mesh rotation

Started by
3 comments, last by Calin 18 years, 7 months ago
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.
Advertisement
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]

My project`s facebook page is “DreamLand Page”


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





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
.
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.

My project`s facebook page is “DreamLand Page”

This topic is closed to new replies.

Advertisement