How to Rotate DTS Models in TorqueX
by Charles Speer · in Torque X 2D · 05/06/2008 (9:02 pm) · 2 replies
I have a sphere model loaded in the game and I have the velocity change with the thumbstick accordingly. However, the sphere does not rotate. I need it to rotate along only 1 axis, but I'm not sure how to achieve this. I've messed with the RotationScale variable in the Rigid component, but it still didn't work right. I've read up on the rotation matrix and how this can help rotate your object, but I don't know how to apply this correctly. Can anyone give any sample code or a simple example of how this can be done? Any help is greatly appreciated.
#2
05/07/2008 (8:08 am)
That looks great! Thanks JT. I'll try it out later today, and hopefully that will work for me.
Torque 3D Owner JohnT
Once you have the objects transform it is pretty easy to manipulate the object in any axis using:
Matrix.CreateRotationX(rad);
Matrix.CreateRotationY(rad);
Matrix.CreateRotationZ(rad);
....
_dtsObj = TorqueObjectDatabase.Instance.FindObject
_dtsRender = _dtsObj.Components.FindComponent
_nodeID = _dtsRender.Shape.FindNode("boneName");
_dtsRender.ShapeInstance.NodeTransforms[_nodeID] = Matrix .Identity * Matrix.CreateRotationZ(MathHelper.PiOver2);
Hopefully someone else can come up with an easier way of accomplishing this since I am still very early in my learning of the TorqueX engine.
John