Jump to content
  • Advertisement


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


vertexbuffer/mesh question

This topic is 5394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, is it possible to make a mesh from a vertex buffer? One of the reasons for this is I want to make vertices dynamicaly and then put, or add them to a mesh, and then maybe also use the pick triangle thing on it. Also there is a CreateMesh function, but this doesn''t show how to get the vertices into the mesh, I can''t remember exactly (not at home right now), but the function is something like this; CreateMesh{ number of faces, number of vertices, pointer to fvf declaration or fvf flags, pointer to rendering device, pointer to the created mesh } This doesn''t show what the vertices actually are though, where they are positioned. thanks for any help

Share this post

Link to post
Share on other sites
Yes I am doing that in some play-code.
The mesh is just an interface, a class with some members. The triangles are in the vertexbuffer, an empty one is created with the right size and you can copy in your data afterwards. Too bad there is no simple assignment, if you already have a vertexbuffer.

What I do is create a new mesh with D3DXCreateMesh, pass in the number of vertexes and faces (triangles), then use mymesh->lockvertexbuffer, copy the vertexes into the buffer, and unlock again.
You will probably need to create an index buffer, but that can be a simple array of 0,1,2,3... of word (16-bit) and copy that in too.
The advantages are that you can draw subsets, if you fill the attributebuffer, call createnormals, optimize it (sorts it so that it''s faster), etc.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!