home *** CD-ROM | disk | FTP | other *** search
- public class VRCRobot implements Runnable {
- VRCObject robot;
- VRCObject upper_body;
- VRCObject top_lower;
- VRCObject top;
- VRCObject r_arm_peg;
- VRCObject r_arm_low;
- VRCObject r_arm_up;
- VRCObject l_arm_peg;
- VRCObject l_arm_low;
- VRCObject l_arm_up;
- VRCObject torso;
- VRCObject r_arm;
- VRCObject r_forearm;
- VRCObject r_hand;
- VRCObject l_arm;
- VRCObject l_forearm;
- VRCObject l_hand;
- VRCObject r_leg;
- VRCObject r_calf;
- VRCObject r_foot;
- VRCObject l_leg;
- VRCObject l_calf;
- VRCObject l_foot;
- VRCObject mid;
- VRCObject window;
- VRCObject l_leg_peg;
- VRCObject r_leg_peg;
- VRCAPI VreamApi = new VRCAPI();
- int ActiveWindow;
- boolean KeepRunning;
-
- public VRCRobot() {
- this.ActiveWindow = this.VreamApi.ActiveHWND;
- this.robot = new VRCObject("robot", this.ActiveWindow);
- this.upper_body = new VRCObject("upper_body", this.ActiveWindow);
- this.torso = new VRCObject("torso", this.ActiveWindow);
- this.r_arm = new VRCObject("r_arm", this.ActiveWindow);
- this.r_forearm = new VRCObject("r_forearm", this.ActiveWindow);
- this.r_hand = new VRCObject("r_hand", this.ActiveWindow);
- this.l_arm = new VRCObject("l_arm", this.ActiveWindow);
- this.l_forearm = new VRCObject("l_forearm", this.ActiveWindow);
- this.l_hand = new VRCObject("l_hand", this.ActiveWindow);
- this.r_leg = new VRCObject("r_leg", this.ActiveWindow);
- this.r_calf = new VRCObject("r_calf", this.ActiveWindow);
- this.r_foot = new VRCObject("r_foot", this.ActiveWindow);
- this.l_leg = new VRCObject("l_leg", this.ActiveWindow);
- this.l_calf = new VRCObject("l_calf", this.ActiveWindow);
- this.l_foot = new VRCObject("l_foot", this.ActiveWindow);
- this.mid = new VRCObject("mid", this.ActiveWindow);
- this.top_lower = new VRCObject("top_lower", this.ActiveWindow);
- this.top = new VRCObject("top", this.ActiveWindow);
- this.r_arm_peg = new VRCObject("r_arm_peg", this.ActiveWindow);
- this.r_arm_low = new VRCObject("r_arm_low", this.ActiveWindow);
- this.r_arm_up = new VRCObject("r_arm_up", this.ActiveWindow);
- this.l_arm_peg = new VRCObject("l_arm_peg", this.ActiveWindow);
- this.l_arm_low = new VRCObject("l_arm_low", this.ActiveWindow);
- this.l_arm_up = new VRCObject("l_arm_up", this.ActiveWindow);
- this.window = new VRCObject("window", this.ActiveWindow);
- this.l_leg_peg = new VRCObject("l_leg_peg", this.ActiveWindow);
- this.r_leg_peg = new VRCObject("r_leg_peg", this.ActiveWindow);
- }
-
- public void run(String var1) {
- if (var1.equals("walk")) {
- this.walk();
- }
-
- if (var1.equals("animate")) {
- this.animate();
- }
-
- }
-
- public void run() {
- this.KeepRunning = true;
-
- while(this.KeepRunning) {
- }
-
- }
-
- public void destroy() {
- this.robot.deactivate();
- this.upper_body.deactivate();
- this.torso.deactivate();
- this.r_arm.deactivate();
- this.r_forearm.deactivate();
- this.r_hand.deactivate();
- this.l_arm.deactivate();
- this.l_forearm.deactivate();
- this.l_hand.deactivate();
- this.r_leg.deactivate();
- this.r_calf.deactivate();
- this.r_foot.deactivate();
- this.l_leg.deactivate();
- this.l_calf.deactivate();
- this.l_foot.deactivate();
- this.mid.deactivate();
- this.top_lower.deactivate();
- this.top.deactivate();
- this.r_arm_peg.deactivate();
- this.r_arm_low.deactivate();
- this.r_arm_up.deactivate();
- this.l_arm_peg.deactivate();
- this.l_arm_low.deactivate();
- this.l_arm_up.deactivate();
- this.window.deactivate();
- this.l_leg_peg.deactivate();
- this.r_leg_peg.deactivate();
- this.VreamApi.destroy();
- this.KeepRunning = false;
- System.gc();
- }
-
- void getRobotPosition() {
- this.robot.getPosition();
- System.out.println(this.robot.fPosVal[0]);
- System.out.println(this.robot.fPosVal[1]);
- System.out.println(this.robot.fPosVal[2]);
- }
-
- void getRobotRotation() {
- this.robot.getRotation();
- System.out.println(this.robot.fRotVal[0]);
- System.out.println(this.robot.fRotVal[1]);
- System.out.println(this.robot.fRotVal[2]);
- System.out.println(this.robot.fRotVal[3]);
- System.out.println(this.robot.fRotVal[4]);
- System.out.println(this.robot.fRotVal[5]);
- }
-
- void randomColor(VRCObject var1) {
- int[] var2 = new int[]{(int)((double)1.0F / Math.random()) * (int)((double)1.0F / Math.random()) + (int)((double)1.0F / Math.random()) * 10, (int)((double)1.0F / Math.random()) * (int)((double)1.0F / Math.random()) + (int)((double)1.0F / Math.random()) * 10, (int)((double)1.0F / Math.random()) * (int)((double)1.0F / Math.random()) + (int)((double)1.0F / Math.random()) * 10};
- var1.setColor(var2);
- }
-
- void colorRainbo() {
- for(int var1 = 0; var1 < 2; ++var1) {
- this.randomColor(this.top);
- this.randomColor(this.top_lower);
- this.randomColor(this.window);
- this.randomColor(this.r_arm);
- this.randomColor(this.l_arm);
- this.randomColor(this.mid);
- this.randomColor(this.r_arm_peg);
- this.randomColor(this.l_arm_peg);
- this.randomColor(this.r_arm_low);
- this.randomColor(this.r_arm_up);
- this.randomColor(this.l_arm_low);
- this.randomColor(this.l_arm_up);
- this.randomColor(this.r_forearm);
- this.randomColor(this.l_forearm);
- this.randomColor(this.r_hand);
- this.randomColor(this.l_hand);
- this.randomColor(this.l_leg_peg);
- this.randomColor(this.r_leg_peg);
- this.randomColor(this.r_leg);
- this.randomColor(this.l_leg);
- this.randomColor(this.r_calf);
- this.randomColor(this.l_calf);
- this.randomColor(this.r_foot);
- this.randomColor(this.l_foot);
- }
-
- }
-
- void tranRobot(float[] var1) {
- this.robot.TranslateRel(var1);
- }
-
- void tranUpperBody(float[] var1) {
- this.upper_body.Translate(var1);
- }
-
- void rotUpperBody(float[] var1) {
- var1[3] = 0.0F;
- var1[4] = 0.1F;
- var1[5] = 0.0F;
- this.upper_body.RotateRel(var1);
- }
-
- void spinUpperBody(float[] var1) {
- this.upper_body.Spin(var1);
- }
-
- void tranTorso(float[] var1) {
- this.torso.Translate(var1);
- }
-
- void rotTorso(float[] var1) {
- var1[3] = 0.0F;
- var1[4] = 0.0F;
- var1[5] = 0.0F;
- this.torso.RotateRel(var1);
- }
-
- void spinTorso(float[] var1) {
- this.torso.Spin(var1);
- }
-
- void tranRightArm(float[] var1) {
- this.r_arm.Translate(var1);
- }
-
- void rotRightArm(float[] var1) {
- var1[3] = -2.25F;
- var1[4] = 1.75F;
- var1[5] = 0.0F;
- this.r_arm.RotateRel(var1);
- }
-
- void spinRightArm(float[] var1) {
- this.r_arm.Spin(var1);
- }
-
- void tranRightForearm(float[] var1) {
- this.r_forearm.Translate(var1);
- }
-
- void rotRightForearm(float[] var1) {
- var1[3] = -2.5F;
- var1[4] = 0.25F;
- var1[5] = 0.0F;
- this.r_forearm.RotateRel(var1);
- }
-
- void rotRightHand(float[] var1) {
- var1[3] = -2.5F;
- var1[4] = 0.0F;
- var1[5] = -0.75F;
- }
-
- void rotLeftArm(float[] var1) {
- var1[3] = 2.25F;
- var1[4] = 1.75F;
- var1[5] = 0.0F;
- this.l_arm.RotateRel(var1);
- }
-
- void rotLeftForearm(float[] var1) {
- var1[3] = 2.5F;
- var1[4] = 0.0F;
- var1[5] = 0.25F;
- this.l_forearm.RotateRel(var1);
- }
-
- void rotRightLeg(float[] var1) {
- var1[3] = -1.0F;
- var1[4] = 0.0F;
- var1[5] = 0.0F;
- this.r_leg.RotateRel(var1);
- }
-
- void rotRightCalf(float[] var1) {
- var1[3] = -1.0F;
- var1[4] = -1.25F;
- var1[5] = 0.0F;
- this.r_calf.RotateRel(var1);
- }
-
- void rotRightFoot(float[] var1) {
- var1[3] = -1.0F;
- var1[4] = -2.25F;
- var1[5] = 0.0F;
- this.r_foot.RotateRel(var1);
- }
-
- void rotLeftLeg(float[] var1) {
- var1[3] = 1.0F;
- var1[4] = 0.0F;
- var1[5] = 0.0F;
- this.l_leg.RotateRel(var1);
- }
-
- void rotLeftCalf(float[] var1) {
- var1[3] = -1.0F;
- var1[4] = -1.25F;
- var1[5] = 0.0F;
- this.l_calf.RotateRel(var1);
- }
-
- void rotLeftFoot(float[] var1) {
- var1[3] = -1.0F;
- var1[4] = -2.25F;
- var1[5] = 0.0F;
- this.l_foot.RotateRel(var1);
- }
-
- void rotateArm(String var1, int var2) {
- float[] var3 = new float[6];
- if (var2 == 1) {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = 0.314F;
- } else {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = -0.314F;
- }
-
- if (var1.equals("right")) {
- this.rotRightArm(var3);
- this.rotRightForearm(var3);
- } else {
- this.rotLeftArm(var3);
- this.rotLeftForearm(var3);
- }
- }
-
- void rotateFoot(String var1, int var2) {
- float[] var3 = new float[6];
- if (var2 == 1) {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = 0.03725F;
- } else {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = -0.03725F;
- }
-
- if (var1.equals("right")) {
- this.rotRightFoot(var3);
- } else {
- this.rotLeftFoot(var3);
- }
- }
-
- public void rotateLeg(String var1, int var2) {
- float[] var3 = new float[6];
- float[] var4 = new float[6];
- if (var2 == 1) {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = 0.314F;
- var4[0] = 0.0F;
- var4[1] = 0.0F;
- var4[2] = -0.314F;
- } else {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = -0.314F;
- var4[0] = 0.0F;
- var4[1] = 0.0F;
- var4[2] = 0.314F;
- }
-
- if (var1.equals("right")) {
- this.rotRightLeg(var3);
- this.rotRightCalf(var4);
- } else {
- this.rotLeftLeg(var3);
- this.rotLeftCalf(var4);
- }
- }
-
- public void rotatesLeg(String var1, int var2) {
- float[] var3 = new float[6];
- if (var2 == 1) {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = 0.03725F;
- } else {
- var3[0] = 0.0F;
- var3[1] = 0.0F;
- var3[2] = -0.03725F;
- }
-
- if (var1.equals("right")) {
- this.rotRightLeg(var3);
- } else {
- this.rotLeftLeg(var3);
- }
- }
-
- public void rotateTorso(int var1) {
- float[] var2 = new float[6];
- if (var1 == 1) {
- var2[0] = 0.314F;
- var2[1] = 0.0F;
- var2[2] = 0.0F;
- } else {
- var2[0] = -0.314F;
- var2[1] = 0.0F;
- var2[2] = 0.0F;
- }
-
- this.rotTorso(var2);
- }
-
- public void pause(int var1) {
- try {
- Thread.sleep((long)(1000 / var1));
- } catch (InterruptedException var2) {
- }
- }
-
- public void wave(String var1) {
- for(int var2 = 0; var2 < 5; ++var2) {
- this.rotateArm(var1, -1);
- this.pause(22);
- }
-
- for(int var3 = 0; var3 < 5; ++var3) {
- this.rotateArm(var1, 1);
- this.pause(22);
- }
-
- }
-
- public void twist(int var1) {
- for(int var2 = 0; var2 < 5; ++var2) {
- this.rotateTorso(var1);
- this.pause(22);
- }
-
- for(int var3 = 0; var3 < 5; ++var3) {
- this.rotateTorso(var1 * -1);
- this.pause(22);
- }
-
- }
-
- public void liftLeg(String var1) {
- for(int var2 = 0; var2 < 5; ++var2) {
- this.rotateLeg(var1, -1);
- this.pause(22);
- }
-
- for(int var3 = 0; var3 < 5; ++var3) {
- this.rotateLeg(var1, 1);
- this.pause(22);
- }
-
- }
-
- public void bendFoot(String var1) {
- for(int var2 = 0; var2 < 5; ++var2) {
- this.rotateFoot(var1, -1);
- this.pause(22);
- }
-
- for(int var3 = 0; var3 < 5; ++var3) {
- this.rotateFoot(var1, 1);
- this.pause(22);
- }
-
- }
-
- public void walk() {
- float[] var1 = new float[]{0.0F, 0.0F, 0.075F};
-
- for(int var2 = 0; var2 < 5; ++var2) {
- this.rotateFoot("left", -1);
- this.rotatesLeg("left", 1);
- this.rotateLeg("right", -1);
- this.tranRobot(var1);
- this.pause(22);
- }
-
- for(int var3 = 0; var3 < 5; ++var3) {
- this.rotateFoot("left", -1);
- this.rotatesLeg("left", 1);
- this.rotatesLeg("right", -1);
- this.rotateLeg("right", 1);
- this.rotateFoot("right", 1);
- this.tranRobot(var1);
- this.pause(22);
- }
-
- for(int var4 = 0; var4 < 5; ++var4) {
- this.rotateFoot("left", 1);
- this.rotatesLeg("left", -1);
- this.rotateFoot("left", 1);
- this.rotatesLeg("left", -1);
- this.rotatesLeg("right", 1);
- this.rotateFoot("right", -1);
- this.tranRobot(var1);
- this.pause(22);
- }
-
- for(int var5 = 0; var5 < 5; ++var5) {
- this.rotateFoot("right", -1);
- this.rotatesLeg("right", 1);
- this.rotateLeg("left", -1);
- this.tranRobot(var1);
- this.pause(22);
- }
-
- for(int var6 = 0; var6 < 5; ++var6) {
- this.rotateFoot("right", -1);
- this.rotatesLeg("right", 1);
- this.rotatesLeg("left", -1);
- this.rotateLeg("left", 1);
- this.rotateFoot("left", 1);
- this.tranRobot(var1);
- this.pause(22);
- }
-
- for(int var7 = 0; var7 < 5; ++var7) {
- this.rotateFoot("right", 1);
- this.rotatesLeg("right", -1);
- this.rotateFoot("right", 1);
- this.rotatesLeg("right", -1);
- this.rotatesLeg("left", 1);
- this.rotateFoot("left", -1);
- this.tranRobot(var1);
- this.pause(22);
- }
-
- }
-
- public void animate() {
- for(int var1 = 0; var1 < 5; ++var1) {
- this.rotateArm("right", -1);
- this.pause(22);
- }
-
- for(int var2 = 0; var2 < 5; ++var2) {
- this.rotateArm("left", -1);
- this.rotateTorso(-1);
- this.rotateLeg("right", -1);
- this.pause(22);
- }
-
- for(int var3 = 0; var3 < 5; ++var3) {
- this.rotateArm("right", 1);
- this.rotateLeg("right", 1);
- this.rotateTorso(1);
- this.pause(22);
- }
-
- for(int var4 = 0; var4 < 5; ++var4) {
- this.rotateArm("left", 1);
- this.pause(22);
- }
-
- }
-
- public void asyncWalk() {
- VRCAsyncRobot var1 = new VRCAsyncRobot(this);
- var1.repeat(2);
- var1.sendCommand("walk");
- }
-
- public void asyncColor() {
- VRCAsyncRobot var1 = new VRCAsyncRobot(this);
- var1.repeat(1);
- var1.sendCommand("color");
- }
-
- public void asyncRWave() {
- VRCAsyncRobot var1 = new VRCAsyncRobot(this);
- var1.repeat(1);
- var1.sendCommand("rwave");
- }
-
- public void asyncLWave() {
- VRCAsyncRobot var1 = new VRCAsyncRobot(this);
- var1.repeat(1);
- var1.sendCommand("lwave");
- }
-
- public void asyncLLeg() {
- VRCAsyncRobot var1 = new VRCAsyncRobot(this);
- var1.repeat(1);
- var1.sendCommand("lleg");
- }
-
- public void asyncRLeg() {
- VRCAsyncRobot var1 = new VRCAsyncRobot(this);
- var1.repeat(1);
- var1.sendCommand("rleg");
- }
-
- public void asyncAnimate() {
- VRCAsyncRobot var1 = new VRCAsyncRobot(this);
- var1.repeat(1);
- var1.sendCommand("animate");
- }
- }
-