PDA

View Full Version : Camera Chase mode



fcoutel
11-14-2002, 02:56 AM
Hi!

I would like to implement a Camera chase mode. I have the 1st person and 3rd person
examples from gamestutorials.com but I can;t figure out how to do this. Basically I want to draw my object (plane) and wherever I go I want the object to be in my line of sight. Can someone please help me do this?

Thanks!

nexusone
11-14-2002, 04:28 AM
First look up on how to use vector math.

example:

v1 = view point
v2 = object we are following
v3 = camera rotation.

gluLookAt(x1, y1, z1, x2, y2, z2, x3, y3, z3)


We just find v1 based on the position of v2 which is the object we are following.

Also we will have some distance to be keep between v1 and v2, and maybe some lag time during moving...

so v1 = v2 - distance + rotation vector of 180, since we will be looking from behind the object at all times.



Originally posted by fcoutel:
Hi!

I would like to implement a Camera chase mode. I have the 1st person and 3rd person
examples from gamestutorials.com but I can;t figure out how to do this. Basically I want to draw my object (plane) and wherever I go I want the object to be in my line of sight. Can someone please help me do this?

Thanks!



[This message has been edited by nexusone (edited 11-14-2002).]

fcoutel
11-14-2002, 04:31 AM
OK but how to I compute v1 from v2?, could you please give me an example?

nexusone
11-14-2002, 05:41 AM
Let's say the object we are following is moving North which we define as 0 degree direction.

Our view will follow at 180 degree behind it, at 5 units distance.

distance = 5;
angle = 0 + 180;

X1 = distance * cos( angle ) // note degrees must be converted to radians for the sin/cos function to work.
Z1 = distance * sin( angle )

Y1 & Y2 = // hight of view... 0 floor view, 1 midlevel view, 2 head view... numbers would need to be adjusted to world scale.

More is needed to be added to the code for lag of camera following the object, etc.



Originally posted by fcoutel:
OK but how to I compute v1 from v2?, could you please give me an example?