Create an object's movement vector

Started by
0 comments, last by BionicBytes 15 years, 4 months ago
Hello!I have a 3D object and I want the user to be able to move it. I have a nice thick line (calling it "the movement vector" for now) coming out of the object's center, aligned with the X Axis. While the user presses one of the 'x','y' or 'z' buttons I increase the vector's angle with the appropriate axis, and in 'glDisplayFunc' I call a glRotatef() for each axis. So far so good, I know the vector's angle with each one of the x-y-z axis. And now the question... What must I add to my object's transformation matrix so that it moves "on" that line?
Advertisement
Simple normlaize the this vector and scale it by how much you want to move along this directional movement line. Then add it to your current position vector and you're done.

E.g

vDirVec.norm()
vDirVec.Scale (10)
vPosition.Add (vDirVec)

This topic is closed to new replies.

Advertisement