Archived

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

apanjocko

creating a mesh from a vertexbuffer (managed)

Recommended Posts

i know there was a function in D3DX for creating a mesh from a vertexbuffer. i just can''t find it in the managed directx (c#). can anyone help me out? the reason is this, i have generated a terrain and stored that in a vertexbuffer. now i would like to use the progessive-mesh interface to reduce the number of vertices as the camera get farer away. appreciate any help i can get on this!

Share this post


Link to post
Share on other sites
Basically, instead of creating a VB, create a mesh. Then, fill the mesh's VB.

Detailed steps:
1.) create a pointer to a mesh (LPD3DXMESH *pMesh)
2.) create a blank mesh (D3DXCreateMeshFVF(...))
3.) lock mesh's vertex buffer( pMesh->LockVertexBuffer(...))
4.) fill vertex buffer
5.) unlock vertex buffer

Let me know if it works :D

-Edit-
Above was from C++ Docs. Should be the same for C#, no?
-Edit-

[edited by - dr1ft on October 23, 2003 1:49:21 PM]

Share this post


Link to post
Share on other sites
how about the index buffer?
you have to fill that too? and is a vertex-buffer dynamically resizeable? i though you had to enter the size of the buffer when creating it, and in that case the Mesh constructor would probably create an empty vertexbuffer and an empty indexbuffer.

Share this post


Link to post
Share on other sites
There is also a LockIndexBuffer() method.

Look up "ID3DXMesh" in the SDK docs.

>and is a vertex-buffer dynamically resizeable?
You can use dynamic VBs if you want. Look up different Lock types: search "D3DLOCK" in the SDK.

Share this post


Link to post
Share on other sites