Pointing objects in a direction

Started by
5 comments, last by Pontius 21 years, 4 months ago
I am making a very primitive flight simulator. I have a set of points that my plane (a teapot for now) flies to on autopilot. I have got the movement down, going from point to point, but what i need is for the teapot to point in the direction of the next point it''s traveling to. In terms of X and Y, I can get it to do this. but I can''t figure it out for Z. Sometimes it works, sometimes it points in the wrong dir. I was wondering if there are any tutorials that demonstrate pointing an object in a certain direction? Let me know, thanks Pontius
Advertisement


[edited by - Hawkeye3 on December 23, 2002 6:20:54 PM]
? That was empty
i dont know the functions since i haven''t begun to learn opengl yet, but for rotation (which you say you have working) you can just find the angle between the two points, or just point it at the second point (like i said, i don''t know the functions so i don''t know what''s easier)

for pitch you would think of it like a right triangle...

/| destination z
/ |
/ |
current z /a__|

then just find the angle of "a" and use that to point the plane...

it would be like....

angle = arctan((destination_z-current_z)/sqrt((destination_x-currentx)^2+(destination_y-currenty)^2))

(psuedo code because, again, i haven''t got into C++ or OpenGL programming much, I just know the concepts and the math.





zRotationAngle = atan2(yTargetLocation - yCurrentLocation, xTargetLocation - xCurrentLocation);
xRotationAngle = atan2(yTargetLocation - yCurrentLocation, zTargetLocation - zCurrentLocation);
yRotationAngle = atan2(zTargetLocation - zCurrentLocation, xTargetLocation - xCurrentLocation);

zRotationAngle /= (3.1415926535897932 / 180);
xRotationAngle /= (3.1415926535897932 / 180);
yRotationAngle /= (3.1415926535897932 / 180);

If I remember right you rotate by the negative of those values... not sure, try it.

------------
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155
"It''s all part of the conspiracy of conspirators conspiring to conspire their own conspiracies..."
_______________________________________Pixelante Game Studios - Fowl Language
quote:Original post by LockePick
"It''s all part of the conspiracy of conspirators conspiring to conspire their own conspiracies..."


Let me guess - Yes, Prime Minister ?

Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
quote:Original post by Crispy


Let me guess - Yes, Prime Minister ?



either that or it's an ARB meeting discussing the high level shading language for GL 2.0 ;¬)



[edited by - mrbastard on December 25, 2002 5:06:12 PM]
[size="1"]

This topic is closed to new replies.

Advertisement