Domanda

I'm trying to rotate a node around a custom center point in Ogre3D, but I can't seem to find a way to do this. I've looked into quaternions and matrixes but they don't seem to do what I'm trying to do (but to be honest, I'm not quite sure I completely understand them).

The drawing below illustrates what I want (a 'door' in a wall, as seen from the top). 'o' represents the center point (the hinge), 'x' the door, '=' the wall.

- Original position
- What I get:          What I want:

  == x x o x x ==      == x o x x x ==

- After a 90 degree clockwise rotation:
- What I get:          What I want:

         x
         x                  x  
  ==     o     ==      ==   o       ==
         x                  x
         x                  x
                            x
È stato utile?

Soluzione

If this is about an object that you want to rotate around the same point always (like a door), the easiest way would actually be to change the pivot point of the object.

This can easily be done by your artist in Maya/Max/Blender.

Or you could attach the door to an extra scene node at the desired position. And then rotate that extra scene node. This has the benefit that you could do everything from Ogre.

Altri suggerimenti

The basic technique from point of view of matrix calculus is:

  • move model to the point

  • rotate the model

First you can try to execute Translate(...) , after Rotate(...), one time suceedeed on this, can optimize by using one single matrix, with translation and rotation data, so will execute what you want with a single Transform(...) call

Hope this helps.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top