- Home /
delete mesh triangles only
Hello, I hope somebody can help me with this I want to remove or delete triangles of a mesh object, more specific only the triangles are in Y = 0 position, here a imagen of what i mean
i dont want to use shaders with transparent, i need remove the triangles if its posible
thanks in advance
Answer by Bunny83 · Oct 25, 2013 at 04:40 AM
Well, if this is a mesh and not a terrain, just iterate through the triangles array, check which triangles have all vertices y == 0 and remove it. The easiest way is to but the indices into a List and iterate backwards:
// C#
Vector3[] vertices = mesh.vertices;
List<int> indices = new List<int>(mesh.triangles);
int count = indices.Count / 3;
for (int i = count-1; i >= 0; i--)
{
Vector3 V1 = vertices[indices[i*3 + 0]];
Vector3 V2 = vertices[indices[i*3 + 1]];
Vector3 V3 = vertices[indices[i*3 + 2]];
if (V1.y < 0.001f && V2.y < 0.001f && V3.y < 0.001f)
{
indices.RemoveRange(i*3, 3);
}
}
mesh.triangles = indices.ToArray();
Written from scratch, untested.
$$anonymous$$eep in $$anonymous$$d if somewhere in the middle a triangle meets the condition it will be removed too. As solution you could simply "lift" those dark areas you want to keep a little bit, by not using solid black but a slightly brighter black for those areas.
Thx, but it way to remove the triagles not the vertices? because I will use a sequence of imagens for the depth map
uhm i remove the triangles... the vertices are still there. I don't even update the vertices....
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Change Pivot Point- Maya 3 Answers
White artifacting bordering mesh triangles 0 Answers