use different variables to store the data. The aim is to handle even not triangulated mesh files.
At the moment there is a problem with the UV using the new method
This commit is contained in:
@@ -120,8 +120,17 @@ void OpenGLController::deleteVectors()
|
||||
cursor->segmLst.pop_back();
|
||||
|
||||
delete segmCuror->uv;
|
||||
delete segmCuror->mesh;
|
||||
delete segmCuror->mesh; // not used when using vector
|
||||
delete segmCuror->vertex;
|
||||
|
||||
while (!segmCuror->meshIndices.empty())
|
||||
{
|
||||
std::vector<std::uint32_t>* meshCursor = segmCuror->meshIndices.back();
|
||||
meshCursor->clear();
|
||||
segmCuror->meshIndices.pop_back();
|
||||
delete meshCursor;
|
||||
}
|
||||
|
||||
delete segmCuror;
|
||||
}
|
||||
|
||||
@@ -368,7 +377,7 @@ void OpenGLController::loadMsh(const char * path)
|
||||
// collect vertex data of all models
|
||||
std::vector<Vertex> tempBufferData;
|
||||
|
||||
for (auto& modIt : vModels)
|
||||
/*for (auto& modIt : vModels)
|
||||
{
|
||||
// don't draw bones, nulls, shadow mesh and hidden things
|
||||
if (modIt->type == null || modIt->type == bone || modIt->type == shadowMesh || modIt->renderFlags == 1)
|
||||
@@ -397,7 +406,56 @@ void OpenGLController::loadMsh(const char * path)
|
||||
tempBufferData.push_back(tempVertex);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////DEV ZONE
|
||||
for (auto& modIt : vModels)
|
||||
{
|
||||
for (auto& segIt : modIt->segmLst)
|
||||
{
|
||||
for (auto& mshIt : segIt->meshIndices)
|
||||
{
|
||||
if (mshIt->size() == 3) // already triangulated
|
||||
{
|
||||
// for every edge of the polygon (in that case 3)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
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] * 3 + j];
|
||||
}
|
||||
tempBufferData.push_back(tempVertex);
|
||||
}
|
||||
}
|
||||
else if (mshIt->size() > 3) // needs to be triangulated
|
||||
{
|
||||
//triangulate;
|
||||
MessageBox(NULL, "Ooops!", "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
else // this shouldn't happen (polygon with less then 3 vertex)
|
||||
{
|
||||
deleteVectors();
|
||||
MessageBox(NULL, "You have polygons with less then 3 vertices!", "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// think of delete the data from obj here. It's no longer needed
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// fill the buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, gluiVertexBufferID);
|
||||
|
||||
Reference in New Issue
Block a user