Jump to content
  • Advertisement
Sign in to follow this  
BenjaminBowen

Rebuilding the Mesh in Realtime

This topic is 2852 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

I have "prototyped" my software in a very highly abstracted setup, so now I'm moving down to capture more performance... If I were to create a 3D modeling tool in C++ with Direct3D 9, how would I go about updating the mesh when the user edits it?

I also want to support this in real-time, for dynamic options when drawing the simple shapes my layer supports; such as rectangles with multiple colors (four different corners with four different colors).

Would this require shader programming? As I do want to create a highly robust framework for my game engine, I must have robust include-required shaders as well.

Thanks for reading, please respond. Since this is my first post, I'll try to contribute to the community afterwards.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
how would I go about updating the mesh when the user edits it?

Depends on what changes the user has made. For changing vertex parameters such as position, tex coords, normals, etc., just lock the vertex buffer, change the vertex parameters for the selected vertices and unlock it.

For deleting faces, create a new mesh with fewer vertices and indices, copy the vertex data from the old (locked) vertex buffer to the new one, skipping the deleted vertices, update the indices in the new mesh, unlock the buffers and delete the old mesh.

For my editor, I maintain a stack (list, vector, however you want to keep the info) of changes and two meshes: one for display which reflects all the changes the user has made, and a second mesh without any changes. When the user requests an "undo," I pop the last change from the stack, delete the display mesh, clone the "unchanged" mesh and apply all the remaining changes to it.

For the best results, you probably should render the mesh using the shaders you're going to use in-game so it's WYSIWYG: "what-you-see-is-what-you-get."

Something else you may want to consider for static mesh rendering: don't use dynamic lighting. In the editor, allow the user to place lights in the "scene," and calculate per-vertex colors to reflect the lighting.

Share this post


Link to post
Share on other sites
Quote:
Something else you may want to consider for static mesh rendering: don't use dynamic lighting. In the editor, allow the user to place lights in the "scene," and calculate per-vertex colors to reflect the lighting.


Of course! I'm actually a big contributor to this kind of clockwork (else places). I've helped people implement "baked" lighting, and it's already fully functional with my prototype.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!