Game Development Community

Object rotation

by James Tracey · in Torque Game Engine · 10/05/2005 (11:49 am) · 1 replies

How can I rotate all three axis of a Static Shape object?
I tried using:

$shape.setTransform(0 SPC 0 SPC 100 SPC 1 SPC 0 SPC 0 SPC %Pitch *-1 );
$shape.setTransform(0 SPC 0 SPC 100 SPC 0 SPC 1 SPC 0 SPC %Roll *-1 );
$shape.setTransform(0 SPC 0 SPC 100 SPC 0 SPC 0 SPC 1 SPC %Heading );

But all it does is rotate the heading.

Also, is there a way to set the cameras Transform/Rotation via script?

#1
12/13/2005 (7:53 pm)
You should take the time to read up on matrix transforms, this stuff is really usefull. I think your main problem here is that your setting the object transform instread of adding each rotation. Adding transforms is done using the matrixmultiply function. Its is also good to note these are quats and not true matrices in the scripts.

%nullpos = 0 SPC 0 SPC 0;
%a = %nullpos SPC 0 SPC 0 SPC 1 SPC 0;
%b =%nullpos SPC  1 SPC 0 SPC 0 SPC %Pitch *-1;
%c =%nullpos SPC  0 SPC 1 SPC 0 SPC %Roll *-1;
%d =%nullpos SPC  0 SPC 1 SPC %Heading;

%trans = $shape.gettransform();
%r = matrixmultiply(%a, %b);
%r = matrixmultiply(%r, %c);
%r = matrixmultiply(%r, %d);

%r = matrixmultiply(%trans, %r);

$shape.setTransform(%r);

Im not sure exactly how you mean to rotate your object but this should get you started.