Jump to content
  • Advertisement
Sign in to follow this  
Entity Gaming

Third Person Camera

This topic is 3793 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

Hello everyone! I have been using NeHe's cell shading example and I've made it rotate and move by pressing the respective keys (WASD) but I was wondering what I'd have to do to achieve a third person camera to go along with it. I am not asking someone to do it for me, I would just like a good old shove in the right direction if you will. I was wondering, would I be able to combine the first person movement from tutorial 10 and then edit it to make it third person? And how would I go about doing such a task? I appreciate your time and hope you can get back to me ASAP. -Entity Gaming

Share this post


Link to post
Share on other sites
Advertisement
easiest way to set a camera is gluLookAt function from glu.h header

void gluLookAt( GLdouble eyeX,
GLdouble eyeY,
GLdouble eyeZ,
GLdouble centerX,
GLdouble centerY,
GLdouble centerZ,
GLdouble upX,
GLdouble upY,
GLdouble upZ )

in most cases, up vector will be 0.0 1.0 0.0 (no tilt or upside-down camera), center vector (lookat vector) will be your character's position.

the only thing you would need to calculate yourself is eye vector (camera position), which requires simple trigonometry (sin and cos) to place the camera behind the character.

Share this post


Link to post
Share on other sites
Aye, I've heard about gluLookAt(). Thanks for your contribution. Where in the cell shading example would I place this? I know I'm souding very nooby and I sincerely apologise but we all have to learn somewhere.

Even if you can't help me out thank you for your efforts and constribution, I apopreciate them dearly :)

-Entity Gaming

Share this post


Link to post
Share on other sites
I suggest to put gluLookAt in draw(), just after glLoadIdentity() call.

easiest way to store the position of camera would be using spherical coordinates
http://en.wikipedia.org/wiki/Polar_coordinates -> scroll to Spherical Coordinates and you have equations for x,y,z having 2 angles

Share this post


Link to post
Share on other sites
Quote:
Original post by i_luv_cplusplus
I suggest to put gluLookAt in draw(), just after glLoadIdentity() call.

easiest way to store the position of camera would be using spherical coordinates
http://en.wikipedia.org/wiki/Polar_coordinates -> scroll to Spherical Coordinates and you have equations for x,y,z having 2 angles


Hehe I managed to do that part before reading your post! Hehe I'm proud lol.

Anyway, all I have to do now is to transform the camera according to the model's angle and then I'm all set.

I really do appreciate your generosity mate, I ain't just saying that. You're making my life a lot easy! I'll see if I can do the transformation but any hints are greatly welcomed!

Cheers once again
-Entity Gaming

Share this post


Link to post
Share on other sites
I'm pretty shitty when it comes to these things, luckily this forum part (NeHe) isn't frequently visited so no one yells at me yet. :)

funny thing is I'm coding my camera as well, and it is working for me :)

Share this post


Link to post
Share on other sites
Quote:
Original post by i_luv_cplusplus
I'm pretty shitty when it comes to these things, luckily this forum part (NeHe) isn't frequently visited so no one yells at me yet. :)

funny thing is I'm coding my camera as well, and it is working for me :)


Haha I see! Do you have MSN? Maybe you could help me out there? My MSN address is: very_shaggadelic@hotmail.co.uk. I would be so so greatful if you could help me sort out this little "kink" then I shall be able to progress hopefully!

Thanks mate
-Entity Gaming

Share this post


Link to post
Share on other sites
I dont have permission to edit your posts here, but perhaps it'd be a good idea to remove your MSN account if you 2 found each other [wink].

And yeh gluLookAt is a good choice to set up an easy camera, later you might look into quaternions, but I guess thats a bit too much math for now...

Share this post


Link to post
Share on other sites
Quote:
Original post by Caste
And yeh gluLookAt is a good choice to set up an easy camera, later you might look into quaternions, but I guess thats a bit too much math for now...


Just wanted to drop in to clarify: although the above is very good advice, it's actually somewhat misleading since using quaternions to represent your camera-orientation does in no way conflict with also using gluLookAt. In fact, I'm using both right now. They don't have anything to do with each other: with quaternions you calculate, with gluLookAt you tell the API about your perspective of the world... ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!