void CCamera::RotateX(float fArg)
{
// set rotation matrix
m_mRotationMatrix.SetXRotationMatrix(fArgument);
// rotate camera vectors
m_vViewVector = (m_mRotationMatrix * m_vViewVector).Normalize();
m_vUpVector = (m_mRotationMatrix * m_vUpVector).Normalize();
// set camera to origin
m_vPosition.SetAll(0.0f, 0.0f, 0.0f);
// compute direction vector from Null position to view vector
Vector3f vDirection = m_vViewVector - m_vPosition;
// translate cameraposition in direction-vector direction
m_vPosition = m_vPosition + (vDirection * -vDistance.Magnitude());
}
When i start the programm and want to y-rotate it works. then i close the program and restart. Now rotating x axis works fine too. Same procedure with z axis. But if mix rotations it dosnt work fine.
Does anyone has an idea how to fix this problem ?
greetings,
xiaowei
OpenGL gluLookAt camera
Hello, i have a problem with gluLookAt.
I have camera class and so far it works. i can move forward backwards left right and rotate in x and y direction.
But I dont know, how to rotate around a certain point. LEt's Say I want to rotate around point 0,0,0. My camera's position is at 0,0,10.
I tried to solve this problem but i still have problems. They occure when i rotate around y then around z. X works fine. But Y and Z dont. When I rotate Z after Y,X rotation my Cube rotates a bit left, and then it turns over and rotates right. So it swing left and right. So, i really cant mix rotations.
My Idea was to save the distance (vector) from the point where i want to rotate around and camera position.Then i rotate the camera vectors and then move the camera position to the point where i want to rotate around. Finally i build
a vector from current camera position to rotatet view vector and then move the
camera back along this new normalized vector times the magnitude of the saved distance vector. guys i hope you could follow me. :(
Hello, thanks for your reply.
Well i thought again about my problem. Maybe it is caused because when i rotate around x,y,z together i actually rotate around abitrary axes. So I should compute the rotation axes before a rotation. For example x rotation i compute a rotaion axis that is the vector from camera position to view point.
That could be possilbe as well, right ?
greetings,
xiaowei
Well i thought again about my problem. Maybe it is caused because when i rotate around x,y,z together i actually rotate around abitrary axes. So I should compute the rotation axes before a rotation. For example x rotation i compute a rotaion axis that is the vector from camera position to view point.
That could be possilbe as well, right ?
greetings,
xiaowei
>>Hello, thanks for your reply.
dont thank me, just look up about gimbal lock, theres lots of info on the internet about it + possible solutions
eg
http://www.sjbaker.org/steve/omniv/eulers_are_evil.html
dont thank me, just look up about gimbal lock, theres lots of info on the internet about it + possible solutions
eg
http://www.sjbaker.org/steve/omniv/eulers_are_evil.html
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement