Game Development Community

Fluid rotation of object through script

by Tom Lenz · in Torque Game Engine · 01/14/2009 (8:02 pm) · 0 replies

After looking through the forums for a while, I'm still in need of some direction when it comes to rotating objects.

I am working on a game where the player needs to inspect objects by holding them and rotating them. For example pretend to hold a rubik's cube and you need to examine the cube so that you can solve it. You will need to rotate the cube across all three axis, back and forth until you know the cube well. The player needs to be able to fluidly move the object in any direction they please with the controls bound to keys. I have been able to get the object rotating around a single axis but with the current method as soon as I try to rotate on a second axis the rotation of the first snaps back to the original rotation. I can't for example rotate the object 90 degrees on the x axis and then from that position rotate the object 90 degrees on the z axis. I need to be able to do all three.

Now how do I go about doing this in TGE.

I read about rotation matrix multiplication, degrees and radians, gimbal lock, xRotation yRotation zRotation theta, and quaternions. Now my math skills aren't the best ( strong skills but I would need a crash course for calculus ) but I do have a small background in 3D graphics ( HLSL ). The question is what do I need to use? From my research it seems as though the best way is to use quaternions but how would I implement this into the code?

Thanks in advance.

If any more clarification is needed let me know, I can create a video about what I need if that would help.