Roll model when turning - SOLVED

Member
Posts: 65
Joined: 2009.03
Post: #1
Hi all

I'm trying to work out something which I'm thinking should be reasonably easy, but it's stumping me.

I have a ship that has a position to which a direction vector is added. The direction vector is calculated using a steering algorithm.

I've got the ship pointing in the direction of travel, but I'd like to rotate the model around the z axis as though it were banking as it turns left and right, like a plane.

I've tried a number of things like calculating the dot product between the ships position and the direction vector, but nothing is working for me.

Has anyone done this before or got any pointers.

Thanks

MikeD

iPhone Game Development Blog - 71Squared
Quote this message in a reply
Member
Posts: 65
Joined: 2009.03
Post: #2
I've found a solution which is working for me at the moment. If anyone has a better way though I'd love to hear from you Smile
Code:
SSVector3D c = SSVector3DCross(direction, oldsf);
float angle = atan2(SSVector3DLength(c), SSVector3DDot(direction,oldDirection)) * 3000;
angle = SSVector3DDot(c, SSVector3DMake(0, 1, 0)) < 0.0f ? -angle : angle;
glRotatef(angle, 0, 0, 1);

MikeD

iPhone Game Development Blog - 71Squared
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Get model to face direction of movement - SOLVED MikeD 3 2,702 Sep 6, 2010 12:37 PM
Last Post: MikeD
  removeFromSuperview not calling dealloc of view - SOLVED BeyondCloister 5 13,259 Aug 11, 2010 01:18 PM
Last Post: BeyondCloister
  Turning off the screen? imikedaman 0 1,644 Jun 10, 2009 10:01 AM
Last Post: imikedaman