Odd results trying to get a mesh's vertex count

I’m using this code snippet, from a script inside the object in question:

Mesh temp = gameObject.GetComponent<MeshFilter>().sharedMesh;
        if (temp)
            print("Name|Vertices: " +gameObject.name+"|"+ temp.vertices.Length);

And here’s a sample object;

As far as i’m concerned, this object should take exactly 14 vertices to create. and yet my debug output for it is:

Name|Vertices: Brickwall68|314

314 vertices. What?
Is this correct? Did i screw up the code somewhere?

These objects are dynamically generated by an editor extension i purchased, i want to be sure this is correct before i go shouting at the author.

Uh, yeah… that’s quite clearly got more than 14 verts


…etc

There’s no way that could be done with 14 vertices even if you get rid of all the redundant geometry; just the visible faces alone would need 19 vertices. If the rest of it looks like I imagine, it would be 42 verts.

–Eric

There’s also this

[this not thos. xD]

And in Unity each texture is on its separate set of vertices, due to the way the UV works

this can’t be right, if constructed correctly (which admittedly, it isn’t,) the number of vertices couldn’t possibly be odd. It’s basically just a somewhat complex front face extruded forward a bit, so the vertex count should be 2n, the entire area between the front and back should be all squares and contain no additional verts of its own.

all that said, it seems like theere’s a ton of worthless geometry on the side parts: http://puu.sh/diHZ7/1f30caff13.jpg

is my code correct then? is this really over 300 vertices?

you know, i don’t actyually need sharp edges here, infact i’d prefer them to be rendered more smoothly. if this is indeed the case, is there any way to join those up and make it not split ?

does anyone know of a simple tool to fix this object? All i’d really need is something to check the angle between two edges, and to merge them(and remove the intervening vertex) if that angle is below a certain value. I think in most of these cases, that angle is almost zero/180

how complex would it be to write such a thing myself? mesh processing is a new area for me.

If you do end up merging them though the mesh will end up looking like this shading-wise. Like i said black spots will appear and it’ll be odd

Erm, 42 isn’t an odd number last I checked. (Significant, maybe, but not odd.)

You don’t want that; vertices must be split on normals and UV edges and can’t be merged. Or at least not without completely screwing up the model.

–Eric

1 Like