Jump to content

PlayerActor setWorldTransform() issue


photo

Recommended Posts

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 to save+load a point.

Thanks in advance, Javier

player_actor.7z

Link to comment

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

Link to comment
×
×
  • Create New...