Sign in to follow this  
chris.sermanni

how to Rotate Model

Recommended Posts

Hi every one ...:)

i want to rotate my 3dmodel in roll-pitch-yaw axis

i have just axis(x,y,z) vector and up(x,y,z) vector

so how to rotate my model by axis(x,y,z) vector + up(x,y,z) vector values?

please lookout my simple code...
[code]
D3DXVECTOR3 * axis=new D3DXVECTOR3;
axis->x = -0.14;
axis->y = -0.99;
axis->z = -0.04;

D3DXVECTOR3 * up=new D3DXVECTOR3;
up->x = -0.99;
up->y = 0.14;
up->z = 0.07;

D3DXMATRIXA16 mWorld;

///////////////////////////////////////////////////////////////////

D3DXMatrixLookAtLH(&mWorld,g_Camera.GetEyePt(),axis,up);

////////////////////////////////////////////////////////////////////

mWorld *= *g_Camera.GetWorldMatrix();

D3DXMATRIXA16 mProj;
mProj = *g_Camera.GetProjMatrix();

D3DXMATRIXA16 mView;
mView = *g_Camera.GetViewMatrix();

D3DXMATRIXA16 mWorldViewProjection;
mWorldViewProjection = mWorld * mView * mProj;

V( g_pEffect9->SetMatrix( g_hmWorldViewProjection, &mWorldViewProjection ) );[/code]

is there any way or formula to convert :[b]
[/b][size="1"][size="2"]axis(x,y,z) & up(x,y,z) vectors to (roll - pitch - yaw) ?[/size]:mellow:[/size][b]
[/b]
also you know we need use "axis" and "up" vector both together to calculate. because in some direction of y we must change place of x value by z ....

Share this post


Link to post
Share on other sites
[quote name='chris.sermanni' timestamp='1318058242' post='4870407']
i have just axis(x,y,z) vector and up(x,y,z) vector
[/quote]

What are you representing with these vectors? What is the purpose/meaning of the axis vector? Are you representing the axis of rotation? Have you packed an Euler triplet into a vector? What is the purpose of the up vector? Are you representing the direction the local up axis should map to in world space?

[quote name='chris.sermanni' timestamp='1318058242' post='4870407']


is there any way or formula to convert :[b]
[/b][size="1"][size="2"]axis(x,y,z) & up(x,y,z) vectors to (roll - pitch - yaw) ?[/size]:mellow:[/size][b]
[/b]
also you know we need use "axis" and "up" vector both together to calculate. because in some direction of y we must change place of x value by z ....

[/quote]
Technically, given a single fixed axis of rotation vector, and a single localup->worldup mapping, it is possible to solve a unique rotation (unless the fixed axis is perpendicular to localup X worldup), but I am guessing you did not intend this, since you are asking "how to rotate my model by axis(x,y,z) vector + up(x,y,z) vector values?"

An axis vector alone does not define a rotation. You need to also specify the amount to rotate about that angle. See http://en.wikipedia.org/wiki/Axis-angle_representation . Alternatively, see other representations of rotation http://en.wikipedia.org/wiki/Rotation_representation_(mathematics) . Perhaps you were looking to generate a LookAt matrix here? ( http://stackoverflow.com/questions/349050/calculating-a-lookat-matrix ).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this