D3DXMESH Editing Vertices

Started by
4 comments, last by ubersheep 16 years, 2 months ago
Hi all, really quick question, don't want to be wasting your time: I'm rendering a .x model using C++ DirectX9, using a D3DXMESH object (well, a LPD3DXMESH object to be exact). I would like to move this mesh, but not the camera (as there are other objects in the scene). What is the correct way to do this, (a) lock the mesh's vertex buffer, increment (x,y,z) of each vertex by the new value, unlock then render again (b) somehow at the render stage offset the object by a certain amount (x,y,z) using a Direct3D function (I don't know how this would work) (c) call a function on the mesh so that DrawSubset() renders the object at a different relative 0,0 location, using a Direct3D function (Again, I don't know how this would work) I'm not sure I know what I'm doing here; all I'm certain is that locking the vertex buffer, incrementing all the values, unlocking then rendering seems to me like a very, very costly way of doing things. Any help appreciated :) Thanks in advance
Advertisement
3D transforms. use a translation.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Quote:Original post by dpadam450
3D transforms. use a translation.


Thanks, I'm actually looking for more of an answer to as why ID3DXMesh itself doesn't encapsulate a translation function, perhaps some typical methods to overcome this, or some kind of explanation as to which tree I should be barking up, regarding translating a ID3DXMESH.
Because an ID3DXMesh just contains mesh data. It doesn't contain data on how to actually render the mesh, which is why it also has no information on materials and the like. You can think of it as a managed bunch of vertices.

DrawSubset() just sends the vertex data to the graphics pipeline to be rendered. It's your responsibility to make sure that the pipeline is in the state that you want it to be before rendering. This includes making calls to SetRenderState() and etc.

To do a fixed-function transformation of your mesh, generate a world matrix and call IDirect3DDevice9::SetTransform() to set the transformation matrix.
NextWar: The Quest for Earth available now for Windows Phone 7.
That's perfect! Thankyou so much, you've been such a great help, Sc4Freak :D

My thinking made the whole thing seem really odd previously, but knowing that makes a lot of things fall into place in my head now.

Thankyou again :D
WOOHOO!! BTW just to let u know it works perfectly :)

Thanks again :)

This topic is closed to new replies.

Advertisement