I’m not sure that I’ve understood the question. however if you know the initial position and the speed, why don’t you simply integrate, that is, if your camera is at (x0, y0, z0) at time t0, and the camera’s speed is (vx, vy, vz), then at time t the position (x,y,z) is :
x = x0 + (t - t0)*vx;
y = y0 + (t - t0)*vy;
z = z0 + (t - t0)*vz;
If the speed is not constant, just decompose your motion in elementary short motions, in each of them the speed could be thought as constant.
im sorry about my english…
i ll try to explain better…
i have my initial camera’s position…
for example (0.0, 0.0, 0.0), oK ???
now, i want to go to another position… like ( 10.0, 5.0, 5.0 ), ok ???
and i have only one speed, although i can have 3… the vx, vy, vz.
whatever!
i just want to know to calculate the coordinates of each position, frame by frame while my
camera doesnt reach the final coordinate… (10.0, 5.0, 5.0 )
so, if i have a higher speed, less frame to reach that point… slower speed -> more frames to reach…
Typically in a real-time animation, you get the time from the system itself. Get the current time which has (on PCs) millisecond precision, or use a high performance timer to get microsecond precision.
You can use a high performance timer by using the Windows API. Specifically, QueryPerformanceCounter and QueryPerformanceFrequency. Do a search on MSDN to see how to use those, it’s very easy.
If you get your system’s time when you start moving, store it, then get it in subsequent frames you should be able to calculate the time for the object’s movement path.
There are is no metric system in opengl.
1 could be 1m or 1km. If you consider 1 as 1m, then the speed is your [speed]m/sec.
only “t” was wrong. I meant dt (delta t). The difference in time between current time (with current point) and the time when “current” point was at Point A.
let me explain it again…
my camera is in origin… (0.0, 0.0, 0.0), ok ???
now… my camera wants to go up… 10 points, ok ???
so, the final position is ( 0.0, 10.0, 0.0 ), ok ???
so, imagine a line, connecting these points…
ok… the line is made by other points, right ??? (a large number of them that we ever wonder before!) ok…
now, my camera always look to ( 0.0, 0.0, -10.0 ). so… when my camera gets 10 on Y axis its looks down, am I correct ??? i guess so…
what i want to know is make my camera, using some kind of speed, “walk” through those line’s points until reach the final point ( 0.0, 10.0, 0.0 )…
AND when its get there, stop by!!!
ufffffff…
plz… help me to figure out this damn situation…
[This message has been edited by Gelero (edited 08-21-2001).]
dt = 20; // your choice: how long it takes to move from A to B
initial_time = clock(); // or some other timing function
final_time = initial_time + dt;
Path = B - A; // path, A, and B are vectors/points
while (clock() < final_time)
{
Position = A + (clock()-initial_time)/dt * Path; // Position is another vector
gluLookAt(Position.x, …);
Render(…);
}