Archived

This topic is now archived and is closed to further replies.

Looking at a certain point?

This topic is 6013 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I don''t know about WoolyUK, but that really helped me out.
thanx,
Farnz

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites