View Full Version : How to use gluLookAt() to implement tracking

Hi,my teachers

I want to view a track of 3D objects which includes a set of ordering points,p0,p1,...,pn,where pi(x,y,z,),0<i<n.

when I use gluLookAt() to implement tracking,it's very difficult for me to correct view it along any direction.

How to implement to track a set of ordering points like a tank automatically running in known track without controling,and my viewpoint is always following the tank.

thank you

dorbie

06-21-2002, 02:05 AM

You need to describe what you want to do. "following" a tank is not a clear description. Do you want to float above the tank? Sit inside it looking forward. Look down on the tank etc.

Omaha

06-21-2002, 04:36 AM

Knowing the position of the tank, each frame, call gluLookAt(camera.x, camera.y, camera.z, tank.x, tank.y, tank.z, up.x, up.y, up.z) on the modelview identity matrix. (up.x, up.y, up.z) will probably just be (0, 1, 0) or whatever unit vector is "up" in your coordinate system.

Originally posted by Omaha:

Knowing the position of the tank, each frame, call gluLookAt(camera.x, camera.y, camera.z, tank.x, tank.y, tank.z, up.x, up.y, up.z) on the modelview identity matrix. (up.x, up.y, up.z) will probably just be (0, 1, 0) or whatever unit vector is "up" in your coordinate system.

For example, I draw a big house and design a track (p[0],p[1],...,p[n] inside the house). I want to view part of the house along the track designed inside the house.

When I call gluLookAt(p[i-1].x, p[i-1].y, p[i-1].z, p[i].x, p[i].y, p[i].z, 0, 0, 1), where 0<i<n, I can't change my viewpoint along p[i-1]-p[i] direction, namely I can't correctly view along the track inside the house. What's wrong? Do you know that (up.x, up.y, up.z) can be changed with p[i]?

In addition, I can't correctly set the light. The drawed object like the house always becomes bad when I track the viewpoints.

Thank you

knackered

06-22-2002, 08:47 AM

gluLookAt takes in the position of your camera, the point in space you want to look at from the position, and a vector to tell it which way is 'up' in your coordinate system. You surely can work out if/how this can solve your problem?

Ding,

At each p[i] you also want to know the intended camera position, looking direction and up direction. Once you have that, you can interpolate the camera positions and the view and up directions going from p[i] to p[i+1].

The positions can be linearly interpolated, the vectors should be slerped (spherical interpolation) for better results.

Once you have that working, you can start thinking about spline-curves through the intended camera positions and look-at positions for even smoother camera movement...

Just my .02

Jean-Marc.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.