Jump to content
  • Advertisement
Sign in to follow this  
blue-ice2002

mesh rotation

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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]

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!