# mesh rotation

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

## Recommended Posts

hello,im writing a 3d rts game in direct3d and,i made a map,that is made of quads,and have put a catapult mesh on the floor,and want to rotate the mesh. But it rotates the map also.I mean i want to rotate 1 object,the mesh,and not rotate the other primitives,if i rotate with D3DXMatrixRotationY it rotates all the objects.How can i solve this,any help will be appreciated.thanks.

##### Share on other sites
You must transform your world matrix before you draw the catapult
Something like this:
mDevice->SetTransform(D3DTS_WORLD, & "Matrix for catapult positon");

m_pMesh->DrawSubset();

The general solution to your problem:

1) Load identity matrix into WorldMatrix;
2) Load object1 position into WorldMatrix;
3) Draw object1.

1) Load identity matrix into WorldMatrix;
2) Load object2 position into WorldMatrix;
3) Draw object2.

1) Load identity matrix into WorldMatrix;
2) Load object3 position into WorldMatrix;
3) Draw object3.

[Edited by - Calin on September 11, 2005 7:42:43 AM]

##### Share on other sites

g_pd3dDevice->BeginScene();

D3DXMatrixIdentity( &matWorld );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
terrain.render();

D3DXMatrixIdentity( &matWorld );
D3DXMatrixRotationY( &matWorld, timeGetTime()/1000.0f);
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
mytiger.render();

g_pd3dDevice->EndScene();

u mean this right? it worked,thanks,u mean i have to transform evey object to world coordinates before i render them?by settransform?even if dont want to transform it,like in the terrain

##### Share on other sites
Hello...

Yes man...this is the correct way of apply different tranformations for each object in the scene. First you set the transformation for object1 and render object1, then you set the object2 transformation and render object2, and so on....do it every frame

Resuming, once you use IDirect3DDevice9->SetTransform(), the tranformation you applied will be active for all objects in future renderings.This is the base for many things in D3D programming like TextureStageStates, RenderStates, and many another things you can set.

cya

##### Share on other sites
Quote:
 u mean this right? it worked,thanks,u mean i have to transform evey object to world coordinates before i render them?by settransform?even if dont want to transform it,like in the terrain

Yes. This way you make shure that your object will not suffer from any previous World Matrix transformation.

Edit: xissburg got there first.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 14
• 10
• 11
• 13
• ### Forum Statistics

• Total Topics
634096
• Total Posts
3015488
×