Game Development Community

Rotate and add an offset vector

by David Erenger · in Torque Game Engine · 03/30/2004 (8:27 am) · 1 replies

Hi, How can I rotate a vector in a simple way?

Hi have it like this.

%pos = %vehicle.getTransform();
%offsetvector="5 0 0";

//**** rotate offsetvector with %vehicle rotation****

%finalpos = VectorAdd(%offsetvector,%pos);
%obj.setTransform(%finalpos);


I gues its simple but I just cant find out how to rotate the vector.
thanks for any help

#1
04/02/2004 (9:13 am)
Sorry this didn't get answered for a few days.

I have to leave for my day job pretty shortly, so I can't be too thorough here. The quick answer to your question is... there are several ways to do it.

For the most straight-forward method, I'd check out the MatrixCreate, MatrixCreateFromEuler, and MatrixMulVector functions. These functions are very simple. If you follow C/C++ real well, I'd suggest checking out the source for those functions(engine/math/mathTypes.cc). If you don't speak C, just play around with the functions in script. :) Use Ron Yacketta's TGE Console Command Reference for some quick info on the function prototypes.

Also, there are threads discussing rotations and these functions already in the forums, so a forum search will help. Here a few quick links: www.garagegames.com/mg/forums/result.thread.php?qt=7897, www.garagegames.com/mg/forums/result.thread.php?qt=17075, www.garagegames.com/mg/forums/result.thread.php?qt=2200

If this was unsatisfactory, my apologies. I really hate to be so terse and not answer things directly, but I have to get ready to go. If needed, I'll write more when I get home from work.