home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1996 June / PCPRO_696.ISO / plugins / wirl3d / data.1 / VRCRobot.class (.txt) < prev    next >
Encoding:
Java Class File  |  1995-03-11  |  6.8 KB  |  583 lines

  1. public class VRCRobot implements Runnable {
  2.    VRCObject robot;
  3.    VRCObject upper_body;
  4.    VRCObject top_lower;
  5.    VRCObject top;
  6.    VRCObject r_arm_peg;
  7.    VRCObject r_arm_low;
  8.    VRCObject r_arm_up;
  9.    VRCObject l_arm_peg;
  10.    VRCObject l_arm_low;
  11.    VRCObject l_arm_up;
  12.    VRCObject torso;
  13.    VRCObject r_arm;
  14.    VRCObject r_forearm;
  15.    VRCObject r_hand;
  16.    VRCObject l_arm;
  17.    VRCObject l_forearm;
  18.    VRCObject l_hand;
  19.    VRCObject r_leg;
  20.    VRCObject r_calf;
  21.    VRCObject r_foot;
  22.    VRCObject l_leg;
  23.    VRCObject l_calf;
  24.    VRCObject l_foot;
  25.    VRCObject mid;
  26.    VRCObject window;
  27.    VRCObject l_leg_peg;
  28.    VRCObject r_leg_peg;
  29.    VRCAPI VreamApi = new VRCAPI();
  30.    int ActiveWindow;
  31.    boolean KeepRunning;
  32.  
  33.    public VRCRobot() {
  34.       this.ActiveWindow = this.VreamApi.ActiveHWND;
  35.       this.robot = new VRCObject("robot", this.ActiveWindow);
  36.       this.upper_body = new VRCObject("upper_body", this.ActiveWindow);
  37.       this.torso = new VRCObject("torso", this.ActiveWindow);
  38.       this.r_arm = new VRCObject("r_arm", this.ActiveWindow);
  39.       this.r_forearm = new VRCObject("r_forearm", this.ActiveWindow);
  40.       this.r_hand = new VRCObject("r_hand", this.ActiveWindow);
  41.       this.l_arm = new VRCObject("l_arm", this.ActiveWindow);
  42.       this.l_forearm = new VRCObject("l_forearm", this.ActiveWindow);
  43.       this.l_hand = new VRCObject("l_hand", this.ActiveWindow);
  44.       this.r_leg = new VRCObject("r_leg", this.ActiveWindow);
  45.       this.r_calf = new VRCObject("r_calf", this.ActiveWindow);
  46.       this.r_foot = new VRCObject("r_foot", this.ActiveWindow);
  47.       this.l_leg = new VRCObject("l_leg", this.ActiveWindow);
  48.       this.l_calf = new VRCObject("l_calf", this.ActiveWindow);
  49.       this.l_foot = new VRCObject("l_foot", this.ActiveWindow);
  50.       this.mid = new VRCObject("mid", this.ActiveWindow);
  51.       this.top_lower = new VRCObject("top_lower", this.ActiveWindow);
  52.       this.top = new VRCObject("top", this.ActiveWindow);
  53.       this.r_arm_peg = new VRCObject("r_arm_peg", this.ActiveWindow);
  54.       this.r_arm_low = new VRCObject("r_arm_low", this.ActiveWindow);
  55.       this.r_arm_up = new VRCObject("r_arm_up", this.ActiveWindow);
  56.       this.l_arm_peg = new VRCObject("l_arm_peg", this.ActiveWindow);
  57.       this.l_arm_low = new VRCObject("l_arm_low", this.ActiveWindow);
  58.       this.l_arm_up = new VRCObject("l_arm_up", this.ActiveWindow);
  59.       this.window = new VRCObject("window", this.ActiveWindow);
  60.       this.l_leg_peg = new VRCObject("l_leg_peg", this.ActiveWindow);
  61.       this.r_leg_peg = new VRCObject("r_leg_peg", this.ActiveWindow);
  62.    }
  63.  
  64.    public void run(String var1) {
  65.       if (var1.equals("walk")) {
  66.          this.walk();
  67.       }
  68.  
  69.       if (var1.equals("animate")) {
  70.          this.animate();
  71.       }
  72.  
  73.    }
  74.  
  75.    public void run() {
  76.       this.KeepRunning = true;
  77.  
  78.       while(this.KeepRunning) {
  79.       }
  80.  
  81.    }
  82.  
  83.    public void destroy() {
  84.       this.robot.deactivate();
  85.       this.upper_body.deactivate();
  86.       this.torso.deactivate();
  87.       this.r_arm.deactivate();
  88.       this.r_forearm.deactivate();
  89.       this.r_hand.deactivate();
  90.       this.l_arm.deactivate();
  91.       this.l_forearm.deactivate();
  92.       this.l_hand.deactivate();
  93.       this.r_leg.deactivate();
  94.       this.r_calf.deactivate();
  95.       this.r_foot.deactivate();
  96.       this.l_leg.deactivate();
  97.       this.l_calf.deactivate();
  98.       this.l_foot.deactivate();
  99.       this.mid.deactivate();
  100.       this.top_lower.deactivate();
  101.       this.top.deactivate();
  102.       this.r_arm_peg.deactivate();
  103.       this.r_arm_low.deactivate();
  104.       this.r_arm_up.deactivate();
  105.       this.l_arm_peg.deactivate();
  106.       this.l_arm_low.deactivate();
  107.       this.l_arm_up.deactivate();
  108.       this.window.deactivate();
  109.       this.l_leg_peg.deactivate();
  110.       this.r_leg_peg.deactivate();
  111.       this.VreamApi.destroy();
  112.       this.KeepRunning = false;
  113.       System.gc();
  114.    }
  115.  
  116.    void getRobotPosition() {
  117.       this.robot.getPosition();
  118.       System.out.println(this.robot.fPosVal[0]);
  119.       System.out.println(this.robot.fPosVal[1]);
  120.       System.out.println(this.robot.fPosVal[2]);
  121.    }
  122.  
  123.    void getRobotRotation() {
  124.       this.robot.getRotation();
  125.       System.out.println(this.robot.fRotVal[0]);
  126.       System.out.println(this.robot.fRotVal[1]);
  127.       System.out.println(this.robot.fRotVal[2]);
  128.       System.out.println(this.robot.fRotVal[3]);
  129.       System.out.println(this.robot.fRotVal[4]);
  130.       System.out.println(this.robot.fRotVal[5]);
  131.    }
  132.  
  133.    void randomColor(VRCObject var1) {
  134.       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};
  135.       var1.setColor(var2);
  136.    }
  137.  
  138.    void colorRainbo() {
  139.       for(int var1 = 0; var1 < 2; ++var1) {
  140.          this.randomColor(this.top);
  141.          this.randomColor(this.top_lower);
  142.          this.randomColor(this.window);
  143.          this.randomColor(this.r_arm);
  144.          this.randomColor(this.l_arm);
  145.          this.randomColor(this.mid);
  146.          this.randomColor(this.r_arm_peg);
  147.          this.randomColor(this.l_arm_peg);
  148.          this.randomColor(this.r_arm_low);
  149.          this.randomColor(this.r_arm_up);
  150.          this.randomColor(this.l_arm_low);
  151.          this.randomColor(this.l_arm_up);
  152.          this.randomColor(this.r_forearm);
  153.          this.randomColor(this.l_forearm);
  154.          this.randomColor(this.r_hand);
  155.          this.randomColor(this.l_hand);
  156.          this.randomColor(this.l_leg_peg);
  157.          this.randomColor(this.r_leg_peg);
  158.          this.randomColor(this.r_leg);
  159.          this.randomColor(this.l_leg);
  160.          this.randomColor(this.r_calf);
  161.          this.randomColor(this.l_calf);
  162.          this.randomColor(this.r_foot);
  163.          this.randomColor(this.l_foot);
  164.       }
  165.  
  166.    }
  167.  
  168.    void tranRobot(float[] var1) {
  169.       this.robot.TranslateRel(var1);
  170.    }
  171.  
  172.    void tranUpperBody(float[] var1) {
  173.       this.upper_body.Translate(var1);
  174.    }
  175.  
  176.    void rotUpperBody(float[] var1) {
  177.       var1[3] = 0.0F;
  178.       var1[4] = 0.1F;
  179.       var1[5] = 0.0F;
  180.       this.upper_body.RotateRel(var1);
  181.    }
  182.  
  183.    void spinUpperBody(float[] var1) {
  184.       this.upper_body.Spin(var1);
  185.    }
  186.  
  187.    void tranTorso(float[] var1) {
  188.       this.torso.Translate(var1);
  189.    }
  190.  
  191.    void rotTorso(float[] var1) {
  192.       var1[3] = 0.0F;
  193.       var1[4] = 0.0F;
  194.       var1[5] = 0.0F;
  195.       this.torso.RotateRel(var1);
  196.    }
  197.  
  198.    void spinTorso(float[] var1) {
  199.       this.torso.Spin(var1);
  200.    }
  201.  
  202.    void tranRightArm(float[] var1) {
  203.       this.r_arm.Translate(var1);
  204.    }
  205.  
  206.    void rotRightArm(float[] var1) {
  207.       var1[3] = -2.25F;
  208.       var1[4] = 1.75F;
  209.       var1[5] = 0.0F;
  210.       this.r_arm.RotateRel(var1);
  211.    }
  212.  
  213.    void spinRightArm(float[] var1) {
  214.       this.r_arm.Spin(var1);
  215.    }
  216.  
  217.    void tranRightForearm(float[] var1) {
  218.       this.r_forearm.Translate(var1);
  219.    }
  220.  
  221.    void rotRightForearm(float[] var1) {
  222.       var1[3] = -2.5F;
  223.       var1[4] = 0.25F;
  224.       var1[5] = 0.0F;
  225.       this.r_forearm.RotateRel(var1);
  226.    }
  227.  
  228.    void rotRightHand(float[] var1) {
  229.       var1[3] = -2.5F;
  230.       var1[4] = 0.0F;
  231.       var1[5] = -0.75F;
  232.    }
  233.  
  234.    void rotLeftArm(float[] var1) {
  235.       var1[3] = 2.25F;
  236.       var1[4] = 1.75F;
  237.       var1[5] = 0.0F;
  238.       this.l_arm.RotateRel(var1);
  239.    }
  240.  
  241.    void rotLeftForearm(float[] var1) {
  242.       var1[3] = 2.5F;
  243.       var1[4] = 0.0F;
  244.       var1[5] = 0.25F;
  245.       this.l_forearm.RotateRel(var1);
  246.    }
  247.  
  248.    void rotRightLeg(float[] var1) {
  249.       var1[3] = -1.0F;
  250.       var1[4] = 0.0F;
  251.       var1[5] = 0.0F;
  252.       this.r_leg.RotateRel(var1);
  253.    }
  254.  
  255.    void rotRightCalf(float[] var1) {
  256.       var1[3] = -1.0F;
  257.       var1[4] = -1.25F;
  258.       var1[5] = 0.0F;
  259.       this.r_calf.RotateRel(var1);
  260.    }
  261.  
  262.    void rotRightFoot(float[] var1) {
  263.       var1[3] = -1.0F;
  264.       var1[4] = -2.25F;
  265.       var1[5] = 0.0F;
  266.       this.r_foot.RotateRel(var1);
  267.    }
  268.  
  269.    void rotLeftLeg(float[] var1) {
  270.       var1[3] = 1.0F;
  271.       var1[4] = 0.0F;
  272.       var1[5] = 0.0F;
  273.       this.l_leg.RotateRel(var1);
  274.    }
  275.  
  276.    void rotLeftCalf(float[] var1) {
  277.       var1[3] = -1.0F;
  278.       var1[4] = -1.25F;
  279.       var1[5] = 0.0F;
  280.       this.l_calf.RotateRel(var1);
  281.    }
  282.  
  283.    void rotLeftFoot(float[] var1) {
  284.       var1[3] = -1.0F;
  285.       var1[4] = -2.25F;
  286.       var1[5] = 0.0F;
  287.       this.l_foot.RotateRel(var1);
  288.    }
  289.  
  290.    void rotateArm(String var1, int var2) {
  291.       float[] var3 = new float[6];
  292.       if (var2 == 1) {
  293.          var3[0] = 0.0F;
  294.          var3[1] = 0.0F;
  295.          var3[2] = 0.314F;
  296.       } else {
  297.          var3[0] = 0.0F;
  298.          var3[1] = 0.0F;
  299.          var3[2] = -0.314F;
  300.       }
  301.  
  302.       if (var1.equals("right")) {
  303.          this.rotRightArm(var3);
  304.          this.rotRightForearm(var3);
  305.       } else {
  306.          this.rotLeftArm(var3);
  307.          this.rotLeftForearm(var3);
  308.       }
  309.    }
  310.  
  311.    void rotateFoot(String var1, int var2) {
  312.       float[] var3 = new float[6];
  313.       if (var2 == 1) {
  314.          var3[0] = 0.0F;
  315.          var3[1] = 0.0F;
  316.          var3[2] = 0.03725F;
  317.       } else {
  318.          var3[0] = 0.0F;
  319.          var3[1] = 0.0F;
  320.          var3[2] = -0.03725F;
  321.       }
  322.  
  323.       if (var1.equals("right")) {
  324.          this.rotRightFoot(var3);
  325.       } else {
  326.          this.rotLeftFoot(var3);
  327.       }
  328.    }
  329.  
  330.    public void rotateLeg(String var1, int var2) {
  331.       float[] var3 = new float[6];
  332.       float[] var4 = new float[6];
  333.       if (var2 == 1) {
  334.          var3[0] = 0.0F;
  335.          var3[1] = 0.0F;
  336.          var3[2] = 0.314F;
  337.          var4[0] = 0.0F;
  338.          var4[1] = 0.0F;
  339.          var4[2] = -0.314F;
  340.       } else {
  341.          var3[0] = 0.0F;
  342.          var3[1] = 0.0F;
  343.          var3[2] = -0.314F;
  344.          var4[0] = 0.0F;
  345.          var4[1] = 0.0F;
  346.          var4[2] = 0.314F;
  347.       }
  348.  
  349.       if (var1.equals("right")) {
  350.          this.rotRightLeg(var3);
  351.          this.rotRightCalf(var4);
  352.       } else {
  353.          this.rotLeftLeg(var3);
  354.          this.rotLeftCalf(var4);
  355.       }
  356.    }
  357.  
  358.    public void rotatesLeg(String var1, int var2) {
  359.       float[] var3 = new float[6];
  360.       if (var2 == 1) {
  361.          var3[0] = 0.0F;
  362.          var3[1] = 0.0F;
  363.          var3[2] = 0.03725F;
  364.       } else {
  365.          var3[0] = 0.0F;
  366.          var3[1] = 0.0F;
  367.          var3[2] = -0.03725F;
  368.       }
  369.  
  370.       if (var1.equals("right")) {
  371.          this.rotRightLeg(var3);
  372.       } else {
  373.          this.rotLeftLeg(var3);
  374.       }
  375.    }
  376.  
  377.    public void rotateTorso(int var1) {
  378.       float[] var2 = new float[6];
  379.       if (var1 == 1) {
  380.          var2[0] = 0.314F;
  381.          var2[1] = 0.0F;
  382.          var2[2] = 0.0F;
  383.       } else {
  384.          var2[0] = -0.314F;
  385.          var2[1] = 0.0F;
  386.          var2[2] = 0.0F;
  387.       }
  388.  
  389.       this.rotTorso(var2);
  390.    }
  391.  
  392.    public void pause(int var1) {
  393.       try {
  394.          Thread.sleep((long)(1000 / var1));
  395.       } catch (InterruptedException var2) {
  396.       }
  397.    }
  398.  
  399.    public void wave(String var1) {
  400.       for(int var2 = 0; var2 < 5; ++var2) {
  401.          this.rotateArm(var1, -1);
  402.          this.pause(22);
  403.       }
  404.  
  405.       for(int var3 = 0; var3 < 5; ++var3) {
  406.          this.rotateArm(var1, 1);
  407.          this.pause(22);
  408.       }
  409.  
  410.    }
  411.  
  412.    public void twist(int var1) {
  413.       for(int var2 = 0; var2 < 5; ++var2) {
  414.          this.rotateTorso(var1);
  415.          this.pause(22);
  416.       }
  417.  
  418.       for(int var3 = 0; var3 < 5; ++var3) {
  419.          this.rotateTorso(var1 * -1);
  420.          this.pause(22);
  421.       }
  422.  
  423.    }
  424.  
  425.    public void liftLeg(String var1) {
  426.       for(int var2 = 0; var2 < 5; ++var2) {
  427.          this.rotateLeg(var1, -1);
  428.          this.pause(22);
  429.       }
  430.  
  431.       for(int var3 = 0; var3 < 5; ++var3) {
  432.          this.rotateLeg(var1, 1);
  433.          this.pause(22);
  434.       }
  435.  
  436.    }
  437.  
  438.    public void bendFoot(String var1) {
  439.       for(int var2 = 0; var2 < 5; ++var2) {
  440.          this.rotateFoot(var1, -1);
  441.          this.pause(22);
  442.       }
  443.  
  444.       for(int var3 = 0; var3 < 5; ++var3) {
  445.          this.rotateFoot(var1, 1);
  446.          this.pause(22);
  447.       }
  448.  
  449.    }
  450.  
  451.    public void walk() {
  452.       float[] var1 = new float[]{0.0F, 0.0F, 0.075F};
  453.  
  454.       for(int var2 = 0; var2 < 5; ++var2) {
  455.          this.rotateFoot("left", -1);
  456.          this.rotatesLeg("left", 1);
  457.          this.rotateLeg("right", -1);
  458.          this.tranRobot(var1);
  459.          this.pause(22);
  460.       }
  461.  
  462.       for(int var3 = 0; var3 < 5; ++var3) {
  463.          this.rotateFoot("left", -1);
  464.          this.rotatesLeg("left", 1);
  465.          this.rotatesLeg("right", -1);
  466.          this.rotateLeg("right", 1);
  467.          this.rotateFoot("right", 1);
  468.          this.tranRobot(var1);
  469.          this.pause(22);
  470.       }
  471.  
  472.       for(int var4 = 0; var4 < 5; ++var4) {
  473.          this.rotateFoot("left", 1);
  474.          this.rotatesLeg("left", -1);
  475.          this.rotateFoot("left", 1);
  476.          this.rotatesLeg("left", -1);
  477.          this.rotatesLeg("right", 1);
  478.          this.rotateFoot("right", -1);
  479.          this.tranRobot(var1);
  480.          this.pause(22);
  481.       }
  482.  
  483.       for(int var5 = 0; var5 < 5; ++var5) {
  484.          this.rotateFoot("right", -1);
  485.          this.rotatesLeg("right", 1);
  486.          this.rotateLeg("left", -1);
  487.          this.tranRobot(var1);
  488.          this.pause(22);
  489.       }
  490.  
  491.       for(int var6 = 0; var6 < 5; ++var6) {
  492.          this.rotateFoot("right", -1);
  493.          this.rotatesLeg("right", 1);
  494.          this.rotatesLeg("left", -1);
  495.          this.rotateLeg("left", 1);
  496.          this.rotateFoot("left", 1);
  497.          this.tranRobot(var1);
  498.          this.pause(22);
  499.       }
  500.  
  501.       for(int var7 = 0; var7 < 5; ++var7) {
  502.          this.rotateFoot("right", 1);
  503.          this.rotatesLeg("right", -1);
  504.          this.rotateFoot("right", 1);
  505.          this.rotatesLeg("right", -1);
  506.          this.rotatesLeg("left", 1);
  507.          this.rotateFoot("left", -1);
  508.          this.tranRobot(var1);
  509.          this.pause(22);
  510.       }
  511.  
  512.    }
  513.  
  514.    public void animate() {
  515.       for(int var1 = 0; var1 < 5; ++var1) {
  516.          this.rotateArm("right", -1);
  517.          this.pause(22);
  518.       }
  519.  
  520.       for(int var2 = 0; var2 < 5; ++var2) {
  521.          this.rotateArm("left", -1);
  522.          this.rotateTorso(-1);
  523.          this.rotateLeg("right", -1);
  524.          this.pause(22);
  525.       }
  526.  
  527.       for(int var3 = 0; var3 < 5; ++var3) {
  528.          this.rotateArm("right", 1);
  529.          this.rotateLeg("right", 1);
  530.          this.rotateTorso(1);
  531.          this.pause(22);
  532.       }
  533.  
  534.       for(int var4 = 0; var4 < 5; ++var4) {
  535.          this.rotateArm("left", 1);
  536.          this.pause(22);
  537.       }
  538.  
  539.    }
  540.  
  541.    public void asyncWalk() {
  542.       VRCAsyncRobot var1 = new VRCAsyncRobot(this);
  543.       var1.repeat(2);
  544.       var1.sendCommand("walk");
  545.    }
  546.  
  547.    public void asyncColor() {
  548.       VRCAsyncRobot var1 = new VRCAsyncRobot(this);
  549.       var1.repeat(1);
  550.       var1.sendCommand("color");
  551.    }
  552.  
  553.    public void asyncRWave() {
  554.       VRCAsyncRobot var1 = new VRCAsyncRobot(this);
  555.       var1.repeat(1);
  556.       var1.sendCommand("rwave");
  557.    }
  558.  
  559.    public void asyncLWave() {
  560.       VRCAsyncRobot var1 = new VRCAsyncRobot(this);
  561.       var1.repeat(1);
  562.       var1.sendCommand("lwave");
  563.    }
  564.  
  565.    public void asyncLLeg() {
  566.       VRCAsyncRobot var1 = new VRCAsyncRobot(this);
  567.       var1.repeat(1);
  568.       var1.sendCommand("lleg");
  569.    }
  570.  
  571.    public void asyncRLeg() {
  572.       VRCAsyncRobot var1 = new VRCAsyncRobot(this);
  573.       var1.repeat(1);
  574.       var1.sendCommand("rleg");
  575.    }
  576.  
  577.    public void asyncAnimate() {
  578.       VRCAsyncRobot var1 = new VRCAsyncRobot(this);
  579.       var1.repeat(1);
  580.       var1.sendCommand("animate");
  581.    }
  582. }
  583.