World Movement
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
The problem is you are using degrees, sin cos and OpenGL all use radians.
180 degrees = 3.14159 radians.
180 degrees = 3.14159 radians.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement