Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


3rd-person Camera in OpenGL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 atcdevil   Members   -  Reputation: 145

Like
Likes
Like

Posted 27 August 2001 - 03:13 PM

I am trying to implement a 3rd-person camera. I figured out the position of an object that acts as a camera to another object using polar coordinates. Now from a view just looking down the z axis at 0,0,0 if I draw both the object being followed and the object representing the camera it appears that the camera is at the right position and angle to be a camera for the other object. So I'm pretty sure that calculating the position of everything isn't the problem So I have these variables: For the object I want to be looking at: xpos, zpos, yrot. For the camera: camerax, cameraz and cameradist. I'm pretty sure the y-axis rotation should be the same for each. So let's say I want to use these to make a 3rd person camera. I thought this would work (it didn't): //already cleared the buffers and loaded an identity matrix //Draw the main object, directly in front of the camera glTranslatef(0.0f, 0.0f, -cameradist); DrawModel(); //Draw the scenery glLoadIdentity(); glTranslatef(-camerax, 0.0f, -cameraz); glRotatef(yrot, 0.0f, 1.0f, 0.0f); DrawScenery(); Please let me know if you know the right way to display everything! Edited by - atcdevil on August 27, 2001 10:18:56 PM

Sponsor:

#2 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 27 August 2001 - 07:53 PM

personally i find its easier/intutitive to use the gluLookAt(..) function

#3 -TheDragon   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 August 2001 - 12:00 AM

glLookAt() sounds good.

-Phil Crosby
www.philisoft.com
www.graphics-design.com

#4 atcdevil   Members   -  Reputation: 145

Like
Likes
Like

Posted 28 August 2001 - 03:07 AM

Thanks for the advice. The problem is that, I do not fully understand how to use gluLookAt. I know this much: gluLookAt(camerax, 0.0f, cameraz, ?, 0.0f, ?, 0.0f, 1.0f, 0.0f); What would I put in those two ?''s.

#5 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 28 August 2001 - 09:54 AM

the first 3 are the x,y,z coordinates of the camera
the second 3 are the x,y,z coordinates of the place/object you want the camera to look at
the third 3 define the up direction usually (0,1,0)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS