cloth stores the data in vectors, too;

removed the old unused code
This commit is contained in:
Anakin 2016-11-20 13:09:02 +01:00
parent 9ac1a25954
commit f81f03353d
4 changed files with 23 additions and 91 deletions

View File

@ -24,8 +24,6 @@ struct Segment {
std::uint32_t textureIndex = 0;
float* vertex = nullptr;
float* uv = nullptr;
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
};

View File

@ -401,45 +401,6 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
continue;
}
/*if (!strcmp("STRP", (*it)->name))
{
// jump to the data section and read the size;
fsMesh.seekg((*it)->position);
fsMesh.read(reinterpret_cast<char*>(&tempData->meshSize), sizeof(tempData->meshSize));
// workaround: ignore everything except unhidden static/dynamic mesh
if (dataDestination->type == null ||
dataDestination->type == bone ||
dataDestination->type == shadowMesh ||
dataDestination->renderFlags == 1)
continue;
tempData->mesh = new std::uint32_t[tempData->meshSize];
for (unsigned int i = 0; i < tempData->meshSize; i += 3)
{
std::uint16_t tempValue[3];
fsMesh.read(reinterpret_cast<char*>(&tempValue[0]), sizeof(std::uint16_t));
fsMesh.read(reinterpret_cast<char*>(&tempValue[1]), sizeof(std::uint16_t));
fsMesh.read(reinterpret_cast<char*>(&tempValue[2]), sizeof(std::uint16_t));
if (!(tempValue[0] >> 15 && tempValue[1] >> 15 && !(tempValue[2] >> 15)))
throw std::invalid_argument("invalid file. go and triangulate!");
tempValue[0] = (std::uint16_t(tempValue[0] << 1) >> 1);
tempValue[1] = (std::uint16_t(tempValue[1] << 1) >> 1);
tempData->mesh[i] = (std::uint32_t)tempValue[0];
tempData->mesh[i + 1] = (std::uint32_t)tempValue[1];
tempData->mesh[i + 2] = (std::uint32_t)tempValue[2];
}
continue;
}*/
/////////////////////////////////////////////////////////////////////////////////////////
/////DEV ZONE
if (!strcmp("STRP", (*it)->name))
{
// don't get null, bone, shadowMesh and hidden mesh indices
@ -450,13 +411,14 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
continue;
// jump to the data section and read the size;
std::uint32_t tempSize;
fsMesh.seekg((*it)->position);
fsMesh.read(reinterpret_cast<char*>(&tempData->meshSize), sizeof(tempData->meshSize));
fsMesh.read(reinterpret_cast<char*>(&tempSize), sizeof(tempSize));
int highBitCount(0);
std::vector<uint32_t>* tempPoly = new std::vector<uint32_t>;
for (unsigned int i = 0; i < tempData->meshSize; i++)
for (unsigned int i = 0; i < tempSize; i++)
{
// ReadData
std::uint16_t tempValue;
@ -504,8 +466,6 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
tempData->meshIndices.erase(tempData->meshIndices.begin());
continue;
}
////////////////////////////////////////////////////////////////////////////////////////
}
dataDestination->segmLst.push_back(tempData);
}
@ -559,16 +519,26 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
if (!strcmp("CMSH", (*it)->name))
{
// jump to the data section and read the size;
std::uint32_t tempSize;
fsMesh.seekg((*it)->position);
fsMesh.read(reinterpret_cast<char*>(&tempData->meshSize), sizeof(tempData->meshSize));
fsMesh.read(reinterpret_cast<char*>(&tempSize), sizeof(tempSize));
tempData->mesh = new std::uint32_t[tempData->meshSize * 3];
std::vector<uint32_t>* tempPoly;
for (unsigned int i = 0; i < tempData->meshSize; i += 3)
// for every triangle..
for (unsigned int i = 0; i < tempSize; i += 3)
{
fsMesh.read(reinterpret_cast<char*>(&tempData->mesh[i]), sizeof(std::uint32_t));
fsMesh.read(reinterpret_cast<char*>(&tempData->mesh[i + 1]), sizeof(std::uint32_t));
fsMesh.read(reinterpret_cast<char*>(&tempData->mesh[i + 2]), sizeof(std::uint32_t));
tempPoly = new std::vector<uint32_t>;
// ..get the 3 indices and save them
for (int j = 0; j < 3; j++)
{
std::uint32_t tempValue;
fsMesh.read(reinterpret_cast<char*>(&tempValue), sizeof(std::uint32_t));
tempPoly->push_back(tempValue);
}
tempData->meshIndices.push_back(tempPoly);
}
continue;
}

View File

@ -120,7 +120,6 @@ void OpenGLController::deleteVectors()
cursor->segmLst.pop_back();
delete segmCuror->uv;
delete segmCuror->mesh; // not used when using vector
delete segmCuror->vertex;
while (!segmCuror->meshIndices.empty())
@ -343,10 +342,10 @@ void OpenGLController::updateScene()
// give the MVP to the shader
glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix(modelIndex)[0][0]);
glDrawArrays(GL_TRIANGLES, instanceOffset, segIt->meshSize);
glDrawArrays(GL_TRIANGLES, instanceOffset, segIt->meshIndices.size() * 3);
// increase the offset
instanceOffset += segIt->meshSize;
instanceOffset += segIt->meshIndices.size() * 3;
}
}
@ -377,39 +376,6 @@ void OpenGLController::loadMsh(const char * path)
// collect vertex data of all models
std::vector<Vertex> tempBufferData;
/*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)
continue;
for (auto& segIt : modIt->segmLst)
{
for (unsigned int i = 0; i < segIt->meshSize; i++)
{
Vertex tempVertex;
tempVertex.position[0] = (GLfloat)segIt->vertex[segIt->mesh[i] * 3];
tempVertex.position[1] = (GLfloat)segIt->vertex[segIt->mesh[i] * 3 + 1];
tempVertex.position[2] = (GLfloat)segIt->vertex[segIt->mesh[i] * 3 + 2];
if (segIt->uv == NULL)
{
tempVertex.uv[0] = 1.0;
tempVertex.uv[1] = 1.0;
}
else
{
tempVertex.uv[0] = (GLfloat)segIt->uv[segIt->mesh[i] * 2];
tempVertex.uv[1] = (GLfloat)segIt->uv[segIt->mesh[i] * 2 + 1];
}
tempBufferData.push_back(tempVertex);
}
}
}*/
/////////////////////////////////////////////////////////////////////////////////////////
/////DEV ZONE
for (auto& modIt : vModels) // for every model chunk
{
for (auto& segIt : modIt->segmLst) // for every cluster
@ -441,7 +407,7 @@ void OpenGLController::loadMsh(const char * path)
}
else if (mshIt->size() > 3) // needs to be triangulated
{
//triangulate;
//TODO: triangulate;
MessageBox(NULL, "Ooops!", "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
}
else // this shouldn't happen (polygon with less then 3 vertex)
@ -453,8 +419,6 @@ void OpenGLController::loadMsh(const char * path)
}
}
}
// think of delete the data from obj here. It's no longer needed
////////////////////////////////////////////////////////////////////////////////////////
// fill the buffer
glBindBuffer(GL_ARRAY_BUFFER, gluiVertexBufferID);

View File

@ -17,7 +17,7 @@ int main(int argc, char** argv)
else
scene = OpenGLController::getInstance();
scene->loadMsh("..\\Release\\Msh\\cubeTex.msh");
scene->loadMsh("..\\Release\\Msh\\cluster.msh");
do {
scene->updateScene();