int PrevX = 0;
int PrevY = 0;
int RotX = 0;
int RotY = 0;
float zoom = 0;
OnMouseMove(int X, int Y)
{
if(isClicked)
{
RotX =+ X-PrevX;
RotY =+ -(Y-PrevY);
}
PrevX = X;
PrevY = Y;
}
OnRender()
{
glTranslatef(0,0,zoom);
glRotatef(RotY,1,0,0);
glRotatef(RotX,0,1,0);
//..Continue Render
)
Simpler ArcBall?
Is it just me, or is NeHe's Lesson 48 on arcballs really unnessicarily complicated? After reading through the tutorials, I made my own implimentation of an ArcBall system with like 10 lines of code!
that might not be exactly the code that I had, because I dont have it right next to me to look at, but it was darn close. I guess the point I am trying to make is that the whole arcball class and stuff didn't seem to do all that much, or at least I dont understand what its purpose is. Can anyone fill me in about this?
You've implemented mouse based model rotation, but it isn't an arcball system. Basically the goal behind a full arcball system is to project the mouse positions into model space so that moving the mouse cause an intuitive rotation, with a grab and move feedback. This is done by generating a shortest arc quaternion between the starting and ending projected mouse coordinates and then applying that quaternion to the current accumulated rotations.
With your system, as rotations accumulate the resulting rotations don't add on to one another cleanly. It's possible to have a situation after a number of transformations that moving the mouse up would cause a sideways rotation, which isn't an intuitive control method. This is basically the gimbal lock problem for using Euler angles for rotations.
With your system, as rotations accumulate the resulting rotations don't add on to one another cleanly. It's possible to have a situation after a number of transformations that moving the mouse up would cause a sideways rotation, which isn't an intuitive control method. This is basically the gimbal lock problem for using Euler angles for rotations.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement