Jump to content

Translate and Rotate a Node in the World Coordinates


photo

Recommended Posts

Hi there

 

I'm trying the change the origin and orientation of an object. It worked fine until I decided to include as well the orientation of the node.

 

I started with the following approach:

//
// Didn't work - it could only take one of the two transformations
UNIGINE_MAT4 apMat = nPtr->getWorldTransform();
apMat.setTranslate(UNIGINE_VEC3(ap.getLat(), ap.getLon(), ap.getAlt()));
apMat.setRotateZ(ap.getRotZ());

But as result, my node changed only in the applied rotation.

 

With my second approach, it works... Is this a bug or do I missunderstand the theorie?

UNIGINE_MAT4 apMat = nPtr->getWorldTransform();
apMat.setRotateZ(ap.getRotZ());
apMat.setColumn3(3, UNIGINE_VEC3(ap.getLat(), ap.getLon(), ap.getAlt()));
nPtr->setWorldTransform(apMat);

Kind regards,

Renato

Link to comment

Hi Renato!

 

setRotate, setTranslate functions will reset current matrix data, so you need to do multiply translation matrix by rotation. But you did much better and faster way. :)

Link to comment
×
×
  • Create New...