ClearSurface Function

Blitz3D Forums/Blitz3D Programming/ClearSurface Function

ringwraith(Posted 2007) [#1]
Just out of curiosity, how does the ClearSurface function work if you set it to clear all the vertices but not the triangles on a surface? I mean you can't have a triangle on a surface if there are no vertices, right? Does it automatically clear everything or just clear all the vertices that aren't attached to a triangle?


Stevie G(Posted 2007) [#2]
You really would have no reason to clear the vertices on their own as, like you say, the triangles rely upon them. I haven't tried but it would make sense for it to clear all the triangles too - otherwise you'd probably get a MAV on renderworld.

Stevie


ringwraith(Posted 2007) [#3]
I just tested it out and you're right, it does cause a MAV on RenderWorld(). It's too bad, I was hoping I could use that to clear any unnecessary vertices from a surface, I guess I'll have to figure out my own way to do that now.


Stevie G(Posted 2007) [#4]
What is it your trying to do? I have alot of custom mesh function so may have one which fits the bill.


Ross C(Posted 2007) [#5]
If your looking for a polygon reduction function, John J had one in the code archives. And Stevie seems to have a wealth of them too :o)


Danny(Posted 2007) [#6]
Anyone have a DeleteVertex(surface, vertexIndex) and DeleteTriangle(surface, triangleIndex) lying around by any chance??

Danny


Stevie G(Posted 2007) [#7]
This takes a surface index rather than the surface ...

Function DeleteTriangle( mesh , Sindex , Tindex )

	tmp = CopyMesh( mesh )
	ts = GetSurface( tmp, Sindex )

	s = GetSurface( mesh, Sindex )
	ClearSurface s , True, True 
	
	For t = 0 To CountTriangles( s ) - 1
		If t <> Tindex
			v0 = TriangleVertex( ts, t , 0 )
			v1 = TriangleVertex( ts, t , 1 )
			v2 = TriangleVertex( ts, t , 2 )
			Nv0 = AddVertex( s, VertexX( ts, v0 ) , VertexY( ts, v0 ) , VertexZ( ts, v0 ) , VertexU( ts, v0 ) , VertexV( ts, v0 ) )
			Nv1 = AddVertex( s, VertexX( ts, v1 ) , VertexY( ts, v1 ) , VertexZ( ts, v1 ) , VertexU( ts, v1 ) , VertexV( ts, v1 ) )
			Nv2 = AddVertex( s, VertexX( ts, v2 ) , VertexY( ts, v2 ) , VertexZ( ts, v2 ) , VertexU( ts, v2 ) , VertexV( ts, v2 ) )
			AddTriangle s, Nv0, Nv1, Nv2
		EndIf
	Next
	
	FreeEntity tmp
	
End Function



Danny(Posted 2007) [#8]
Thanks stevie,
I should have been more specific. I was just ranting since Blitz doesn't have any such functions. For anything you can 'set' there should be a 'get' - anything you can 'create' should be able to be 'destroyed'.

My problem being that these functions basically require a 'complete rebuild' of the mesh 'except' for the vertices/triangles you didn't need - which is rediculous, but unfortunately the only way. Not something you want to do in realtime..

cheers anyway,
D.