PDA

View Full Version : Problem with glutMotionFunc(MotionCallback)



Diego Felix
07-23-2011, 01:55 PM
When I rotate qx (move cursor on the x axis of the window) the camera do not rotate on the z axis of the camera, Dir is the direction of view camera.



glutMouseFunc(MouseCallback);
glutMotionFunc(MotionCallback);
MotionCallback(0, 0);

void Simulation::MouseCallback(int button, int state, int x, int y)
{
mx = x;
my = y;
}

void Simulation::MotionCallback(int x, int y)
{
int dx = mx - x;
int dy = my - y;

Dir.normalize();
N.cross(Dir,NxVec3(0,1,0));

NxQuat qx(NxPiF32 * dx * 20/ 180.0f, NxVec3(0,1,0));
qx.rotate(Dir);
NxQuat qy(NxPiF32 * dy * 20/ 180.0f, N);
qy.rotate(Dir);

mx = x;
my = y;
}

Diego Felix
07-23-2011, 02:01 PM
Video of motionCallback problem of GLUT (http://www.roboime.com.br/svn/RoboCup/Projeto Computacional/Videos/Animation.avi)

Diego Felix
07-23-2011, 03:08 PM
NxQuat is a quaternion class