vertices count in a mesh

Blitz3D Forums/Blitz3D Programming/vertices count in a mesh

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Triangles can share vertices. So I guess what you could try is deleting all the triangles and then rebuild the surface without the triangle you want to remove. Rebuilding the triangle list should be faster than rebuilding the vert list because a triangle needs a lot less information. So you need to build a triangle list as shown below. This of course can be optimised, you do not really need to build a new trilist each time you do this. Of course you can get rid of the pesky verts you do not really need as well, but thats a bit more complicated.

Dim Trilist(3000,2)

Function removetri(surf,tri)
	numtris=CountTriangles(surf)
	For t=0 To numtris-1
		trilist(t,0)=TriangleVertex(surf,t,0)
		trilist(t,1)=TriangleVertex(surf,t,1)
		trilist(t,2)=TriangleVertex(surf,t,2)
	Next
	ClearSurface surf,False,True
	For t=0 To numtris-1
		If t<>tri Then 	AddTriangle(surf,trilist(t,0),trilist(t,1),trilist(t,2))
	Next
End Function	 


Graphics3D 640,480,0,2
sphere=CreateSphere(12)
EntityColor sphere,200,100,50
EntityPickMode sphere,2
EntityFX sphere,16

camera=CreateCamera()
PositionEntity camera,0,0,-3
light=CreateLight()
RotateEntity light,45,0,0


Repeat 

	mx=MouseX()
	my=MouseY()
	
	TurnEntity sphere,KeyDown(200)-KeyDown(208),KeyDown(205)-KeyDown(203),0
	
	If MouseDown(1) Then pick=CameraPick(camera,mx,my)
	
	If pick=sphere Then removetri(PickedSurface(),PickedTriangle())
	
	RenderWorld
	
	Text 0,0,TrisRendered()
	
	Flip
	
Until KeyDown(1)

End