vertex counter?

anyone have a vertex counter, or care to write one up for me :wink:

what do you mean with that?

The vertex count is displayed at the menu bar on the right side. To see the vertexcount of an object switch to edit mode.

no not that I mean in game where the framerate and profile are, when you link an object(and duplicate it a number of time as in my case) blender doesn’t tell you the total vert count.

I know it can be done but I don’t know python and im not really interested in learning so I was hoping someone could write one up???:confused:

Well, since you’re just spawning instances of the same object, the total vertex count is the number of vertices for that object, multiplied by the number of instances.

… I can write it for you, if you really need me to, but I think you can/should do this one yourself.

you could do it by an always sensor attached to the script, loop through scene.objects.mesh.vertexCount or w/e ? then you get a total scene count …
write the value to a property and then turn on debugging for the value.

i reckons 5 lines of code or so…? give it a shot, and if you’ve got nothing by tomorrow i’ll look at it tonight :slight_smile:

are you using 2.5x or 2.49?

Even better.

well no I can’t lol I can read python and see how it works but I can’t write my own, plus I focus on the artistic side of things modeling, texture, concept art and story etc I also make music and do graphic design… so trying to learn python(which I’ve tried in the past) on top off all that would just drive me nuts :spin:

so yeah if you could put a .blend together for me I would greatly appreciate it, thanks;)

oh and im using 2.55 I always use the latest from the blender site

sorry for the bump right here, only one im going to do :smiley:

try this

Verts.py


import GameLogic

PallVerts = "allVerts"

def countVerts(cont):
  if not cont.sensors[0].positive:
    return

  scene = GameLogic.getCurrentScene()
  sum = countSceneVerts(scene)
  cont.owner[PallVerts] = sum
 
def countSceneVerts(scene):
  sum = 0
  for obj in scene.objects:
    sum += countObjectVerts(obj)
  return sum

def countObjectVerts(obj):
  sum = 0
  for mesh in obj.meshes:
    sum += countMeshVerts(mesh)
  return sum

def countMeshVerts(mesh):
  sum = 0
  for material in range(mesh.numMaterials):
    sum += mesh.getVertexArrayLength(material)
  return sum


It works with 2.49b and 2.5x

It is a Module, so switch the Python controller to Module mode. Enter Verts.countVerts. Trigger it by whatever senso you like. I recommend to trigger it not faster then every 60 frames (every second).
It places to number of vertices in the porperty allVerts of the object running the Python controller. To see it switch on debug mode and the debug flag at the property.

Keep in mind for the GE each triangle has 3 Vertices and each quad has 4 vertices, regardles if ther eis an connecting edge or not.

I hope it helps
Monster

thanks for the effort monster but this has become a hassle dude if you can put it in a .blend for me that would be great but I just need a simple way to see all active verts in my BGE scene im way to busy with other things to try and get this to work…

so thanks again man but it’s just made more shit for me to do… :frowning: lol

If you can’t/won’t learn to do some scripting and you mostly focus on the artistic side of things, why not join a team.
There are quite a few scripters around who would enjoy having some extra help with modeling and music for a team project.

Monsters script added to a 2.5x blend.

I notice with the default cube it displays ‘24’ - and when i deleted it and added a basic plane it displayed ‘8’, (even with double-sided turned off)
whats going on there?

Attachments

VertCount.blend (391 KB)

because im going to start my own game project soon maybe in a month or so, but right now im trying to plan everything out story concept art modeling a few general assets like trees, rocks, terrain skydome etc theres too many game project fail due to lack of planing and leadership I dont want t fall victim to the same issues.

and I wanted this to try to strain the GE and get an idea of the limitations, I think there is around 200,000 verts in the scene with a few point lights and a Dof blur… running at 40-60fps but I wanted to know the exact vert count

thanks for you troubles mate, hopefully monster can fix the issue with it

i dont think its an issue, just an understanding issue.
it would appear that in BGE there are no shared vertexes, each face has its own, so at 6 faces, 4 vertex per face = 24 vertexes for basic cube.
the plane has me confused though, with the ‘double-sided’ mesh turned off not changing it. i still believe it is an understanding thing, not a problem with the script.

(just before the last “return sum” line, you could add (indented identically to the return line) “print (mesh.name, sum)”, which would then print out the mesh and each objects vertex count in the terminal (that extra window that opens in windows, or run from the command line and check the terminal in linux… something similar on MacOSX i presume)

Blender Game Engine Started
Sphere 1984
Icosphere 240
Cylinder 194
Cube.001 24
Cone 129
Cube 24
Blender Game Engine Finished

oh ok thats odd in a sort of makes sense way lol, can you able to tell blender that the vertexes are shared?

edit: I just tested a plane and it gave me 4 verts… are you using 2.4x

Just do math…

as he said 6 faces equal 24 vertices, so just divide that be 6 to get 4, which a cube has 8 vertices… so I guess go ahead and divide by 4 then multiply be 2… Not sure how the formula checks out for calculating the vertex count (and frankly it’s too late for me to care) but basically just do: (sum / 4)*2

yeah but the whole point of this is so I can test and get on with my modeling, texturing, story, planing… frankly trying to get this vertex counter was waste of time… now you say “do math” good sir I do believe you out of line lol. thanks for people efforts though I do appreciate the help but imma say this has been a bust and i’ll just focus on other stuff for now

Do not do that much math, the smple truth is: The BGE deals with this amount of vertices. It does not matter if ou think they are shared. This is just semantic.

Much more important than vertex count is face count!
(easy to modify the Python code for that)

Especially the faces that are pointing to the camera are important for performance. But this is not easy.

All ou can do with the vertex counter is to get an idea how much faces you already have in your scene. Keep in mind this are all vertices even from culled/occluded objects.

So you can estimate how much objects you can add without performance problems (on your PC).

I made a demo that does what you want (2.49b file attached).

Monster is correct in saying that face count is much more important than vertex count, however:

I don’t really know of anyone who actually uses either as their performance metric: people simply measure the performance impact of a single object, and if it’s relatively low, they reason that they can add more with little to no consequences.

Usually, this simple logic is sufficient to create something playable.

As always, I will argue that pre-mature optimization is the source of all known evil, and that therefore all of these “counters” are a complete and utter waste of everyone’s time (whether they know it or not).

You should worry about performance only in the following cases:

  • The framerate has dropped to some unplayable level, so something has to be done right now.
  • The game is largely finished, and you can make things even faster, for lower-end systems.

Attachments

vert_count.blend (135 KB)