javier.serrano Posted January 21, 2019 Posted January 21, 2019 Hi, I have been developing an Spawn Point saving/load system that stores in a XML file the world transformations of a PlayerActor and then sets one of those transformations to the PlayerActor via setWorldPosition(). As the spawn points are relative to a moving object (a ship) I store transformations is ship's local coordinate system. The problem comes when I recompose the world matrix and I set it to PlayerActor. The player rotates 180º in Z axis. ¿Should I work with setWorldPosition()/setWorldDirection() instead? I attach an example (without bin/ folder) with the issue, just press R to save+load a point. Thanks in advance, Javier player_actor.7z
alexander Posted January 22, 2019 Posted January 22, 2019 Hi Javier! There is a bad design. PlayerActor has a difference between the setWorldTransform and getWorldTransform functions. I mean, when you use setWorldTransform() your rotation is: x - right, y - up, z - back (as PlayerDummy, PlayerSpectator etc.). But, when you use getWorldTransform you will get: x - right, y - front, z - up. So, the fix looks like this:Save: Mat4 transform = player_actor.getWorldTransform(); dvec3 front = transform.col13; dvec3 up = transform.col23; transform.col13 = up; transform.col23 = -front; spawn_point = ball.getIWorldTransform() * transform;Load: player_actor.setWorldTransform(ball.getWorldTransform() * spawn_point); Best regards, Alexander
javier.serrano Posted January 22, 2019 Author Posted January 22, 2019 Thanks for your response, problem is completely solved. Regards, Javier
Recommended Posts