Jump to content

  • Log In with Google      Sign In   
  • Create Account


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.

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

#1 HappyRocky   Members   -  Reputation: 100

Like
0Likes
Like

Posted 16 May 2011 - 11:51 AM

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

Sponsor:

#2 Texus   Members   -  Reputation: 233

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

TGUI.Net, a GUI for SFML.Net


#3 haegarr   Crossbones+   -  Reputation: 3972

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.



PARTNERS