Looking at a certain point?
Hi there
Is there a simple way to look at at a certain part of the world?
I have a character in my world that I always know the X,Y,Z of, how could I position the camera above the characters head in a 3rd person perspective please??
Thanks loads!
Adam
Hi
Maybe the GluLookAt(x1,y1,z1,x2,y2,z2,x3,y3,z3) Function is the right thing for you. I use it too, and it works fine.
Yout play around with the different Parameters and have fun.
Cu
Visit my page at www.developersworld.de
or email me: jan@developersworld.de
Maybe the GluLookAt(x1,y1,z1,x2,y2,z2,x3,y3,z3) Function is the right thing for you. I use it too, and it works fine.
Yout play around with the different Parameters and have fun.
Cu
Visit my page at www.developersworld.de
or email me: jan@developersworld.de
Hi, thanks for replying
Yeah i''ve tried that command but can''t seem to get it working right! It looks all over the place and no where near where I want to be! lol
Adam
Yeah i''ve tried that command but can''t seem to get it working right! It looks all over the place and no where near where I want to be! lol
Adam
do you want the camera to move in relation to the players movement? If so, I''m working on the same thing. If you just want the camera to look at the player gluLookAt(); should work fine. The first xyz is the cameras location. The second is the direction the camera is point; this is where you would want to put the players position coordinates. The third xyz specifies which way is up. Soory, I couldn''t be more helpful.
good luck,
Farnz
good luck,
Farnz
If you want to have the camera looking in a specific direction positioned say behind the player:
glTranslatef( 0.0f, 0.0f, -fScale );
glRotatef( yRotation * 57.295779f, 0.0f, 1.0f, 0.0f ); // the * 57.295779f converts radians to degrees
glTranslatef( -vPlayerPos.x, -vPlayerPos.y, -vPlayerPos.z );
Now, your camera will be fScale units behind the player and fHeight units off the ground, looking at what the character would be looking at
Final note: You must do this before drawing *anything*. OpenGL does the matrices in reverse. These commands are done last. Use glPushMatrix() & glPopMatrix() to keep your camera matrix clean.
Edit: Forgot that moving behind has to be before the rotate and that the trig stuff is only needed for moving, not looking
Edited by - Wulf_ on June 25, 2001 10:03:05 PM
glTranslatef( 0.0f, 0.0f, -fScale );
glRotatef( yRotation * 57.295779f, 0.0f, 1.0f, 0.0f ); // the * 57.295779f converts radians to degrees
glTranslatef( -vPlayerPos.x, -vPlayerPos.y, -vPlayerPos.z );
Now, your camera will be fScale units behind the player and fHeight units off the ground, looking at what the character would be looking at
Final note: You must do this before drawing *anything*. OpenGL does the matrices in reverse. These commands are done last. Use glPushMatrix() & glPopMatrix() to keep your camera matrix clean.
Edit: Forgot that moving behind has to be before the rotate and that the trig stuff is only needed for moving, not looking
Edited by - Wulf_ on June 25, 2001 10:03:05 PM
Thanks for all the replies!
I still cant get it working right, but I''ve decided its probably cus of the rest of my program - Im confused as to how my world is actually facing all the time. I think I need to start from scratch and organise everything properly this time
Hopefully using your advice above I should get it working then!
Thanks a lot!
Adam
P.S
Are there any demos/source out there for a 3rd person perspective simple engine such as Rune/Tomb raider etc please?
I still cant get it working right, but I''ve decided its probably cus of the rest of my program - Im confused as to how my world is actually facing all the time. I think I need to start from scratch and organise everything properly this time
Hopefully using your advice above I should get it working then!
Thanks a lot!
Adam
P.S
Are there any demos/source out there for a 3rd person perspective simple engine such as Rune/Tomb raider etc please?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement