Sprite Rotation

Started by Mr_Ridd, January 19, 2004, 08:04:16

Previous topic - Next topic

Mr_Ridd

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
he ability to succeed is the ability to adapt

princec

That is the best way.

Cas :)

Mr_Ridd

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
he ability to succeed is the ability to adapt