Genus Calculation again.

Started by
10 comments, last by lucky6969b 6 years, 8 months ago

I apologize first as I lost track of the previous posting for this topic.

I am wondering how do I calculate the genus of a mesh. For instance, if I got a box, just a plain-vanilla box, and if I use the following formula, I will get a genus of 6....

I believe it's wrong.


	int genus = verts.size() + faces.size() - edges.size();
	

	Blind_Block Genus: 6
	

When using this one:


	int genus = (2 + (verts.size() + faces.size() - edges.size())) / 2;
	

I would get:


	Blind_Block Genus: 4
	

 

Advertisement

2 − 2 * genus = V - E + F

old topic: https://www.gamedev.net/forums/topic/687422-doubts-about-hollow-meshes/?tab=comments#comment-5337574

If i did the math right what you want is

genus = (2 - (V - E + F)) / 2

Hello JoeJ,

If that is the case, did I just find the right result? That is a box mesh.... (not a plane with a hole in the middle this time), it has a genus of 4.

Thanks

Jack

Can't be... lets try for box:

genus = (2 - (V - E + F)) / 2

genus = (2 - (8 - 12 + 6)) / 2

genus = 0

Are you sure you don't have double vertices due to differung normals / UVs?

Hello,

I know now, because I got a wack exporter that doesn't support vertex duplication elimination.

The vertex count is 24 for a box, ....

But what does it mean to have a genus of -2?

 

5 minutes ago, lucky6969b said:

But what does it mean to have a genus of -2?

Maybe this happens if the mesh is not a closed two manifold (e.g. grass billboard quads vs. a solid cube mesh)? Or it has polygons and not just triangles. ...

Quote

you can check if a triangle mesh is a closed two manifold if V + F - E = 2.

... but i guess this simple check can still be false positive in some degenerate cases, so you additionally need to check each edge to share exact two triangles.

One of these could be the problem, I don't know which.

The "Blind_Block" has genus of 0, but some other planar mesh still reports 24 vertexes, it is actually a box,

Funny enough is when I opened the obj file, it has 8 vertexes in that part?


	#define aiProcessPreset_TargetRealtime_Quality ( \
    aiProcess_CalcTangentSpace                |  \
    aiProcess_GenSmoothNormals                |  \
    aiProcess_JoinIdenticalVertices            |  \
    aiProcess_ImproveCacheLocality            |  \
    aiProcess_LimitBoneWeights                |  \
    aiProcess_RemoveRedundantMaterials      |  \
    aiProcess_SplitLargeMeshes                |  \
    aiProcess_Triangulate                    |  \
    aiProcess_GenUVCoords                   |  \
    aiProcess_SortByPType                   |  \
    aiProcess_FindDegenerates               |  \
    aiProcess_FindInvalidData               |  \
    0 )
	

Still not sure why, the assimp would load a 8-vertex submesh into a 24-vertex entity?

It's got 12 faces and 24 vertexes

 

Oh yeah, solid cube mesh!!!!

You're confusing vertices with positions. A cube can't be sensibly represented with 8 vertices alone - if you need texcoords and/or normals, that is.

Assimp may do vertex duplication internally due to something like aiProcess_GenUVCoords and maybe aiProcess_CalcTangentSpace. E.g. it reads a cube mesh with 8 vertices, adds UV coords and so has to split in UV space, outputs > 8 vertices.

As soon as a mesh has UVs, duplicating vertices is unavoidable for any closed two manifold mesh. To get around this, you can generate a copy of the original mesh, remove UVs and merge vertices with positions smaller than epsilon.

You can then also use data structures friendly for geometry processing tasks, like the half edge: https://www.openmesh.org/Daily-Builds/Doc/a00016.html

You can create a mapping frome the game asset to the working copy to reflect any changes you do on the copy on the original asset as well (which leads to other porblems like the need to fuse UVs, leading to UV overlaps and flips...)

 

This topic is closed to new replies.

Advertisement