Advertisement

transformation with view vector

Started by September 03, 2002 08:53 PM
0 comments, last by crossbow 22 years, 5 months ago
Why does this not work(ie not make the object go in the right direction)

	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!

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