pos.x += View.x * -speed;
pos.y += View.y * -speed;
pos.z += View.z * -speed;
glTranslatef(pos.x,
pos.y,
pos.z);
It''s almost right, just the object goes the opposite direction sometimes and sometimes not. I do my rotation and calculate the view vector with quaternions, and I know the view vector is correct. What''s the correct function to update the position by the View vector and speed?
Thanks!
transformation with view vector
Why does this not work(ie not make the object go in the right direction)
I would do it this way:
ds = v * dt
where v is the velocity, ie 5 units / sec = 5/1000 units/millisec,
dt is the time difference from the last frame to the current in
milliseconds, and ds is the length of the vector between the
new position and the current position.
your view vector has to be normalized.
after calculating ds for the current frame,
you do this:
pos.x += view.x*ds
pos.y += view.y*ds
pos.z += view.z*ds
It is now for sure you can throw away your computer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement