Hi!
I have models that are simulated in ecef coordinates. I have successfully set their corresponding ue4 actors position using the georeference MoveToEcef function (I add the georeference component to my aktors). I am, however having trouble setting the rotation. I have a rotation matrix describing the ECEF rotation to body system. Ie I can easily get the forward an up vectors expressed in ecef coordinates.
I can also get the rotation in ENU (but at a computational cost), at some ecef coordinate.
I am using c++.
My current setup is as follows:
GeoRef->MoveToECEF({posEcef.x,posECEF.y,posECEF.a});
FRotator ueRotator = GeoRef->Georeference->TransformRotationEnuToUe(
GetEnuRotator(posEcef),
{posEcef.x, posEcef.y, posEcef.z});
GetOwner<AActor>()->SetActorRotation(ueRotator);
Where my ‘GetENURotator’ is implemented like this:
// east north, down are vectors in ecef frame
glm::dvec3 down = -glm: :normalize(posECEF); // simplified inaccurate
glm::dvec3 east = glm::normalize(glm::cross(down, {0.0,0.0,1.0}));
glm::dvec3 north = glm::normalize(glm::cross(east,down));
glm::dmat3x3 T_ENU_ECEF(east.x, north.x, -down.x, east.y, north.y, -down.y, east.z, north.z, -down.z);
glm::dvec3 forwardENU = T_ENU_ECEF*forwardECEF;
glm::dvec3 upENU = T_ENU_ECEF*upECEF;
return UKismetMathLibrary::MakeRotFromXZ({forwardENU.x, forwardENU.y, forwardENU.z},{upENU.x, upENU.y, upENU.z});
This don’t get absolutely correct however. I guess I somehow will have to form my transform at the GeoRef origin instead of at my entity location?
How do I do this?
Thank you!