Hi folks,
So i figured i'd explain. It's all about pushing and poping!
If you want to perform a translation or rotation on an object and not effect the whole scene you need to make sure youre on in the right place on the stack. Once you've performed an action such as _gltranslate or _glrotatef the changes you made in position or rotation will continue, that is unless you push and pop the matrices.
As for the way you've implemented it.
gluLookAt : This is old and outdated and (in my opinion) should'nt be used. I find it best to make your own camera controls!
_GLBEGIN : Again, this is a legacy command and really shouldnt be used either. Use the vertex and texture buffer instead.
https://nehe.gamedev.net/tutorial/lessons_01__05/22004/ It's an old reference (uses _GLBEGIN!) but still one of the best.
Just so you have an idea of how third person camera works
IF KB
(0).Q
THEN Cam.Rot.X
= Cam.Rot.X
+ 1 IF Cam.Rot.X
> 360 THEN Cam.Rot.X
= Cam.Rot.X
- 360
IF KB
(0).Z
THEN Cam.Rot.X
= Cam.Rot.X
+ 1 IF Cam.Rot.X
< -360 THEN Cam.Rot.X
= Cam.Rot.X
+ 360
yrotrad = (Cam.Rot.Y / 180 * 3.141592654F)
xrotrad = (Cam.Rot.X / 180 * 3.141592654F)
yrotrad = (Cam.Rot.Y / 180 * 3.141592654F)
xrotrad = (Cam.Rot.X / 180 * 3.141592654F)
yrotrad = (Cam.Rot.Y / 180 * 3.141592654F)
yrotrad = (Cam.Rot.Y / 180 * 3.141592654F)
diffx = Mouse(0).X - Mouse(1).X '// check the difference between the current x and the last x position
diffy = Mouse(0).Y - Mouse(1).Y '// check the difference between the current y and the last y position
Cam.Rot.X = Cam.Rot.X + diffy '// set the Cam.Rot.x to Cam.Rot.x with the addition of the difference in the y position
Cam.Rot.Y = Cam.Rot.Y + diffx '// set the Cam.Rot.x to Cam.Rot.y with the addition of the difference in the x position
'// Thinkthe thing the camera is following gets rendered here....
_glRotatef Cam.Rot.Y
, 0.0, 1.0, 0.0 ' //rotate our camera on the y-axis (up and down) _glTranslated Cam.
Pos.X
, 0.0F, Cam.
Pos.Z
' //translate the screen to the position of our camera
Unseen