Deleting individual Triangles/Vertices?

Blitz3D Forums/Blitz3D Programming/Deleting individual Triangles/Vertices?

Jim Teeuwen(Posted 2003) [#1]
Hi ppl. Im fiddling around abit with some dynamic mesh creation and Ive got a lil prob.

I need to be able to delete individual Triangles from a mesh at runtime. I allready know the indices of the triangles I need to delete. it's just a matter of finding a command like DeleteTris( Surface, index )..

Anyone did something like this before and care to share some pointers? If at all possible i'd like a method wich does not require a loop

e.g:
For n = 1 to CountTriangles( surface )
...
Next

as stated earlier, I allready know the indices of the triangles I need removed.

Thakns in advance.


Rob(Posted 2003) [#2]
There's no such thing. You can use clearsurface to clear verts and triangles, or just triangles, then rebuild.


Jim Teeuwen(Posted 2003) [#3]
ack. I was affraid of that.. thats going to slow things down quite a bit :\

anyways, thanks for the info


elias_t(Posted 2003) [#4]
Hi.

Just added this in the code archives:
http://www.blitzbasic.com/codearcs/codearcs.php?code=735

removes individual triangles,vertices and isolated vertices.

You just have to declare the trilist and vertlist arrays.
[Not fill them but redim them.]

Bye.


Michael Reitzenstein(Posted 2003) [#5]
ack. I was affraid of that.. thats going to slow things down quite a bit :\

No it won't, deleting individual triangles and vertices is a very slow operation.


big10p(Posted 2003) [#6]
elias_t's functions sound like the way to go but if you want a quick, dirty, hacky way to remove a tri - and it's NOT sharing verts with any other tri - simply set the coords of one of the tri's verts to match the coords of another of the tri's verts. This will cause the tri to have zero surface area and so can't (and wont) get rendered.

Uh, I feel so dirty! :)


Jim Teeuwen(Posted 2003) [#7]
heh that sounds like an idea. I tested around abit with rebuilding the entire mesh. I wasnt as slow as i expected it to be.. the mesh isnt too big.. 4000 triangles at most so i think Ill go this way.

anyways, thanks for the comments! :)


yinch(Posted 2003) [#8]
One of the things you can do is also to reverse the order of the vertex IDs for a particular triangle (swap any two vertex IDs will achieve this) - this will make it face 'backwards' and be culled - it leaves the triangle list unchanged in size.

y'03


Jim Teeuwen(Posted 2003) [#9]
this might indeed by faster then constantly adding/removing vertices and rebuilding the mesh. nice idea!


makakoman(Posted 2003) [#10]
@Yinch,

One of the things you can do is also to reverse the order of the vertex IDs for a particular triangle (swap any two vertex IDs will achieve this) - this will make it face 'backwards' and be culled - it leaves the triangle list unchanged in size.


How do you swap triangle vertex IDs once the triangle is already built? Do you mean use VertexCoords(...) to swap the coordinates of two different vertices?

Thanks,
MK