Java Code Examples for com.jme3.math.Quaternion#fromAngles()

The following examples show how to use com.jme3.math.Quaternion#fromAngles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestOgreComplexAnim.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleUpdate(float tpf) {
    Joint j = skinningControl.getArmature().getJoint("spinehigh");
    Joint j2 = skinningControl.getArmature().getJoint("uparm.left");

    angle += tpf * rate;
    if (angle > FastMath.HALF_PI / 2f) {
        angle = FastMath.HALF_PI / 2f;
        rate = -1;
    } else if (angle < -FastMath.HALF_PI / 2f) {
        angle = -FastMath.HALF_PI / 2f;
        rate = 1;
    }

    Quaternion q = new Quaternion();
    q.fromAngles(0, angle, 0);

    j.setLocalRotation(j.getInitialTransform().getRotation().mult(q));
    j2.setLocalScale(j.getInitialTransform().getScale().mult(new Vector3f(1 + angle, 1 + angle, 1 + angle)));
}
 
Example 2
Source File: PMDPhysicsWorld.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void convPMDEuler(Matrix3f out, float x, float y, float z) {
//        Matrix3f m = new Matrix3f();
//        m.loadIdentity();
//
//        out.fromAngleAxis(y, new Vector3f(0, 1, 0));
//        m.fromAngleAxis(z, new Vector3f(0, 0, 1));
//        out.multLocal(m);
//        m.loadIdentity();
//        m.fromAngleAxis(x, new Vector3f(1, 0, 0));
//        out.multLocal(m);

        Quaternion qx = new Quaternion();
        Quaternion qy = new Quaternion();
        Quaternion qz = new Quaternion();

        qx.fromAngles(x, 0, 0);
        qy.fromAngles(0, y, 0);
        qz.fromAngles(0, 0, z);

        qy.multLocal(qz);
        qy.multLocal(qx);

        qy.toRotationMatrix(out);
    }
 
Example 3
Source File: TestOgreComplexAnim.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void simpleUpdate(float tpf){
    Bone b = control.getSkeleton().getBone("spinehigh");
    Bone b2 = control.getSkeleton().getBone("uparm.left");
    
    angle += tpf * rate;        
    if (angle > FastMath.HALF_PI / 2f){
        angle = FastMath.HALF_PI / 2f;
        rate = -1;
    }else if (angle < -FastMath.HALF_PI / 2f){
        angle = -FastMath.HALF_PI / 2f;
        rate = 1;
    }

    Quaternion q = new Quaternion();
    q.fromAngles(0, angle, 0);

    b.setUserControl(true);
    b.setUserTransforms(Vector3f.ZERO, q, Vector3f.UNIT_XYZ);
    
    b2.setUserControl(true);
    b2.setUserTransforms(Vector3f.ZERO, Quaternion.IDENTITY, new Vector3f(1+angle,1+ angle, 1+angle));
  
  
}
 
Example 4
Source File: TestRenderToMemory.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf){
    Quaternion q = new Quaternion();
    angle += tpf;
    angle %= FastMath.TWO_PI;
    q.fromAngles(angle, 0, angle);

    offBox.setLocalRotation(q);
    offBox.updateLogicalState(tpf);
    offBox.updateGeometricState();
}
 
Example 5
Source File: TestRenderToTexture.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf){
    Quaternion q = new Quaternion();
    
    if (offView.isEnabled()) {
        angle += tpf;
        angle %= FastMath.TWO_PI;
        q.fromAngles(angle, 0, angle);
        
        offBox.setLocalRotation(q);
        offBox.updateLogicalState(tpf);
        offBox.updateGeometricState();
    }
}
 
Example 6
Source File: TestRenderToCubemap.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf){
    Quaternion q = new Quaternion();
 
    angle += tpf;
    angle %= FastMath.TWO_PI;
    q.fromAngles(angle, 0, angle);

    offBox.setLocalRotation(q);
    offBox.updateLogicalState(tpf);
    offBox.updateGeometricState();
}
 
Example 7
Source File: FbxAnimCurveNode.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Converts the euler angles from {@link #getVector3Value(long)} to
 * a quaternion rotation.
 * @param time Time at which to get the euler angles.
 * @return The rotation at time
 */
public Quaternion getQuaternionValue(long time) {
    Vector3f eulerAngles = getVector3Value(time);
    System.out.println("\tT: " + time + ". Rotation: " + 
                            eulerAngles.x + ", " + 
                            eulerAngles.y + ", " + eulerAngles.z);
    Quaternion q = new Quaternion();
    q.fromAngles(eulerAngles.x * FastMath.DEG_TO_RAD, 
                 eulerAngles.y * FastMath.DEG_TO_RAD, 
                 eulerAngles.z * FastMath.DEG_TO_RAD);
    return q;
}
 
Example 8
Source File: PMDPhysicsWorld.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void _convPMDEuler(Matrix3f out, float x, float y, float z) {
    Quaternion qx = new Quaternion();
    Quaternion qy = new Quaternion();
    Quaternion qz = new Quaternion();

    qx.fromAngles(x, 0, 0);
    qy.fromAngles(0, y, 0);
    qz.fromAngles(0, 0, z);

    qz.multLocal(qy);
    qz.multLocal(qx);

    qz.toRotationMatrix(out);
}
 
Example 9
Source File: TestRenderToMemory.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf){
    Quaternion q = new Quaternion();
    angle += tpf;
    angle %= FastMath.TWO_PI;
    q.fromAngles(angle, 0, angle);

    offBox.setLocalRotation(q);
    offBox.updateLogicalState(tpf);
    offBox.updateGeometricState();
}
 
Example 10
Source File: TestRenderToTexture.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf){
    Quaternion q = new Quaternion();
    
    if (offView.isEnabled()) {
        angle += tpf;
        angle %= FastMath.TWO_PI;
        q.fromAngles(angle, 0, angle);
        
        offBox.setLocalRotation(q);
        offBox.updateLogicalState(tpf);
        offBox.updateGeometricState();
    }
}