View Full Version : turning in first person

06-28-2000, 01:58 PM
I am trying to make a simple 3d engine where a person can walk around in the world...everything is up and runnning except for the turning when hitting the left and right keys. Moving foreward and backward was easy to implement because all I had to do was a simple translation, but when I hit the left or right key I want it to turn in that direction(not strafe). How would I accomplish this? I thought I could use glRotatef but that seems to rotate the world around me and not me instead. Thanks for your help!

06-28-2000, 03:28 PM
Well it does make sense moving the world around you....

Okay...lets say that you are facing a pole or a pillar....and you hit the left-key...that means you are now facing just to the left of the pole right? Meaning the pole is to the right of where it originally was on the screen in relation to you?

All this means is that you have to rotate the geometry in the world in the opposite way that you turn...which can be done by throwing a negative ( - ) sign inside a glRotate() function just before you render each primitive.

I would suggest reading more about YAW,PITCH and ROLL before you get too deep in this...because can be a major part of any 3D engine....its very important

hope all goes well,

06-28-2000, 08:35 PM
I would suggest a camera and then use Sin and Cos to rotate the point around the viewpoint... u should also use sin and cos when U move forward/backwards...

but thats just my approach...
this way U dont have to recalculate all the coordinates of the objects every time U move...


06-29-2000, 02:51 AM
Yeah, sin and cos.....
make sure that its used properly!!

I can't figure out in my head how quake's anglevector() code can be so simple...so i end up having to do matrix work to find out the forward vector....matrix-scale it by my "speed" and matrix-add it to my origin....
oh...this is for going forward and back i mean....

If anyone can explain how quake can do it wish only a couple of multiplications, that'll be sweet

06-29-2000, 09:17 AM
Thanks all...although I figured it out myself now hehe, using the unit circle from algebra 3/4 this year!
I used sin and cos to figure out the translation on x and z axis after rotation. I also added the ability to look up and down.
Thanks all!

06-29-2000, 12:16 PM
hehe, yeah, but soon you'll want to implement the unit sphere * distance http://www.opengl.org/discussion_boards/ubb/wink.gif

The x= and z= require a two variable approach http://www.opengl.org/discussion_boards/ubb/smile.gif. The xangle and the yangle, have fun http://www.opengl.org/discussion_boards/ubb/smile.gif