Hello All,
I had been working a bit on rotating the camera (node) about a specific node given both roll and tilt (pitch) angles and vectors. Hope this is of help to those who need such a feature
cheers!
CameraNode oCamNode;
//rollAxis is usually cam.up
//tiltAxis is usually cam.up cross cam.dir
public void rotateDelta(float angleRoll, float anglePitch, Vector3f rollAxis, Vector3f tiltAxis) {
Matrix4f axisL2W = new Matrix4f();
oCamNode.getLocalToWorldMatrix(axisL2W);
axisL2W.invertLocal();
axisL2W.rotateVect(rollAxis);
axisL2W.rotateVect(tiltAxis);
Vector3f oldPos = axisL2W.toTranslationVector().negate();
Quaternion qRoll = new Quaternion();
Quaternion qTilt = new Quaternion();
qRoll.fromAngleAxis(angleRoll, rollAxis);
qTilt.fromAngleAxis(anglePitch, tiltAxis);
Quaternion q = qRoll.mult(qTilt);
oCamNode.setLocalTranslation(new Vector3f());
oCamNode.setLocalRotation(oCamNode.getLocalRotation().mult(q));
Quaternion rot = oCamNode.getLocalRotation();
oCamNode.setLocalTranslation(rot.mult(oldPos));
}