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;
}