Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Genus Calculation again.

This topic is 493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
	

 

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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?

 

Edited by lucky6969b

Share this post


Link to post
Share on other sites
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.

Edited by JoeJ

Share this post


Link to post
Share on other sites

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 )
	

Share this post


Link to post
Share on other sites

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!!!!

Edited by lucky6969b

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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...)

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!