Sign in to follow this  
NickyP101

World Movement

Recommended Posts

NickyP101    146
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
Grain    500
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
jyk    2094
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
NickyP101    146
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this