Amerio.Stephane Posted June 30, 2023 Posted June 30, 2023 Hi, I'm spawning node in geo terrain (curved and flat), and I just want to make sure I'm doing it correctly. auto converter = ig->getConverter(); Mat4 transform = converter->getZeroBasis(geo); node->setWorldTransform(transform); vec3 up = converter->getZeroUpDirection(geo); quat q = converter->getZeroRotation(geo); node->setWorldRotation(quat(up, yaw) * q); // rotate the yaw of the node. 0 should be face north, 90 should be face east. Not sure here! Can you confirm this is the correct way, that I'm not messing up the quat order? Thanks!
cash-metall Posted June 30, 2023 Posted June 30, 2023 Hello! Yes, you are on the right way, but you got a little lost with the order of applying rotations // input Vec3 geo = Vec3(lat,lon,alt); vec3 euler_ned = vec3(yaw, pitch, roll); vec3 euler_enu = vec3(roll, pitch, yaw); // there are can be different sign. im not shure about direction of rotation CW or CCW // === usual way with flat vec3 world_pos = geodeticToWorld(geo); quat world_rot = quat(composeRotationZYX(euler_enu)); // OR if you have a ned rotation quat world_rot = quat(0.0f, 0.0f, -1.0f, euler_ned.z) * quat(1.0f, 0.0f, 0.0f, euler_ned.y) * quat(0.0f, 1.0f, 0.0f, euler_ned.x); Mat4 final_transform = Mat4(world_rot, world_pos); // ==== with geodetic curved vec3 world_pos = geodeticToWorld(geo); quat world_rot = quat(composeRotationZYX(euler_enu)); quat zero_basis = getZeroRotation(geo); // rotation of local tanget plane for this point Mat4 transform = Mat4(zero_basis * world_rot, world_pos); // compose rotation of ltp with rotation of entity // or just Mat4 transform = getZeroBasis(geo) * Mat4(world_rot.getMat3()); // im not shure about altitude in this case but it should works to... 1
Recommended Posts