"Camera" Help

Started by
0 comments, last by YodaTheCoder 22 years, 6 months ago
Okay, its just working... I''ve got a floor.. I''ve got functions that move forward, move back (those seem to work), but the rotate doesnt correspond to the movements!!!! I know how the whole Rotatef and Translated work; You set up your axis, and if you move your figure (in my case, my floor (which is a polygon)) it will rotate or translate according to its respective axis.. How do I override that? I want where ever I stand (its First Person) to be the center of the x-y-z axis. Is that possible? If not, how do I make it so i can move around my little polygon? The only way that seems logical is to make wherever I stand the point of origon for everything.. Any of that maake sense? I hope so.. ~Jesse PS does it involve gluLookAt?
Advertisement
You want to translate according to the negative player.x, player.y, and player.z, and you want to rotate according to -player.rotation. You just need to do your rotations and translations in the right order. Rotate and then translate before drawing your scene.

You can use gluLookAt to achieve the same effects.

Also, if you want the player to move foward relative to his rotation, you need to use some simple trig. In case you didn''t already know, that''s the following:

x += sin(angle) * speed;
y += cos(angle) * speed;

(you may need to switch the sine and cosine depending on how your coordinates are set up)

Also, remember that glRotate takes angles in degree measure, while sine and cosine take angles in radian measure, so you''ll need to convert between the two. Remember the following:

1 degree = PI/180 radians

A trick to compute PI quickly, easily, and painlessly, is the following:

PI = atan(1) * 4


That should be all you need to know, unless you want to use gluLookAt, in which case I can''t help you since I''ve never even looked at the prototype for that function. I''ve just overheard what it''s supposed to do!

This topic is closed to new replies.

Advertisement