# Rotate Model

This topic is 2592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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?

 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; /////////////////////////////////////////////////////////////////// D3DXMatrixRotationAxis(&mWorld,axis,180); //is true ? D3DXMatrixRotationAxis(&mWorld,up,180); // is true ? //////////////////////////////////////////////////////////////////// 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 ) );

##### Share on other sites
You might wanna use D3DXMatrixLookAtLH

##### Share on other sites
can you please show me how to use it ?
i try to do it myself but model not rotate in a true direction....

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 ) );

##### Share on other sites
[size="4"] is there any way or formula to convert :

[size="5"]axis(x,y,z) & up(x,y,z) vectors to (roll - pitch - yaw) ?

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 on other sites
Don't allocate the vectors with 'new' btw, you pass their address to d3d functions

D3DXVECTOR3 forward(0,0,1);
D3DXVECTOR3 up(0,1,0);

Make sure they're normalized

D3DXMatrixLookAtLH( &mWorld, &D3DXVECTOR3(0,0,0), &forward, &up );

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633269
• Total Posts
3011149
• ### Who's Online (See full list)

There are no registered users currently online

×