Using arrows keys to simply rotate an object?

Scripting questions, discussions, etc
2 posts Page 1 of 1
whyasky
Posts: 4
Joined: Wed Aug 26, 2015 4:26 am
  by whyasky » Sun Sep 20, 2015 3:44 am
I've been experimenting with rotating an object in T3D.

At first, I setup the camera to orbit around the object.
But that didn't have the desired affect.

Instead, I'd like to rotate the object itself -
Leaving the camera in a fixed position.

So, far I've only been able to get it to rotate on the Z axis ... not X or Y.

Not sure if I'm trying the wrong approach or what --

Code: Select all

%txfm = %object.getTransform(); echo(" object starting transform=" @ %txfm ); // change the rotation based on number keys // switch$(%direction) { case "LEFT": %rotMod = "0 0 0.1"; case "RIGHT": %rotMod = "0 0 -0.1"; case "DOWN": %rotMod = "0 1 0"; case "UP": %rotMod = "0 -1 0"; } // create rotation matrix from radian angles %rotTrans = MatrixCreateFromEuler(%rotMod); // multiply against objects original transform %newTransform = MatrixMultiply(%txfm, %rotTrans); // set the transform %object.setTransform( %newTransform );
This seems to rotate it correctly on the horizontal axis (Z?)
But not the other axis's (guessing it X and Y not rotating)

Is this the correct approach -- Using a matrix multiply ?

Any ideas or examples of how to get it rotating in all directions?
in other words ... +/- X or Y or Z ... based on input.

I get the key mapping, etc ... just need a working example of the matrix math to use.
cybore
Posts: 29
Joined: Fri Feb 13, 2015 10:18 am
by cybore » Sun Sep 20, 2015 8:07 am
This might help you figure out what your after.

Torque3D Script Rotations Explained and Converted
2 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests