Advertisement

Moveing around in 3D Space

Started by April 24, 2000 06:38 PM
1 comment, last by DavidGholami 24 years, 7 months ago
HI, I am trying to get user input from the client and move around in 3D space. I thought it would be an easy task by doing something like this case ''f'' : { veiwerPos.z += 1; } break; case ''r'': { veiwerPos.z -=1; } break; case ''g'': { veiwerPos.x += 1; } break; case ''h'' : { veiwerPos.x -= 1; } break; vgvec2 pos(event->mouseDeltaX, event>mouseDeltaY); angleX += pos.x; angleY += pos.y; if(angleY > 45.0f) angleY = 45.0f; if(angleY < -45.0f) angleY = -45.0f; axis = pos.Normalize(); glRotatef(angleX, 0, axis, 0); glRotatef(angleY, axis, 0, 0); glTranslatef(veiwerPos.x, veiwerPos.y, veiwerPos.z ) This does not work correctly for obvius reasons in the code, I need to use glMultMatrixf instead of the glRotatef, and glTranslatef. but i dont know what to put in the glMultMatrix. If any one that knows what I am doing wrong or can help me out please e-mail me or respond to this post Thanks David Gholami
You must learn how to crawl before you can walk
When you use matrices for a position in 3D space, they''re usually a combination of several rotation and translation matrices. Whenever you move in a direction, you multiply by a translation matrix, and whenever you rotate, you multiply by a rotation matrix. (I''m not sure in which order, but that can be done w/ trial & error.)

"The wise make proverbs, and fools repeat them." -- ISAAC D'ISRAELI

lntakitopi@aol.com
http://geocities.com/guanajam/
Advertisement
Could this be part of your problem:

quote: glRotatef(angleX, 0, axis, 0);
glRotatef(angleY, axis, 0, 0);


angleX is rotating on the Y axis, and angle Y is rotating on the X axis.

This topic is closed to new replies.

Advertisement