- Home /
Is it possible to remove part of a mesh?
I looked around at previous answers and most of them seemed to say that its possible, but improbable.
I'm currently in the design stage (I haven't coded anything, just figuring out what TO code), but I'm creating a 3-D Liero game. Essentially, I'll have a big cube of dirt (implemented voxel style) with a couple of worms blowing their way through it. My original idea to implement the terrain was that whenever a voxel was destroyed it would call on its neighbors, if they were there, to create a mesh face and then join that face to the larger "terrain" mesh in order to help performance via Mesh.CombineMeshes (nothing says bad fps like 10000 meshes). I'm not going to bother with diagonals or anything, and it should look blocky (kinda like minecraft, but with much much smaller cubes).
The problem is that when I remove a voxel I'll also have to remove any faces that it had previously generated. It wouldn't be hard to locate all the potential vertices, and triangles, that it could have created. So using that is it possible to remove those vertices (and their potential triangles) from the overall mesh? If so, how? What functions would I need and what data?
Of course, anything's possible.
You will have to become an expert, generally, at program$$anonymous$$g mesh.
if you look in the Documentation you can find the mesh class and proceed from there.
There are dozens or hundreds of questions on here about different aspects of generating mesh.
http://answers.unity3d.com/questions/315059/how-to-improve-performance-while-generating-extrud.html
Realise too there are a number of "unity $$anonymous$$inecraft starter kits" kicking around that have huge code bases and you would certainly start with one of those.
This question is too general so if you have a specific question, ask a new one! Cheers!
'What functions would I need and what data?" the literal answer is glance at "$$anonymous$$esh" in the unit documentation, you will see the .vertices functions and so on.
Answer by Eric5h5 · Mar 12, 2013 at 07:24 AM
The standard method is to build mesh chunks, and rebuild them as necessary. Don't use Mesh.CombineMeshes; that adds an unnecessary layer of inefficiency. So you don't need to track vertices or anything, just rebuild the relevant chunk when the player removes or adds a voxel.
Your answer
Follow this Question
Related Questions
Voxel Mesh has Lines Between the Voxels 1 Answer
CombineMeshes() Not Working Properly? 0 Answers
Custom shader light blending 0 Answers
Marching cubes problem, some tris not drawing properly 2 Answers
Colored Voxel Meshs 2 Answers