# Find the track!

I never programmed with delphi, but I think what Nocturnal ment is: You’ve got a point A (Ax,Ay,Az) and a Point B(Bx,By,Bz). The Vector P (Path) would be:

Px = Bx-Ax
Py = By-Ay
Pz = Bz-Az

no… i dont think so…

i guess B - A is a CrossProduct of them…

but im not sure…

Px = Bx-Ax
Py = By-Ay
Pz = Bz-Az

This is not the operation for the cross product, it’s vector subtraction and it gives you the direction vector (in this case) between A and B.

-Mezz

so… what crossproduct stands for ???

With a CrossProduct you get the perpandecular(normal) Vector to two other vectors. (Works only if the the two vectors point not in the same or opposed direction)

In your case it’s a vector from point A to Point B.

so, in my case, i dont need crossproduct…
right ??

which cases i have to use crossproduct ???
or it is useful??

Yeah, right.

e.g.
If you want to implement the OpenGL-light, you have to calculate the normals for your objects due to have correct lighting-calculation for them (Setting for each vertex a normal with glNormal).

Forgot:
Of course you calculate those normals with the crossproduct.

OK… i understand…
but what normals stands for, EXACTLY ???

coz, im calculating in my program but im not sure the reason… just for the light system ???

A normal is the normal vector to a plane (or other surface). In the plane equation Ax + By + Cz + D = 0, [A,B,C] is the normal vector. Also called the surface normal.

For example, for each point on a sphere, there is one tangent plane to that point, and thus one normal. (Actually, there are two planes and normals, one pointing out of the sphere and one pointing into the sphere, but the inner pointing normal is very rarely used.) In the case of a polygon, the normal remains constant for the entire polygon because the polygon has the same tangent plane for each point.

Surface normals are used by OpenGL to approximate lighting on smooth objects like spheres using flat polygons. Hence GL_FLAT vs GL_SMOOTH. (Bump maps change the surface normal on a per-texel basis.)

However, normals are irrelevant to your original question.

B - A
B - A
B - A

This looks correct.
If I meant cross product I would have written: P = B x A

P.S. I am pretty sure that gluLookAt uses the cross product internally.

[This message has been edited by Nocturnal (edited 08-22-2001).]

Originally posted by Gelero:
[b]OK! i tried… but the camera goes to another direction completely weird…

can you help meeee??!?!?!?![/b]

Make sure your OpenGL code calls glLoadIdentity before using gluLookAt:

gluLookAt(…);

hey guys, du diddnt understand him!
the only thing he want to have is a code for a waypointsystem…
and this what he means speed is the step the make from one frame 2 another, right?

d = sqrt( (Bx-Ax)^2 + (By-Ay)^2 + (Bz-Az)^2 )

Px = Ax + tv (Bx-Ax)/d
Py = Ay + tv (By-Ay)/d
Pz = Az + tv (Bz-Az)/d

i think you can use this code, but dont know exactly…

it would be nice to get the cam rotation too, so that the cam looks 2 the waypoint next…

Originally posted by MofuX:
[b]hey guys, du diddnt understand him!
the only thing he want to have is a code for a waypointsystem…
and this what he means speed is the step the make from one frame 2 another, right?

d = sqrt( (Bx-Ax)^2 + (By-Ay)^2 + (Bz-Az)^2 )

Px = Ax + tv (Bx-Ax)/d
Py = Ay + tv (By-Ay)/d
Pz = Az + tv (Bz-Az)/d

i think you can use this code, but dont know exactly…

it would be nice to get the cam rotation too, so that the cam looks 2 the waypoint next…[/b]

HEY !! where have you been ???
thats exactly what im looking for…
do you married with me ???  by the way, tell me more about cam rotation plz… PS: anyway, thanks to the other guys that help me a lot!!

i cant tell you much becouse i’m looking my self on a waypointsystem like that…
have you got now any code which is running?
plz add me in icq:
94467954

Thats like the code qwert posted near the top of this thread…

If you know where you are heading, i.e. you know the point at which your camera will travel to next, you can use it as one of the parameters in the gluLookAt() function I think.

To avoid snapping your view to the next waypoint you will have to do some interpolating between the current view direction and the new view direction. Perhaps if you have the camera’s forward vector and the vector between the camera and the next waypoint, you can rotate the view a few degrees each frame to make it smoother.

-Mezz