Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 57df0a2e authored by Anakin's avatar Anakin
Browse files

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
parent 927ce1cd
......@@ -24,8 +24,9 @@ struct Segment {
std::uint32_t textureIndex = 0;
float* vertex = nullptr;
float* uv = nullptr;
std::uint32_t* mesh = nullptr;
std::uint32_t meshSize = 0;
std::uint32_t* mesh = nullptr; // not used when using vector
std::uint32_t meshSize = 0; //not used when using vector
std::vector<std::vector<std::uint32_t>*> meshIndices; // indices into vertex array
};
struct Modl {
......
......@@ -373,23 +373,6 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
{
/*if (!strcmp("SHDW", (*it)->name))
{
fsMesh.seekg((*it)->position);
/* shadow mesh geometry
long int - 4 - number of vertex positions
float[3][] - 12 each - vertex positions (XYZ)
long int - 4 - number of edges
short int[4][] - 8 each - edge the following 4 entries from one edge
> short int - 2 - vertex index of this edge, referes to the vertex list
> short int - 2 - Reference into an edge. Defines the target vertex (the local edge vertex of the referenced edge) to which the edge should be dran from the local vertex
> short int - 2 - Second reference into an edge. In all example .msh files I've seen this always refers to the same vertex as the first edge reference
> short int - 2 - MAX_VALUE of short integers (65535). Indicates the end of this edge
* /
continue;
}*/
if (!strcmp("MATI", (*it)->name))
{
fsMesh.seekg((*it)->position);
......@@ -418,7 +401,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
continue;
}
if (!strcmp("STRP", (*it)->name))
/*if (!strcmp("STRP", (*it)->name))
{
// jump to the data section and read the size;
fsMesh.seekg((*it)->position);
......@@ -452,15 +435,19 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
}
continue;
}
}*/
/////////////////////////////////////////////////////////////////////////////////////////
/////DEV ZONE
if (!strcmp("STRP", (*it)->name))
{
// this needs to be a member
std::vector<std::vector<std::uint32_t>*> tempVector;
// don't get null, bone, shadowMesh and hidden mesh indices
if (dataDestination->type == null ||
dataDestination->type == bone ||
dataDestination->type == shadowMesh ||
dataDestination->renderFlags == 1)
continue;
// jump to the data section and read the size;
fsMesh.seekg((*it)->position);
......@@ -484,6 +471,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
tempPoly->push_back((std::uint32_t)tempValue);
// new Polygon found
if (highBitCount == 2)
{
// reset highBitCount
......@@ -493,7 +481,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
std::uint32_t saveData[2];
for (int i = 0; i < 2; i++)
{
saveData[0] = tempPoly->back();
saveData[i] = tempPoly->back();
tempPoly->pop_back();
}
......@@ -503,13 +491,17 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
newPointer->push_back(saveData[i]);
// save the old vector and set the pointer to the new one
tempVector.push_back(tempPoly);
tempData->meshIndices.push_back(tempPoly);
tempPoly = newPointer;
} // if high bit set
} // for all values
// save the last values (where no 2 high bits follow);
tempVector.push_back(tempPoly);
tempData->meshIndices.push_back(tempPoly);
// kick the first element, it's empty as a reason of the algo above;
tempData->meshIndices.erase(tempData->meshIndices.begin());
continue;
}
......
......@@ -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);
......
......@@ -17,7 +17,7 @@ int main(int argc, char** argv)
else
scene = OpenGLController::getInstance();
scene->loadMsh("..\\Release\\Msh\\cluster.msh");
scene->loadMsh("..\\Release\\Msh\\cubeTex.msh");
do {
scene->updateScene();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment