shorten code,

tested multipoly, there are some problems, look at the README.md,
This commit is contained in:
Anakin 2016-11-20 16:56:56 +01:00
parent b3a8b4bb81
commit bcdc17c362
2 changed files with 6 additions and 31 deletions

View File

@ -388,33 +388,10 @@ void OpenGLController::loadMsh(const char * path)
{ {
for (auto& mshIt : segIt->meshIndices) // for every polygon for (auto& mshIt : segIt->meshIndices) // for every polygon
{ {
if (mshIt->size() == 3) // already triangulated if (mshIt->size() >= 3) // multipoly
{
for (int i = 0; i < 3; i++) // for every edge of the polygon
{
Vertex tempVertex;
// every edge has 3 coordinates
for (int j = 0; j < 3; j++)
tempVertex.position[j] = (GLfloat)segIt->vertex[(*mshIt)[i] * 3 + j];
// and 2 UV
if (segIt->uv == NULL)
{
tempVertex.uv[0] = 1.0;
tempVertex.uv[1] = 1.0;
}
else
{
for (int j = 0; j < 2; j++)
tempVertex.uv[j] = (GLfloat)segIt->uv[(*mshIt)[i] * 2 + j];
}
tempBufferData.push_back(tempVertex);
}
}
else if (mshIt->size() > 3) // needs to be triangulated
{ {
// for every triangle of the multi polygon // for every triangle of the multi polygon
for (int tri = 0; tri < mshIt->size() - 2; tri++) for (unsigned int tri = 0; tri < mshIt->size() - 2; tri++)
{ {
// for every edge of the triangle // for every edge of the triangle
for (int triEdge = 0; triEdge < 3; triEdge++) for (int triEdge = 0; triEdge < 3; triEdge++)
@ -438,9 +415,6 @@ void OpenGLController::loadMsh(const char * path)
tempBufferData.push_back(tempVertex); tempBufferData.push_back(tempVertex);
} }
} }
//TODO: test triangulation
//MessageBox(NULL, "Ooops!", "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
} }
else // this shouldn't happen (polygon with less then 3 vertex) else // this shouldn't happen (polygon with less then 3 vertex)
{ {

View File

@ -13,8 +13,9 @@ Feel free to use my code the way you like. But remember i used some public libra
licence, too. licence, too.
### To Do ### To Do
- cluster seam to use wrong textures - cluster use wrong textures
- multipoly testing - use normals or fix ccw and cw
- multipoly triangulation not 100% good
- cloth testing - cloth testing
- optional display bones, shadow, collision,... - optional display bones, shadow, collision,...
- integrate into a software: - integrate into a software: