Counting Polygons

Blitz3D Forums/Blitz3D Programming/Counting Polygons

Lilprog(Posted 2004) [#1]
Is there anyway in blitz to count the number of polygons in a loaded 3ds file?


big10p(Posted 2004) [#2]
Just iterate through all the surfaces in the mesh and use CountTriangles() on them.


jfk EO-11110(Posted 2004) [#3]
you could hide all other meshes, do a renderworld and then check TrisRendered()

ALternatively you could also use a second camera that is way off the scene, clone the mesh, position it in front of that far-away camera and do the same as I said before.

The most complicaed method may be to parse all surfaces and count the triangles. Well, maybe it even isn't that complicated.


Rottbott(Posted 2004) [#4]
Pretty simple.

Function CountMeshTriangles(Mesh)
  Local Tris = 0
  For i = 1 To CountSurfaces(Mesh)
    Tris = Tris + CountTriangles(GetSurface(Mesh, i))
  Next
  Return Tris
End Function
(Untested)


jfk EO-11110(Posted 2004) [#5]
If it's loaded with LoadMesh then ok. But if it's loaded with LoadAnimMesh then you need to parse the children recursively.


Beaker(Posted 2004) [#6]
Example 3 does it here:
http://www.blitzbasic.com/codearcs/codearcs.php?code=796