   Object transforms problems
  I am having trouble transforming my objects in world space. Its seemigly simple, but i've tried many thing i found online, and still i cant crack it.Heres the code:I have a created cube, and am trying to transform a position matrix just before rendering it.D3DXMATRIXA16 matWorld;D3DXMatrixTranslation(&matWorld,10.0f,10.0f,50.0f);HR(gd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ));HR(gd3dDevice->SetStreamSource(0, SphereVertexBuffer, 0, sizeof(VertexPos)));HR(gd3dDevice->SetIndices(SphereIndexBuffer));HR(gd3dDevice->SetVertexDeclaration(VertexPos::Decl));HR(gd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,0,0,num_vertices,0,4*meridians*(parallels-1)));The code looks legit to me, so maybe the problem is in some other part of the code, or somehow in the way i set up my world. The world is in right handed coordinate system, i doubt it, buy might this be a problem?Also another question, when i change the world matrix, as i understand it, EVERYTHING drawn after this is moved right? So i may be moving the ground and everything along with my object? But then againt i can use my camera as reference, and still dont see any displacement!Any ideas?ps. I am also using effects(ID3DXEffect*), maybe i need to use its settransform?![Edited by - avion85 on May 25, 2009 5:51:11 PM]
Quote:Original post by avion85Also another question, when i change the world matrix, as i understand it, EVERYTHING drawn after this is moved right? So i may be moving the ground and everything along with my object? Correct:If you're doing:SetTransform(t);DrawStuff();DrawGround(); Stuff and ground will not be displaced relative to each other. You'd want to do:SetTransform(t_for_stuff);DrawStuff();SetTransform(t_for_ground);DrawGround();Also, maybe if you described a little bit more of what you'd expect to happen vs what is actually happening then someone would be more able to help you.Your original question is kind of vague, nothing really jumps out which may be why you haven't received any replies.   ;  Thanks for the reply.Your answer was what i was looking for, so i need to transform everyting separately including the "ground" since i am using it to judge the displacement.In the meantime i came up with a solution using D3DEffects to move my object around, using its setmatrix to move it.Il try to make my next question clearer:Whats is the difference between using:   D3DXMatrixTranslation(&matWorld,10.0f,0.0f,50.0f);   HR(gd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ))  //d3deffect transform   HR(gd3dDevice->DrawIndexedPrimitive(...));and    D3DXMatrixTranslation(&matWorld,10.0f,0.0f,50.0f);   HR(mFX->SetMatrix(mhWVP, &(matWorld*(mView*mProj))));  //general transform   HR(mFX->CommitChanges());   HR(gd3dDevice->DrawIndexedPrimitive(...));So what is the difference between using the d3deffects for transforms and the general settransform?   ;  The general set transform _may_ have some hardware/driver optimization making it more desireable than the effects parameter in general cases. How ever if you plan to have a rich effects parameter pipeline, then adding the model transform to it should not cause you much less performance.By the way i think you may have labeled them backwards in your code sniplet comments.   