コード例 #1
0
ファイル: Main.java プロジェクト: Wigglez/GSP362
  @Override
  public void simpleUpdate(float tpf) {
    Juggernaut.Update(tpf);
    // Vector3f camLeft = cam.getLeft().clone().multLocal(0.4f);
    //        walkDirection.set( 0, 0, 0);
    //        if(left)    { walkDirection.addLocal(Vector3f.UNIT_X.negate().multLocal(0.4f));}
    //        if(right)   { walkDirection.addLocal(Vector3f.UNIT_X.clone().multLocal(0.4f));}
    //        player.setWalkDirection(walkDirection);
    //        if( walkDirection != Vector3f.ZERO){
    //            player.setViewDirection(walkDirection.negate());
    //        }
    //
    //        playerDebug.setLocalTranslation(player.getPhysicsLocation());
    elevator1.setLocalTranslation(304 + 20 * FastMath.cos(timer.getTimeInSeconds()), 20, 0);
    elvtr1.setPhysicsLocation(elevator1.getLocalTranslation());

    //        elevator2.setLocalTranslation( 192, 208 + 35*FastMath.cos(timer.getTimeInSeconds()),
    // 0);
    //        elvtr2.setPhysicsLocation(elevator2.getLocalTranslation());
    elvtr2.setLinearVelocity(new Vector3f(0, 25 * FastMath.cos(timer.getTimeInSeconds()), 0));
    elvtr2.setPhysicsRotation(Matrix3f.IDENTITY);
    System.out.print(landscape.getCollideWithGroups() + "\n");

    for (int i = 0; i < views.length; i++) {
      if (views[i].testForPlayer(Juggernaut)) {
        currentView = views[i];
      }
    }

    cam.setLocation(currentView.CamPosition());
    cam.lookAt(currentView.CamLookAt(), Vector3f.UNIT_Y);
  }
コード例 #2
0
 @Override
 public void update(float tpf) {
   Quaternion rot = new Quaternion().fromAngleAxis(FastMath.QUARTER_PI * tpf, Vector3f.UNIT_Y);
   if (control != null) {
     Quaternion angle = control.getPhysicsRotation();
     Quaternion rotation = rot.mult(angle).normalizeLocal();
     control.setPhysicsRotation(rotation);
     car_con[index].setPhysicsRotation(rotation);
   }
 }
コード例 #3
0
  public void setRotation(String objectID, float[] rotation) {
    // get "visual" or "physical" spatial
    // search in all sub-nodes of root node (scene node, trigger node, ...)
    Spatial object = Util.findNode(sim.getRootNode(), objectID);
    RigidBodyControl control = null;

    try {
      control = (RigidBodyControl) object.getControl(0);
    } catch (IndexOutOfBoundsException e2) {
      System.err.println("Could not manipulate physics of '" + objectID + "'!");
    }

    if (control != null) {
      Quaternion rot = new Quaternion().fromAngles(degToRad(rotation));
      control.setPhysicsRotation(rot);
    } else {
      Quaternion rot = new Quaternion().fromAngles(degToRad(rotation));
      object.setLocalRotation(rot);
    }
  }
コード例 #4
0
 @Override
 protected void controlUpdate(float tpf) {
   RigidBodyControl diceControl = spatial.getControl(RigidBodyControl.class);
   if (number != 0) {
     diceControl.setEnabled(true);
     int numberValue = 0;
     synchronized (spatial) {
       numberValue = number;
     }
     switch (numberValue) {
       case 1:
         diceControl.setPhysicsRotation(
             new Quaternion().fromAngleAxis(FastMath.HALF_PI, new Vector3f(1, 0, 0)));
         break;
       case 2:
         diceControl.setPhysicsRotation(
             new Quaternion().fromAngleAxis(-FastMath.HALF_PI, new Vector3f(0, 1, 0)));
         break;
       case 3:
         diceControl.setPhysicsRotation(
             new Quaternion().fromAngleAxis(FastMath.ZERO_TOLERANCE, new Vector3f(1, 0, 0)));
         break;
       case 4:
         diceControl.setPhysicsRotation(
             new Quaternion().fromAngleAxis(FastMath.PI, new Vector3f(1, 0, 0)));
         break;
       case 5:
         diceControl.setPhysicsRotation(
             new Quaternion().fromAngleAxis(FastMath.HALF_PI, new Vector3f(0, 1, 0)));
         break;
       case 6:
         diceControl.setPhysicsRotation(
             new Quaternion().fromAngleAxis(-FastMath.HALF_PI, new Vector3f(1, 0, 0)));
         break;
     }
     diceControl.setLinearVelocity(new Vector3f(0, 0, 0));
     diceControl.setAngularVelocity(new Vector3f(0, 0, 0));
     diceControl.setPhysicsLocation(putLocation);
     spatial.getControl(AbstractRollControl.class).setEnabled(false);
     Geometry d6 = ((Geometry) spatial);
     d6.getMaterial().setColor("Diffuse", ColorRGBA.White);
     number = 0;
   } else {
     diceControl.setEnabled(false);
     this.setEnabled(false);
   }
 }