LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Mr_Ridd on January 19, 2004, 08:04:16

Title: Sprite Rotation
Post by: Mr_Ridd on January 19, 2004, 08:04:16
Howzit

I've got a 3D model that I've imported and it's cool. But now I need to rotate it when I press the relevant arrow key.  

I've written some methods to rotate it using glRotatef but it doesn't work perfectly. I need it to be like like a character in Warcraft III. Those characters turn and face what ever position you click. The only difference with mine is that it's keyboard controlled.

What would be the best way to do this?

Shot
Title: Sprite Rotation
Post by: princec on January 19, 2004, 09:04:23
That is the best way.

Cas :)
Title: Sprite Rotation
Post by: Mr_Ridd on January 19, 2004, 10:17:19
Ok, let me tell you what's happening.

I get the amount that is has to rotate by calling a method I wrote called getNumberOfTicks(). A tick is for example from North to NorthEast, that's one tick. So from East to West it's 4 ticks. Then I get how long it takes to complete 1 tick and I get the total amount that it has to rotate by.

Then I loop until it's finished the total amount. The problem comes in if the model hasn't finished it's rotation.

Say for example the model is facing east and you press *west. It will then start turning around. Then if you press east again and the model has only reached north it will still complete the total amount and end up at south.

How could I fix this?
I tried to only allow the user to press say for example *west again once the rotation is complete but that didn't pan out to well.

Shot