Recommended Posts

I'm looking for any possible way that might help me debug an arcball rotation control problem. I've compared my code with the nehe tutorial and other java examples, but still can't find what could be wrong.
My problem is that the accumulation of the rotations isn't happening because the model keeps snapping back to the origin each time I click on it, and rather than accumulating the last rotation w/ the current rotation, it just starts over from the origin.
--- in sum ...
...
public Quat4f quat = null;
public Matrix3f lastRot = new Matrix3f();
public Matrix3f thisRot = new Matrix3f();
public Matrix4f transform = new Matrix4f();
...
public void mousePressed(MouseEvent me) {
// Here we set the last static rotation to the last
// dynamic rotation.
arcBall.lastRot.set(arcBall.thisRot);
// Update start vector and prepare for dragging.
arcBall.click(me.getPoint());
}
public void mouseDragged(MouseEvent me) {
// Update end vector and get rotation as a quaternion.
arcBall.drag(me.getPoint(), arcBall.quat);
// Convert quaternion into matrix3f.
arcBall.matrix3fSetRotationFromQuat4f(arcBall.thisRot, arcBall.quat);
// Accumulate last rotation into this one.
arcBall.matrix3fMulMatrix3f(arcBall.thisRot, arcBall.lastRot);
// Set our final transform's rotation from this one.
arcBall.matrix4fSetRotationFromMatrix3f(arcBall.transform, arcBall.thisRot);
glDrawable.display();
return;
}
public void mouseReleased(MouseEvent me) {
// Here we set the last static rotation to the last
// dynamic rotation.
arcBall.lastRot.set(arcBall.thisRot);
return;
}
---
I can see that each of the matrices are being populated with arcball coordinates. I just don't understand why it keeps snapping back.
I've been over this for days and can't figure out what's going on. Anyone have an idea/comments/advice on what I should be looking for, or can try to see why this is happening?