Re: trouble with arcball rotation and translation

You know, I did have some limited success through trial and error. It got to the point where I achieved what I was trying to accomplish, but it only half-worked. Let me explain that.

Here is what I did:

First off, I was using 2 translation factors for X and Y, and I was rotating before translating which caused these to be related to the model axis as you say. I realized I needed 3 translation factors if I was going to make it work (obviously). I added a 3rd translation factor for Z.

Second, to do translation I was capturing the keyboard arrow keys, so I needed a way to relate the 2D translation to 3D. So, after collecting the 2D translation from my keyboard procedure, I built a translation matrix using my X and Y translation factors. I eventually discovered, through trial and error, a partial solution; if I was to multiply this new translation matrix by the transpose of my arcball's rotation matrix, the resulting matrix would then contain the proper X, Y, and Z translation factors that could be applied to the model and would cause the model to translate parallel to the screen.

So, now we come to the current problem...how do I make this work more than once? I'll explain. Right now, you can rotate, then you can translate (parallel to the screen), then you can rotate again, but when you try to translate a second time the model jumps back to where it was after the first rotation and translates from there. The model also jumps back to being a constant distance from "the camera".

It seems like I'm so close to my solution, I can almost taste it...but I'm not there yet. This is one of those times where I need some guru to have a hearty laugh at my expense, and chime in with something like, "Hey, you're doing this all wrong. Try reading up on mathematical concepts A, B, and C. When you know how to use them, apply them to your problem in the following way..."

Who knows. I'll post back if I figure out more.

Have a great day!

-langecrew-

Re: trouble with arcball rotation and translation

Thanks to your input above, I managed to figure it out.

Once you have performed your second rotation, you need to recalculate the screen translation vector to avoid the jump.

To do this :

1. get the rotation matrix R

2. transpose (or invert it) to get Rt

3. get the new screen translation vector by rotating the object's translation vector : Trans_Screen = Rt x gl_Trans_Vector

4. forget about the screen z translation : Trans_screen.z = 0

Cheers

andre