Sign in to follow this  
Wizumwalt

help w/ arcball rotation control

Recommended Posts

Wizumwalt    161
I'm looking for any possible way that might help me debug an arcball 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; } --- My problem in trying to debug this is that, I can see that each of the matrices are being populated with arcball coordinates, and my code seems to compare exactly with that of the examples in the nehe and other tutorials. 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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this