Examples of Quaternion


Examples of com.jme.math.Quaternion

        }

        // Fetch a whole bunch of things about the view cell: its transform,
        // position, rotation, and "look at" vector.
        Vector3f viewPosition = viewTransform.getTranslation(null);
        Quaternion viewRotation = viewTransform.getRotation(null);
        Vector3f lookAt = CellPlacementUtils.getLookDirection(viewRotation, null);

        logger.info("Using position of view cell " + viewPosition);
        logger.info("Using look-at vector of view cell " + lookAt);
View Full Code Here

Examples of com.jme.math.Quaternion

     *
     * @param viewTransform The transform of the viewer
     * @return A rotation in world coordinates
     */
    public static Quaternion getCellRotation(CellTransform viewTransform) {
        Quaternion viewRotation = viewTransform.getRotation(null);
        Vector3f lookAt = CellPlacementUtils.getLookDirection(viewRotation, null);
        Quaternion rotation = new Quaternion();
        rotation.lookAt(lookAt.negate(), new Vector3f(0, 1, 0));
        return rotation;
    }
View Full Code Here

Examples of com.jme.math.Quaternion

        startingLocationMI = new JMenuItem(BUNDLE.getString("Starting_Location"));
        startingLocationMI.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
               
                Vector3f position = new Vector3f();
                Quaternion look = new Quaternion();

                String prop = System.getProperty("Placemark.CoverScreen");
                if(prop == null) {
                    prop="";
                }
View Full Code Here

Examples of com.jme.math.Quaternion

        // Find out what the URL to the server is
        String url = sessionManager.getServerURL();

        // Compute the current look angle, as degrees from the +x axis, ignoring
        // any look in the y-axis.
        Quaternion viewRotation = viewTransform.getRotation(null);

        Vector3f v1 = new Vector3f(0, 0, 1);
        Vector3f normal = new Vector3f(0, 1, 0);
        Vector3f v2 = viewRotation.mult(v1);
        v2.normalizeLocal();

        // Compute the signed angle between v1 and v2. We do this with the
        // following formula: angle = atan2(normal dot (v1 cross v2), v1 dot v2)
        float dotProduct = v1.dot(v2);
View Full Code Here

Examples of com.jme3.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

Examples of com.ngt.jopenmetaverse.shared.types.Quaternion

        {
            float[] mat = new float[16];

            // Transpose the quaternion (don't ask me why)
//            q = new Quaternion(q.W, q.X, q.Y, q.Z);
            q = new Quaternion(q);
            q.X = q.X * -1f;
            q.Y = q.Y * -1f;
            q.Z = q.Z * -1f;

            float x2 = q.X + q.X;
View Full Code Here

Examples of com.thecrouchmode.vector.Quaternion

   
    Matrix4f scale = Matrix4f.scale(1);
    Matrix4f translation = Matrix4f.translation(0,0,0);
    Matrix4f rotation = Matrix4f.identity;
    //Matrix4f model = translation.multiply(scale);
    Quaternion zrotation = new Quaternion(-Math.PI/360, new Vector3f(0,1,2));
    Quaternion rotQ = zrotation;
   
    float ztrans = 0;
    float xtrans = 0;
   
    Vector3f camForw = Vector3f.zUnit;
    Vector3f camSide = Vector3f.xUnit.scale(-1);
   
    double value = 0;
   
    time = System.currentTimeMillis();
    int fpsMod = 0;
   
    Light light = Light.builder()
        .intensity(255/1, 255/2, 255/3)
        .pos(1, 1, 1).build();
    shader.setUniform("lightPos", light.pos.xyz());
    shader.setUniform("lightIntensity", light.intensity);
   
    Matrix4f view = Matrix4f.view(
        new Vector3f(0, 0, -5),
        camForw,
        Vector3f.cross(camSide, camForw));
   
    float camX = 0;
    float camZ = 0;
   
    Vector3f trans = new Vector3f(1, 0.5, -4);
   
    while(true){
      try{
        if(Display.isCloseRequested()){
          Display.destroy();
          Keyboard.destroy();
          //cleanup
          break;
        }
        else{
         
          Keyboard.poll();
          //Mouse.poll();
          //System.out.println("Mouse: " +Mouse.getDX());

          //view = Matrix4f.product(Matrix4f.rotation(Mouse.getDX()/(1000*Math.PI), Vector3f.yUnit), view);
          //view = Matrix4f.product(Matrix4f.rotation(-Mouse.getDY()/(1000*Math.PI), Vector3f.xUnit), view);
         
         

         
          while(Keyboard.next()){
            int keyNo = Keyboard.getEventKey();
            char character = Keyboard.getEventCharacter();
            boolean down = Keyboard.getEventKeyState();
           
            //System.out.print("Key " + keyNo + "(" + character +") ");
           
            float moveSpeed = 0.1f;
            if(keyNo == 17 && down){
              xtrans += moveSpeed;
            }
            if(keyNo == 30 && down){
              ztrans -= moveSpeed;
            }
            if(keyNo == 31 && down){
              xtrans -= moveSpeed;
            }
            if(keyNo == 32 && down){
              ztrans += moveSpeed;
            }
           
            if(keyNo == 17 && !down){
              xtrans -= moveSpeed;
            }
            if(keyNo == 30 && !down){
              ztrans += moveSpeed;
            }
            if(keyNo == 31 && !down){
              xtrans += moveSpeed;
            }
            if(keyNo == 32 && !down){
              ztrans -= moveSpeed;
            }
          }
         
          trans = Vector3f.sum(
              trans,
              camForw.xz().unit().scale(xtrans),
              camSide.xz().unit().scale(ztrans));
         
//          Matrix4f camRot = Quaternion.product(
//                  new Quaternion(Mouse.getDY()/(600*Math.PI), camSide),
//                  new Quaternion(-Mouse.getDX()/(600*Math.PI), Vector3f.yUnit)).normalize().rotationMatrix();
         
          Matrix4f camRot = Quaternion.product(
              new Quaternion(-Mouse.getDX()/(600*Math.PI), Vector3f.yUnit),
              new Quaternion(Mouse.getDY()/(600*Math.PI), camSide)).normalize().rotationMatrix();
         
          view = Matrix4f.product();
          camForw = camRot.multiply(camForw, 1).xyz();
          camSide = camRot.multiply(camSide, 1).xyz();
         
          view = Matrix4f.view(
              trans,
              camForw,
              Vector3f.cross(camSide, camForw));
         
          value = value+0.01
         
          Renderer.clear();


//          light.pos = new Vector4f(
//              1+3*(float)Math.sin(-2*value),
//              1+1*(float)Math.cos(-2*value),
//              1f,//,
//              1.0f);
         
          light.pos = new Vector4f(trans, 1.0f);

         
          shader.use();
         
          shader.setUniform("lightPos", light.pos.xyz());
          shader.setUniform("lightInt", light.intensity);
          shader.setUniform("flip", 0);
         
          //rotQ = rotQ.multiply(zrotation);//.normalize();
          rotation = rotQ.rotationMatrix();
         
          translation = Matrix4f.translation(0, 0, 0);
          Matrix4f m = Matrix4f.product(translation, rotation, scale, dragon.normalization);
          Matrix4f vp = Matrix4f.product(projection, view);
          shader.setUniform("M", m);
View Full Code Here

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

    public void buildPoses(Model rootMod, Pose startPose, Pose endPose) {
        Key positionKey;
        Key quaternionKey;
        Vector3 position;
        Quaternion orientation;


        if (realMod!=null) {
            position=realMod.getPosition();
            if (dof.contains(ASFBone.DOF_TX) || dof.contains(ASFBone.DOF_TY) || dof.contains(ASFBone.DOF_TZ)) {
View Full Code Here

Examples of fcagnin.jglsdk.glm.Quaternion

        axis = Glm.normalize( axis );
        axis = Vec3.scale( axis, (float) Math.sin( angRad / 2.0f ) );

        float scalar = (float) Math.cos( angRad / 2.0f );

        Quaternion offset = new Quaternion( scalar, axis.x, axis.y, axis.z );

        if ( rightMultiply ) {
            orientation = Quaternion.mul( orientation, offset );
        } else {
            orientation = Quaternion.mul( offset, orientation );
View Full Code Here

Examples of org.apache.commons.math3.complex.Quaternion

    }

    @Test
    public final void testObjectEquals() {
        final double one = 1;
        final Quaternion q1 = new Quaternion(one, one, one, one);
        Assert.assertTrue(q1.equals(q1));

        final Quaternion q2 = new Quaternion(one, one, one, one);
        Assert.assertTrue(q2.equals(q1));

        final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one);
        Assert.assertFalse(q3.equals(q1));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.