Sign in to follow this  
ubersheep

D3DXMESH Editing Vertices

Recommended Posts

ubersheep    122
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

Share this post


Link to post
Share on other sites
ubersheep    122
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.

Share this post


Link to post
Share on other sites
Sc4Freak    643
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.

Share this post


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this