Archived

This topic is now archived and is closed to further replies.

Programinator

Getting a vertex list from VertexBuffer

Recommended Posts

I need to get triangle strip or vertex list type of information out of my IDirect3DVertexBuffer8. How do I do this? I''m new to DirectX. I searched the SDK, and I see the function GetPrivateData.. How do I use this to get the vertex list out of the buffer into say.. an array of vertex structures.. HRESULT GetPrivateData( REFGUID refguid, void* pData, DWORD* pSizeOfData ); To be honest, I don''t quite even understand what the refguid parameter is.. Is this even the correct approach? Thanks in advance for the help.

Share this post


Link to post
Share on other sites
GetPrivateData is the counterpart of SetPrivateData. With these functions you can associate your own, non dx data with the buffer. The refguid is an unique ID (usually generated with GUID-Gen) to identify the data.

To get the vertices out of a vb call Lock() and use the returned pointer to access the vertices - don't forget to call Unlock() If you just want to render a strip use an index buffer - you know how your vertices form the strip, dx does not. See DX8->DirectX Graphics->Using DX Graphics->Vertex Buffer (and Index Buffer)

Bjørn.

Appendum: ID3DXMesh has various get functions (e.g. GetVertexBuffer())). You are even able to lock the used buffer to modify the data within the mesh.

Edited by - Boki on August 1, 2001 6:17:32 AM

Share this post


Link to post
Share on other sites
Hey thanks a lot!

What I''m trying to do is use the vertices in order to draw a lined wirefram on top of the 3d shape. My next question is, now that I have a pointer to the vertices, what format is the data in that pointer? I tried the GetDesc function on the vertex buffer and it gave me an unhandled exception?

Here''s the whole story if it helps. I have an x file I loaded into a mesh. I want to render that, then use the vertices to draw a wireframe on top of what I''ve rendered, as I said above. So I got the vertex list out of the mesh, and now I have a pointer to it. How do I know how to access the data inside properly? Sorry this is such a newbie question. I''ve been trying to figure this out by the SDK and my books, honestly.. but I can''t get it.

Does the fact that I get an exception from GetDesc on the vertex buffer mean that there is no vertex buffer? I just assumed I could get one out of a mesh.. but I don''t know if every mesh necissarily has one.. Man.

Thanks in advance.

Share this post


Link to post
Share on other sites
I believe that a quick way to achieve this effect (wireframe ''over'' solid object) would be to use the D3D render states. I have never tried this, though....

Basically, set the render state to solid and render your object:

lpDev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
.. render your object ..

Then set the render state to use wireframe rendering:

lpDev->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
.. render your object again ..

Hope this helps!

Share this post


Link to post
Share on other sites