Game Development Community

Rotating woes.

by Tony Lamba · in General Discussion · 05/03/2004 (1:01 pm) · 6 replies

I"ve been using the mission editor for a while now and slowly getting used to it. However if there is one thing that really gets me at this point, it's the whole rotation issue. I"ve used many 3d apps in the past and in all of them even after you rotate an item 90 degrees, if you decided to translate the object, it SHOULD follow the world co-ordinates. In Torque it seems I have to Remember what my last rotation was and then in my head reverse up the co-ordinates as it seems torque sticks to LOCAL co-ordinates. Furthermore, I have having trouble with trying to make say, my current brick slab roated 90 degrees and then rotated 45 degrees on another axis.

I am assuming there is a set-reset option that allows me to align the co-ordinates of an object back onto world co-ordinates? It would solve a lot of problems here. Obivously Troque was designed by a coder not an artist :P

Thanks in advance.

#1
05/03/2004 (3:43 pm)
Torque uses something called quaternion rotation. Instead of 3 numbers for x y and z rotation, there are 4 numbers. The first 3 are a unit vector that define the axis of rotation, the last number is an angle about that axis. Its good for the computer, very bad for humans.

Heres a function that takes a euler rotation (x, y, z rotation in DEGREES) and returns a quaternion (vector + angle in DEGREES)
function eulerToQuat( %euler )
{
	%euler = VectorScale(%euler, $pi / 180);  //convert euler rotations to radians

	%matrix = MatrixCreateFromEuler(%euler); //make a rotation matrix
	%xvec = getWord(%matrix, 3);	//get the parts of the matrix you need
	%yvec = getWord(%matrix, 4);
	%zvec = getWord(%matrix, 5);
	%ang  = getWord(%matrix, 6);	//this is in radians
	%ang = %ang * 180 / $pi;	//convert back to degrees

	%rotationMatrix = %xvec @ " " @ %yvec @ " " @ %zvec @ " " @ %ang;  //put it all together

	return %rotationMatrix;	//send it back
}

There are some consistancy problems between degrees and radians in various parts of the engine. I used this function for the rotation of weapon images, which use degrees (or at least they used to). If you want to use it for rotating static shapes and such, take out the line that says //convert back to degrees.

I'm not sure what you mean by the local coordinates problem.
#2
05/03/2004 (4:24 pm)
I have tried all kinds of tests. Trying to get a rotation 90 deg on z, and then say 45 deg on Y so my object is aligned properly for my level and tilted up. Instead, no matter what, I get slanted objects because it tries to combine rotations.

So, seems if I do a single rotation I am screwed. IF I try a double rotation in one command, it adds them and still screws me in the end with something twisted.

I see no other method but to re-export all my assets in different angle settings just for better alignment. Not sure why a simple ramp aiming up would be so hard just to place!

grrr
#3
05/05/2004 (10:03 am)
"slanted" objects? But isn't that your goal to begin with? Can you give screenshots? Also, have you checked the options to see about moving objects? I'm pretty sure you can move them in worldspace without much hassle.
#4
09/20/2004 (3:10 am)
Just wanted to point out that $pi above, at least on my system (TGE 1.3), is not defined. So you'll have to define it, else you like me, may have a fun "why the hell doesn't this work!" debugging session.
#5
09/24/2004 (2:20 pm)
Well, as for the translation issue, if you hold shift in the mission editor you can translate the object around via world coords rather than local coords. It doesn't work when rotating, though.

-Jase
#6
05/14/2005 (10:44 pm)
For rotation you hold down alt and drag left and right to rotate it in the mission editor.