Shape Rotation
by Tom Cassiotis · in Torque Game Builder · 08/24/2007 (6:43 am) · 3 replies
I'm trying to set the shapeRotation to orient an object properly. The only example I have seen treats this as angles (90 around the x-axis turns the model around) and that seems to work fine for the first value. If you then try and set a second axis the other values change along with it.
My guess is that shapeRotation is actually normalized vector and the level builder is trying to hide that but there is a bug. Is this correct?
If this is the case, can someone give me a link or a quick explanation how to come up with the values. I want to rotate the shape so that it is on an angle (mimicking isometric view) and then rotate it in 8 directions (for movement). If the values were in angles i wouldn't be asking :)
Thanks in advance
My guess is that shapeRotation is actually normalized vector and the level builder is trying to hide that but there is a bug. Is this correct?
If this is the case, can someone give me a link or a quick explanation how to come up with the values. I want to rotate the shape so that it is on an angle (mimicking isometric view) and then rotate it in 8 directions (for movement). If the values were in angles i wouldn't be asking :)
Thanks in advance
About the author
#2
Obviously I need to do a bunch more research/reading before I try and tackle something like this (I do own tge and I'm comfortable with C++ but don't have the 3d knowledge).
I did find a reference in the help which explains what I'm experiencing:
Rotation - sets a rotation value around the axes, but not a moving rotation. Note that because of the complications of 3D math, combining rotations around different axes can cause some unpredictable effects.
08/24/2007 (2:12 pm)
Yes I am talking about 3d objects.Obviously I need to do a bunch more research/reading before I try and tackle something like this (I do own tge and I'm comfortable with C++ but don't have the 3d knowledge).
I did find a reference in the help which explains what I'm experiencing:
Rotation - sets a rotation value around the axes, but not a moving rotation. Note that because of the complications of 3D math, combining rotations around different axes can cause some unpredictable effects.
#3
I never really understood why a Euler Rotation on two axis could not be transformed back and forth from Quaternions. I double checked the transformations (in C++) and they matched the ones I found online.
I solved my specific problem by adding get/setShapeRotation console functions that deals strictly in Quaternions and found the Quat angles for the 8 possible directions that I need to support.
I did this by rotating the shape in one axis (direction) and then used angular rotation on the other axis to accomplish the iso angle (I executed a 'echo(object.getShapeRotationQ());' when it looked right).
So now I have the 8 hard-coded Quat that I can set. Not elegant but it got me where I wanted.
09/04/2007 (12:27 pm)
I thought I would post and let you know what I did.I never really understood why a Euler Rotation on two axis could not be transformed back and forth from Quaternions. I double checked the transformations (in C++) and they matched the ones I found online.
I solved my specific problem by adding get/setShapeRotation console functions that deals strictly in Quaternions and found the Quat angles for the 8 possible directions that I need to support.
I did this by rotating the shape in one axis (direction) and then used angular rotation on the other axis to accomplish the iso angle (I executed a 'echo(object.getShapeRotationQ());' when it looked right).
So now I have the 8 hard-coded Quat that I can set. Not elegant but it got me where I wanted.
Torque Owner John McArthur
What your asking for isnt possible without modifing the source. I dont know the exact lingo but basically the reason you see these garbage rotations is because each axis does not keep track of its rotations - source uses a quaterion to hold x,y,z. So the rotations you apply are relative to whatever direction the model was pointing to last. Thats why anything more then a single axis of rotation makes orientations look off and also why you cant get isometric looking rotations in current form. The programmers probably did this to reduce chance of something called gimbal lock, but the current method is unusable.
You'll probably need to rewrite or modify how rotations get performed/stored. (Do you own TGE, maybe copy source from that into TGB.) You will want functions so you can modify only a single axis of rotation, such as for isometric where the Z axis is always up and your modifying the X axis for direction model faces.
I could go on about skinsets but I think Ive said enough.