Game Development Community

Rotation Problem

by Bauer Ren · in Torque Game Engine · 05/25/2006 (8:14 am) · 3 replies

How the object-rotation in torque works?

what i found out:

0 0 1 50 // rotates the shape around the x coord
the same thing
0 1 0 50 // etc
1 0 0 50

but now my question:

if i want to rotate for example an object

50 10 100

how to i transform this to this rotation format. is there a tutorial for this?

thanks for any hint and reply

rene

#1
05/25/2006 (2:09 pm)
If you want to set the rotation of an object you can use setTransform. Simply provide the original position with the modified rotation if you want to rotate the object in place. setTransform takes a transformation value in the format of posX posY posZ rotationX rotationY rotationZ theta.

You can use getTransform to get the current transformation value, and to parse out individual position or rotation values use the getWord function.

So, for example:
Whack code removed

If you wanted to set the rotation to exactly 50 10 100 0 you could simply do:
%tCurrentTransform = %obj.GetTransform(); //get the current transform of the object (includes both position and rotation)
%vPosition = getWords(%tCurrentTransform, 0, 2); //parse out the position vector, the first 3 "words" of the string
%tfinalTransform = vPosition SPC "50 10 100 0"); //concatonate fixed rotation to position
%obj.setTransform(%tfinalTransform); //set the objects transform value to the adjusted transform
#2
05/25/2006 (2:46 pm)
Torque uses Quanternion type for rotation, which is a bit different from standar rotations.

The first 3 of the 4 digits is your rotation. pretty strait forward.

the last digit is basicaly the direction to spin. it's usually 1,0,-1.

it's not just as simple as setting your X Y Z rotations. there's actually some math involved in the process.

Perhaps you can do a search on converting to axis angles to quanternions on google
#3
05/25/2006 (2:56 pm)
Ramen is correct. (this is what I get for posting from work, doh!) Setting the exact desired rotation should be fine but rotating based on the current rotation requires a bit more thought.