Jump to content

View more

Image of the Day

New ninja for my game.
#screenshotsaturday #gamedev #indiedev #IndieDevHour
https://t.co/sJdnPuiVgh
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

Orientation

2: Adsense

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.


  • You cannot reply to this topic
2 replies to this topic

#1 HappyRocky   Members   

100
Like
0Likes
Like

Posted 16 May 2011 - 11:51 AM

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

#2 Texus   Members   

248
Like
0Likes
Like

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

#3 haegarr   Members   

7345
Like
1Likes
Like

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.