• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Orientation

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1HappyRocky  Members

Posted 16 May 2011 - 11:51 AM

how to move the model in direction of rotation thanks. thanks a lot

### #2Texus  Members

Posted 16 May 2011 - 12:12 PM

I found this code in one of my old project, I hope you can do something with it.

float MoveX = float(2*sin((CameraAngle-90)*PI/180));
float MoveZ = float(2*cos((CameraAngle-90)*PI/180));
CameraPosX -= MoveX;
CameraLookAtX -= MoveX;
CameraPosZ += MoveZ;
CameraLookAtZ += MoveZ;


CameraAngle is a number from 0 to 360. This is the number that you have to change when rotating.

TGUI, a C++ GUI for SFML
texus.me

### #3haegarr  Members

Posted 16 May 2011 - 12:44 PM

how to move the model in direction of rotation thanks. thanks a lot

A "direction of rotation" in the sense you're asking for doesn't exist. Instead, you want to rotate a direction vector (the one that defines the movement direction of the unrotated model) and use the result as direction of movement. Scale the rotated vector to consider the speed and elapsed time and add it to the position of the model's frame.

E.g. using the local z axis vector [ 0 0 1 0 ]t as standard movement direction of the model, the matrix vector product
R * [ 0 0 1 0 ]t == Rz
effectively extracts the 3rd column vector from the rotation matrix as rotated direction of movement. Its length is 1. Using s as speed and dt as the elapsed time give you
s * dt * Rz
as motion vector.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.