Moving a model
Up until recently I had a program that moved a triangle, based on its orientation in the right direction (if its pointed to the left up, it moves left up when it''s "engine" is turned on). The function used 4 points to determine the direction in space. Now I decided to use models. But I have a problem, namely that I don''t know how to figure out where the model is pointed. I can actually move it in any direction pretty easily by updating all of its coordinates. But I want to be able to tell which direction the model is facing, and use that to calculate which way to move it. What is the easiest way to do this? Should I just keep the 4 points and update them along with the model? Or is there a more elegant solution? It''s a milkshape model by the way.
Attach a movement vector to the model.
You can''t really figure out witch way the model is facing since it has faces all over the place.
Make the vector point in the direction that you think it''s facing.
You can''t really figure out witch way the model is facing since it has faces all over the place.
Make the vector point in the direction that you think it''s facing.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
I would do it the same way, like lc_overlord mentioned.
Just give your model a direction vector, that points in the direction the model is facing. If you rotate the model, just rotate the vector, too. With simple vector addition you can then move the model in the right direction:
NewPos = Model.Pos + Model.DirectionVector;
Just give your model a direction vector, that points in the direction the model is facing. If you rotate the model, just rotate the vector, too. With simple vector addition you can then move the model in the right direction:
NewPos = Model.Pos + Model.DirectionVector;
You probably need both a "Forward" and an "Up" vector so the model can do *cartwheels*
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement