Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DavidGholami

Moveing around in 3D Space

This topic is 6939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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/

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!