Jump to content
  • Advertisement
Sign in to follow this  
NickyP101

World Movement

This topic is 4824 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

Having an issue trying to use trig to calculate the x and z values when walking through my 3D world. Im trying to move the player in the direction they are looking. First problem im hving is i dont quiet understand the rotation system in OpenGL, i mean i thought if i stood in one point and rotated around the y axis until i returned to wat i was originally looked at it would be 360deg rotation, instead it appears to be numnerous revolutions? Any input here? To find the x and z co-ords im using this: cX += Math.sin(yRot) * 1; cZ += Math.cos(yRot) * 1; So im sure most of you can see this is horribly wrong. The result im getting is horrible lol. I would draw an image of my thinking but i dont think that will be needed, last time i neeed some help the replies i got were stunning, but if you would like me to post an image just ask :) Any help would be greatly appreciated, Cheers, Nick

Share this post


Link to post
Share on other sites
Advertisement
The problem is you are using degrees, sin cos and OpenGL all use radians.

180 degrees = 3.14159 radians.

Share this post


Link to post
Share on other sites
Grain's right about sin() and cos(), but OpenGL actually uses degrees. So you can send your angles as-is to glRotate(), but you'll need to convert them to radians before calling c++ trig functions.

Share this post


Link to post
Share on other sites
Thank you soo much lol that was my problem, i assumed OpenGL used radians also, but your correct it uses deg. Thanks for your help,

Cheers, Nick

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!