Package fcagnin.jglsdk.glm

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


        Glm.clamp( dot, -1.0f, 1.0f );
        float theta_0 = (float) Math.acos( dot );
        float theta = theta_0 * alpha;

        Quaternion v2 = Quaternion.add( v1, Quaternion.negate( Quaternion.scale( v0, dot ) ) );
        v2 = Glm.normalize( v2 );

        return Quaternion.add( Quaternion.scale( v0, (float) Math.cos( theta ) ),
                Quaternion.scale( v2, (float) Math.sin( theta ) ) );
    }
View Full Code Here

        Vec4 interp = Glm.mix( start, end, alpha );

        System.out.printf( "alpha: %f, (%f, %f, %f, %f)\n", alpha, interp.w, interp.x, interp.y, interp.z );

        interp = Glm.normalize( interp );
        return new Quaternion( interp.w, interp.x, interp.y, interp.z );
    }
View Full Code Here

      // In this space, we are facing in the correct direction. Which means that the camera point
      // is directly behind us by the radius number of units.
      mat = Glm.translate(mat, new Vec3(0.0f, 0.0f, -m_currView.radius));

      // Rotate the world to look in the right direction..
      Quaternion fullRotation = Glm.angleAxis(m_currView.degSpinRotation, new Vec3(0.0f, 0.0f, 1.0f)).mul(m_currView.orient);

      mat.mul(Glm.matCast(fullRotation));

      // Translate the world by the negation of the lookat point, placing the origin at the lookat point.
      mat = Glm.translate(mat, Vec3.negate(m_currView.targetPos));
View Full Code Here

      offsetTargetPos(offsetDir.scale(worldDistance).scale(lastFrameDuration), lastFrameDuration);
    }

    private void offsetTargetPos(Vec3 cameraOffset, float lastFrameDuration) {
      Mat4 currMat = calcMatrix();
      Quaternion orientation = Glm.quatCast(currMat);

      Quaternion invOrient = Glm.conjugate(orientation);
      Vec3 worldOffset = invOrient.mul(cameraOffset);

      m_currView.targetPos.add(worldOffset);
    }
View Full Code Here

      this.orientation = orientation;
    }

    public ObjectData(ObjectData initialData) {
      position = new Vec3(initialData.position);
      orientation = new Quaternion(initialData.orientation);
    }
View Full Code Here

    public float radius;
    float degSpinRotation;
   
    public ViewData(ViewData viewData) {
      targetPos = new Vec3(viewData.targetPos);
      orient = new Quaternion(viewData.orient);
      radius = viewData.radius;
      degSpinRotation = viewData.degSpinRotation;
    }
View Full Code Here

      if (m_bIsDragging) {
        Vec2 iDiff = Vec2.sub(position, m_prevMousePos);
   
        switch (m_RotateMode) {
          case RM_DUAL_AXIS: {
            Quaternion rot = calcRotationQuat(Axis.AXIS_Y.ordinal(), iDiff.x * m_rotateScale);
            rot = Glm.normalize(calcRotationQuat(Axis.AXIS_X.ordinal(), - iDiff.y * m_rotateScale).mul(rot))// Y axis is different in LWJGL
            rotateViewDegrees(rot);
            break;
         
         
          case RM_BIAXIAL: {
            Vec2 iInitDiff = Vec2.sub(position, m_startDragMousePos);
   
            Axis eAxis;
            float degAngle;
            if (Math.abs(iInitDiff.x) > Math.abs(iInitDiff.y)) {
              eAxis = Axis.AXIS_Y;
              degAngle = iInitDiff.x * m_rotateScale;
            } else {
              eAxis = Axis.AXIS_X;
              degAngle = iInitDiff.y * m_rotateScale;
            }
   
            Quaternion rot = calcRotationQuat(eAxis.ordinal(), degAngle);
            rotateViewDegrees(rot, true);
            break;
          }
         
          case RM_SPIN: {
View Full Code Here

      if (!m_bIsDragging) {
        bFromInitial = false;
      }
     
      if (m_pView != null) {
        Quaternion viewQuat = Glm.quatCast(m_pView.calcMatrix());
        Quaternion invViewQuat = Glm.conjugate(viewQuat);

        m_po.orientation = Glm.normalize(Quaternion.mul(Quaternion.mul(invViewQuat,rot), (viewQuat)).mul(bFromInitial ? m_startDragOrient : m_po.orientation));   
      } else {
        rotateWorldDegrees(rot, bFromInitial);
      }
View Full Code Here

TOP

Related Classes of fcagnin.jglsdk.glm.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.