www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: dutch_delight on April 04, 2012, 11:26:44 pm

Title: getting and re-applying object rotation
Post by: dutch_delight on April 04, 2012, 11:26:44 pm
Hi all,

I'm struggling with saving my game state. basically when the player quits my game, I want to save the health, position and rotation of the player.
Everything works fine apart from the rotation part.

To rotate my player in the world, I use either a joystick or screen tilt input and apply it like this:
Code: [Select]
player.rotateY(rotation_value);
I thought that I could just take the value like this:
Code: [Select]
save_rotation_data_Y = player.getRotationMatrix().getYAxis().x
then when the game restarts, all objects are re-initialized (player rotation is back to default)
and then I reload the rotation data and apply it like this:
Code: [Select]
player.rotateY(save_rotation_data_Y);
But the rotation is not what it should be. The data saves and loads correctly (fuel, missiles, translation all are fine) but I dont think I'm looking in the right place for the rotation.
I've tried every axis and even tried saving out the rotation matrix but I know even less about that so I must be doing it wrong.


Any help would be very much appreciated.



Title: Re: getting and re-applying object rotation
Post by: EgonOlsen on April 04, 2012, 11:46:05 pm
Just save and restore the rotation matrix instead.