Jump to content

Convertion between frame of references?


photo

Recommended Posts

Hello,

Is there an easy way to convert between the UNIGINE frame of reference and the CIGI frame of reference for views (especially rotation)?

To be more precise, I have a node inside an entity ("refCamera") which I want to use to reposition the current IG view. I don't want to change the view's player, I just want to know the values I should pass to view->setRotation so the view is pointing in the same direction as refCamera.

I tried this:

// mat is the Mat4 of the transform of my refCamera, which is a child node of the entity
Mat4 mat = node->getTransform();
Vec3 pos = mat.getTranslate();
pos.set(pos.y, pos.x, -pos.z); // transform to CIGI coordinate system
vec3 rot = decomposeRotationZYX(mat3(mat*Mat4(quat(-90,0,0)))); // *quat because the camera is looking into -Z
// rot is not correct if refCamera had a non null roll...

// pos and rot could be later used like this, or written down and send through CIGI
//view->setPosition(pos);
//view->setRotation(rot);

Probably I'm not using the right decompose or I should flip some axis, but after a hour or two scratching my head, I figured you could help me here :)

Thanks!

Link to comment

Hello!

try using method view->copyTransformFromPlayer(player_node);

or

auto convert = ig_manager->getConverter();
//...
auto mat = node->getTransform();
Vec3 pos = convert->ENUtoNED(mat.getTranslate());
vec3 rot convert->rotationToEulerNED(mat.getRotate() * node->isPlayer() ? quat(-90,0,0) : quat::IDENTITY );
//...

 

  • Like 1
Link to comment
×
×
  • Create New...