Game Development Community

Applying rotation on DTS

by Kory Imaginism · in Torque Game Engine Advanced · 05/03/2008 (2:04 pm) · 2 replies

I wondering if anyone know the xyz numbers to do a 180 degree rotation on a DTS.

thanks for your time

#1
05/03/2008 (5:21 pm)
I understand how it works

0 0 1 180

thanks anyways
#2
05/05/2008 (12:22 am)
Torque uses a quaternion notation for roatation. The full transform is:

x y z rx ry rz angle

Where rz ry rz are the unitary components of a vector around which the angle rotation in radians is applied. In other words if you want to rotate 180 degrees in Z you can make:

function rotateZ(%obj, %degrees) {
%xform = %obj.getTransform(); //get all the transform
%pos = getWords(%xform, 0, 2); //get the position
%angle = mDegToRad(%degrees);
%obj.setTransform(%pos SPC "0 0 1" SPC %angle);
}

This will apply an absolute rotation. if you want a relative rotation maybe you can get the current angle from the transform and add the new angle.

Luck!
Guimo