Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Updated observer transformation being applied to context. Discussed h…
Browse files Browse the repository at this point in the history
…ere: https://hub.jmonkeyengine.org/t/google-cardboard-support/31684/48

 Thanks to Robinn on the jMonkeyEngine forums
  • Loading branch information
neph1 committed Dec 29, 2016
1 parent b684482 commit 7c8b231
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/com/jme3/state/CardboardState.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,29 @@ public void update(float tpf) {
}
// left eye
tempVars.quat1.set(context.getOrientation());
if(observer != null){
tempVars.quat1.multLocal(observer.getLocalRotation());
}


tempVars.quat1.toAngles(tempAngles);
tempAngles[0] = -tempAngles[0];
tempAngles[2] = -tempAngles[2];
tempVars.quat1.fromAngles(tempAngles);

tempVars.tempMat4.set(context.getLeftEye().getEyeView());
tempVars.tempMat4.toTranslationVector(tempVars.vect1);
// tempVars.tempMat4.toRotationQuat(tempVars.quat1);
if(observer != null){
tempVars.quat1.set(observer.getLocalRotation().multLocal(tempVars.quat1));
tempVars.vect1.set(observer.getWorldTranslation());
}
camLeft.setFrame(tempVars.vect1, tempVars.quat1);

// right eye
tempVars.tempMat4.set(context.getRightEye().getEyeView());
tempVars.tempMat4.toTranslationVector(tempVars.vect1);
// tempVars.tempMat4.toRotationQuat(tempVars.quat1);
if(observer != null){
tempVars.vect1.set(observer.getWorldTranslation());
}
camRight.setFrame(tempVars.vect1, tempVars.quat1);


tempVars.release();
}

Expand Down

0 comments on commit 7c8b231

Please sign in to comment.