Game Development Community

Object rotation

by Gennady · in Torque 3D Beginner · 09/25/2011 (11:47 pm) · 3 replies

Can anybody explain me extensively about object rotation?
%xfrm = %shape.getTransform();
%lx = getWord(%xfrm, 0);
%ly = getWord(%xfrm, 1);
%lz = getWord(%xfrm, 2);
%rx = getWord(%xfrm, 3);
%ry = getWord(%xfrm, 4);
%rz = getWord(%xfrm, 5);
%rd = getWord(%xfrm, 6);

As far as I am concerned %rd is an amount of angle to rotate (degrees or radians?). And what about %rx, %ry and %rz? How to rotate clockwise and anticlockwise?
When I tried to rotate objects in the WorldEditor I saw that %rd is an absolute number in degrees from 0 to 90. But in all tutorials all parameters are in radians. And I couldn't notice any system in WorldEditor in changing %rx, %ry and %rz. Perhaps it's because of an uneven surface, or there are other reasons. So I suppose I need a general explanation..)

Big Thanks!

About the author

Specialist of International center for professional training in Rosatom Technical Academy


#1
09/26/2011 (7:30 am)
What kind of shape were you trying to rotate?

%lx, %ly, and %lz are position. If I'm not mistaken, %rx, %ry, and %rz are rotations about those axes. If you were calling "getTransform" on a player shape, then those values wouldn't change. Torque only allows player's %rd values to change (without modifying the engine). Trying calling it on a static shape and see what happens.

%rd being in radians can have a value between 0 and 2PI (the decimal equivalence). As far as this value being absolute, I'm not sure. I haven't taken that close a look at the rotations to be honest. However, it really shouldn't matter since you can reach the same rotation of any negative number with a positive one. Example: 0 radians = -2PI radians. PI radians = -3PI/2 radians.

Radians can get a bit confusing when doing calculations, so I believe there is some handy functions to convert between radians and degrees. You should look into them.

I hope I help a little.
#2
09/27/2011 (2:46 am)
Yes, you've helped, thank you.
So, I'm rotating a Vehicle and there are no restrictions as I saw.

I tried to experiment a little with a radians and noticed this system: %rx, %ry and %rz are the angles in percents of angle (%rd) to rotate around appropriate axis.

Here's my example with a vehicle:
1. I'm fixing (as 1) z-axis, c'est-a-dire %rz=1.
2. Then I'm writing an angle to rotate about this axis in %rd
3. And if I need to rotate another angle around x- or y-axises I'm calculating how much this angle in percents from %rd and writing the percents to %rx or %ry resp.
#3
09/27/2011 (4:45 am)
To the point: clockwise or anticlockwise rotation realizing simply changing plus or minus in %rd.