Package edu.cmu.cs.stage3.math

Examples of edu.cmu.cs.stage3.math.Quaternion


  public void startDemoMotion(Ship ship) {
    motionPath = new ShipDemoMotion();
    motionTrack = new ShipMotionTrack(ship, motionPath);
    //motionTrack.setDirectionType(Direction.Path);
    motionTrack.setDirectionType(Direction.PathAndRotation);
    motionTrack.setRotation(new Quaternion().fromAngles(0, 0, 0));
    motionTrack.setSpeed(0.5f);
    motionTrack.setLoopMode(LoopMode.Loop);
    motionTrack.pause();
    timeLeft = 10;
  }
View Full Code Here


            }
        }

        newUp.set(newDirection).crossLocal(newLeft).normalizeLocal();
       
    Quaternion r = new Quaternion().fromAxes(newLeft, newUp, newDirection);
    r.normalize();
    this.setLocalRotation(r);   
  }
View Full Code Here

              ar.cleanup();
                stop();
            } else if (name.equals("SIMPLEAPP_CameraPos")) {
                if (cam != null) {
                    Vector3f loc = cam.getLocation();
                    Quaternion rot = cam.getRotation();
                    System.out.println("Camera Position: ("
                            + loc.x + ", " + loc.y + ", " + loc.z + ")");
                    System.out.println("Camera Rotation: " + rot);
                    System.out.println("Camera Direction: " + cam.getDirection());
                }
View Full Code Here

            if (lerpAmount < 1f) {
                lerpAmount += lerpIncrease * tpf;
                if (lerpAmount > 1f) {
                    lerpAmount = 1f;
                }
                Quaternion newRotation = Quaternion.ZERO.slerp(turnFrom, turnTo, lerpAmount);
                spatial.setLocalRotation(newRotation);
            } else {
                isTurning = false;
                isTurned = true;
                if (!isMoving) {
View Full Code Here

        if (firstPersonConstraint && up.getY() < 0) {
            return;
        }

        Quaternion q = new Quaternion();
        q.fromAxes(left, up, dir);
        q.normalizeLocal();

        cam.setAxes(q);
    }
View Full Code Here

      listener.onCamLocationChange(cam.getLocation());
    }
  }
   
    public void setRotationOffset(float vertical, float horizontal) {
      rotaionOffset = new Quaternion().fromAngles(vertical, horizontal, 0);;
    }
View Full Code Here

    float lr = shipMotionPath.getRotation(this.currentWayPoint);
    float cr = shipMotionPath.getRotation(this.currentWayPoint+1);
   
    float rotation = lr + ((cr - lr) * currentValue);
   
    Quaternion r = new Quaternion().fromAngles(0, 0, rotation);
    spatial.rotate(r);
   
  }
View Full Code Here

        spatial.setLocalTranslation(location.add(0, 0, -4));

        Vector3f vectorDifference = new Vector3f(cam.getLocation().subtract(spatial.getWorldTranslation()));
        spatial.setLocalTranslation(vectorDifference.addLocal(spatial.getLocalTranslation()));

        Quaternion worldDiff = new Quaternion(cam.getRotation().subtract(spatial.getWorldRotation()));
        spatial.setLocalRotation(worldDiff.addLocal(spatial.getLocalRotation()));

        if (spatial.getName().equals("gun")) {
            spatial.move(cam.getDirection().mult(3));
            spatial.move(cam.getUp().mult(-0.8f));
            spatial.move(cam.getLeft().mult(-1f));
            spatial.rotate(0.3f, FastMath.PI, 0);

        } else if (spatial.getName().equals("apple")) {
            spatial.move(cam.getDirection().mult(3));
        } else {
            spatial.move(cam.getDirection().mult(2));
            spatial.move(cam.getUp().mult(-1.5f));
            spatial.move(cam.getLeft().mult(-1f));

            spatial.setLocalRotation(spatial.getLocalRotation().mult(new Quaternion().fromAngles(FastMath.PI - 0.3f, 0, -0.2f)));
        }
    }
View Full Code Here

        IdentityComponent e = em.getEntity(com);
        if(e != null)
        {
          Entity ent = e.getEntity();
          ent.setLocalTranslation(com.position.x, com.position.y+com.heightOffset, com.position.z);
          ent.setLocalRotation(new Quaternion().fromAngleNormalAxis(com.heading, Vector3f.UNIT_Y.negate()));
        } else {
          log.severe("Positioning component without identity component found! comp:"+
              c+" at "+ com.position.x+ ", "+(com.position.y+com.heightOffset)+", "+com.position.z);
          //FIXME this is a workaround, investigate why this can happen! was it added twice? should we better use a hasmap for components
          dumpComponents();
View Full Code Here

    l2j.isPlayer  = true;
    em.setPlayerId(ent.getId());
    l2j.l2jEntity = e;

    ent.setLocalTranslation(pos.position);
    ent.setLocalRotation(new Quaternion().fromAngleAxis(e.getHeading(), Vector3f.UNIT_Y));
    ent.attachChild(visible);
   
    //hook up of the terrain swapping @see SimpleTerrainManager
    ent.addControl(new AbstractControl(){
View Full Code Here

TOP

Related Classes of edu.cmu.cs.stage3.math.Quaternion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.