triangulation implemented,

now need to test it
This commit is contained in:
Anakin 2016-11-20 16:46:49 +01:00
parent f81f03353d
commit b3a8b4bb81
2 changed files with 38 additions and 7 deletions

View File

@ -342,10 +342,16 @@ void OpenGLController::updateScene()
// give the MVP to the shader
glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix(modelIndex)[0][0]);
glDrawArrays(GL_TRIANGLES, instanceOffset, segIt->meshIndices.size() * 3);
// calculate the number of vertex
unsigned int vertexCount(0);
for (auto& it : segIt->meshIndices)
vertexCount += (it->size() - 2) * 3;
glDrawArrays(GL_TRIANGLES, instanceOffset, vertexCount);
// increase the offset
instanceOffset += segIt->meshIndices.size() * 3;
instanceOffset += vertexCount;
}
}
@ -407,8 +413,34 @@ void OpenGLController::loadMsh(const char * path)
}
else if (mshIt->size() > 3) // needs to be triangulated
{
//TODO: triangulate;
MessageBox(NULL, "Ooops!", "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
// for every triangle of the multi polygon
for (int tri = 0; tri < mshIt->size() - 2; tri++)
{
// for every edge of the triangle
for (int triEdge = 0; triEdge < 3; triEdge++)
{
Vertex tempVertex;
// every edge has 3 coordinates
for (int j = 0; j < 3; j++)
tempVertex.position[j] = (GLfloat)segIt->vertex[(*mshIt)[triEdge > 0 ? tri + triEdge : 0] * 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)[triEdge > 0 ? tri + triEdge : 0] * 2 + j];
}
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)
{

View File

@ -14,10 +14,9 @@ licence, too.
### To Do
- cluster seam to use wrong textures
- multipoly testing
- cloth testing
- colisions are displayed (dont touch hiden things)
- bones are not triangulated,
- nulls are not triangulated,
- optional display bones, shadow, collision,...
- integrate into a software:
-> gui open file ( + drag and drop),
-> list all msh under a directory,