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

The following examples show how to use com.jme3.math.Quaternion#toAngles() . 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: CameraMovementState.java    From Lemur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setRotation( Quaternion rotation ) {
    // Do our best
    float[] angle = rotation.toAngles(null);
    this.pitch = angle[0];
    this.yaw = angle[1];
    updateFacing();
}
 
Example 2
Source File: CameraMovementState.java    From Lemur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setRotation( Quaternion rotation ) {
    // Do our best
    float[] angle = rotation.toAngles(null);
    this.pitch = angle[0];
    this.yaw = angle[1];
    updateFacing();
}
 
Example 3
Source File: ConstraintDefinitionRotLike.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void bake(Transform ownerTransform, Transform targetTransform, float influence) {
    Quaternion ownerRotation = ownerTransform.getRotation();
    ownerAngles = ownerRotation.toAngles(ownerAngles);
    targetAngles = targetTransform.getRotation().toAngles(targetAngles);

    Quaternion startRotation = ownerRotation.clone();
    Quaternion offset = Quaternion.IDENTITY;
    if ((flag & ROTLIKE_OFFSET) != 0) {// we add the original rotation to
                                       // the copied rotation
        offset = startRotation;
    }

    if ((flag & ROTLIKE_X) != 0) {
        ownerAngles[0] = targetAngles[0];
        if ((flag & ROTLIKE_X_INVERT) != 0) {
            ownerAngles[0] = -ownerAngles[0];
        }
    }
    if ((flag & ROTLIKE_Y) != 0) {
        ownerAngles[1] = targetAngles[1];
        if ((flag & ROTLIKE_Y_INVERT) != 0) {
            ownerAngles[1] = -ownerAngles[1];
        }
    }
    if ((flag & ROTLIKE_Z) != 0) {
        ownerAngles[2] = targetAngles[2];
        if ((flag & ROTLIKE_Z_INVERT) != 0) {
            ownerAngles[2] = -ownerAngles[2];
        }
    }
    ownerRotation.fromAngles(ownerAngles).multLocal(offset);

    if (influence < 1.0f) {
        // startLocation.subtractLocal(ownerLocation).normalizeLocal().mult(influence);
        // ownerLocation.addLocal(startLocation);
        // TODO
    }
}