Jump to content

Using arrows keys to simply rotate an object?


Recommended Posts

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 --


  %txfm = %object.getTransform();  
 echo(" object starting transform=" @ %txfm );  

 // change the rotation based on number keys //  
     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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...