Doubts about hollow meshes?

Started by
6 comments, last by lucky6969b 7 years ago

Notice in the snippet below, for hollow meshes and non-hollow meshes which form a square or rectangular shape

always hold true.... with a dot product of normal of e1 to e2 of zero

also, the directions of the normal are going to be the same anyways....

So how can you tell that the mesh is hollow?

Can I test if there is an edge going from v1->v3 or v2->v4, if doesn't exist, the statement is true?

Thanks

Jack


#include <iostream>
#include <d3dx9.h>

using namespace std;

int main()
{
    D3DXVECTOR3 v1, v2, v3, v4;
    D3DXVECTOR3 n1, n2, n3, n4;

    /*
    edgenormal(p1p2) = normalize(vec2(y2 - y1, x1 - x2))
    edgenormal(p2p3) = normalize(vec2(y3 - y2, x2 - x3))
    edgenormal(p3p1) = normalize(vec2(y1 - y3, x3 - x1))
    */

    // This is true for hollow and non-hollow cases

    v1 = D3DXVECTOR3(0,0,0);
    v2 = D3DXVECTOR3(2,0,0);
    v3 = D3DXVECTOR3(2,0,-2);
    v4 = D3DXVECTOR3(0,0,-2);


    n1 = D3DXVECTOR3(v2.z - v1.z, 0, v1.x - v2.x);
    D3DXVec3Normalize(&n1, &n1);

    cout << n1.x << " " << n1.y << " " << n1.z << endl;

    n2 = D3DXVECTOR3(v3.z - v2.z, 0, v2.x - v3.x);
    D3DXVec3Normalize(&n2, &n2);

    cout << n2.x << " " << n2.y << " " << n2.z << endl;

    n3 = D3DXVECTOR3(v4.z - v3.z, 0, v3.x - v4.x);
    D3DXVec3Normalize(&n3, &n3);

    cout << n3.x << " " << n3.y << " " << n3.z << endl;

    n4 = D3DXVECTOR3(v1.z - v4.z, 0, v4.x - v1.x);
    D3DXVec3Normalize(&n4, &n4);

    cout << n4.x << " " << n4.y << " " << n4.z << endl;

    float dot = D3DXVec3Dot(&n1, &n2);
    
    // 0
    cout << dot << endl;

    // For Hollow Case, there shouldn't be an edge going from v1->v3 or v2->v4

    cin.ignore(1);
    cin.get();

    return 0;
    
}
Advertisement
It's not clear what you mean with 'hollow'.

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

You can determinate the genus by 2 ? 2 genus = V - E + F.

V = vertex count, E = edge count, F = face count

A sphere (closed surface) has genus 0
A torus (one hole) has genus 1
Double Torus (two holes) has genus 2 and so forth.

(I'm unsure about exceptions on non orientable meshes like Klein Bottle or Moebius Band, but we don't use tham usually)

A open mesh with the topology of a disc (e.g. a one sided quad) has a genus of one (it has one hole around it's edge), if i'm not wrong, but check this please.
So you might be able to get the information you need by combining both formulas.

You might wanna read up on topology and mesh parametrization (applications are automatic UV generation, remeshing) to get more info.
E.g. there is a simple method where you run dijkstra over a mesh and combine it with it's dual to extract boundary edge loops that cut a mesh of any genus into a set of submeshes mapable to 2D space.

Hello

I've got a mesh that got a hole in the middle....
The count is as follows:
V = 32
F = 40
E = 72
The genus is 0, is a zero for any meshes that got a hole in a middle?
Thanks
Jack

You'd need to post a screenshot.
I'm not really into topology right now but a two manifold mesh with genus 0 should not have a hole, only a closed surface (topolgy of a sphere) is genus 0.

Likely your mesh has not the required properties to make those rules applicable.
A typical mesh used in games may duplicate vertices at uv seams or normal discontinuities - you'd need to fuse those first.
And of course you need to triangulate quads or polygons.
There may be other issues, the screenshot may show it up.
But first let's see if you are correct by plugging in your numbers:

2 ? 2 genus = V - E + F
2 ? 2 genus = 32 - 72 + 40
2 ? 2 genus = 0 // probably that's where you get your zero but we're not done yet
2 = 2 genus
1 = genus
So you have genus of 1, which seems correct.

But note that a hole in a torus (a closed surface with a hole) is different from the kind of hole we get if we delete a random triangle from a tesselated sphere (leading to non closed surface).
We could stretch the boundary of the hole out and squeeze the sphere together at the middle of the hole, resulting in a flat disc shaped one sided mesh with no 'hole' but a boundary.
The shape has changed, but not the topology - both have the topology of a one sided disc.

Hello,

I sort it out now, seems that the mesh indeed has a genus of 1, which is correct.....

But to another challenging problem, my frames do not hold exactly one mesh....

The mesh is collapsed into one frame.... I think we've some problems with the art.

So let's say I had a big scene, I test out the genus of such scene, I want to test it

piece by piece. Preferably one mesh per frame.... But that's okay....

Let's see if I can fix the asset today.

But should it be the only correct way is to test individual frame, with one mesh per frame?

otherwise, I only get one number as a result, which can't tell which part of a mesh contains a hole.

Thanks

Jack

I'm curious, what do you try to achieve?
Usually this is related to precroccessing tools. You use it at runtime, to detect holes or something?
Maybe stuff like shooting a hole through a wall and connecting the holes at both sides to get a nice closed surface again?

I am building a hybrid modeling and game engine type of thing....

Although I am quite up to that area yet, you can find something in Unity that

does some stitching of terrain that could cap holes or something like that.....

Maybe just something like that... and more

This topic is closed to new replies.

Advertisement