handle clustered models
This commit is contained in:
@@ -369,6 +369,8 @@ void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
|
||||
void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
|
||||
{
|
||||
Segment* tempData = new Segment;
|
||||
|
||||
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
|
||||
{
|
||||
/*if (!strcmp("SHDW", (*it)->name))
|
||||
@@ -396,16 +398,16 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
if (vTextures.size() <= tempIndex)
|
||||
{
|
||||
std::cout << "warning texture index <" << tempIndex << "> unknown" << std::endl;
|
||||
dataDestination->texture = "";
|
||||
tempData->texture = "";
|
||||
continue;
|
||||
}
|
||||
dataDestination->texture = vTextures[tempIndex];
|
||||
tempData->texture = vTextures[tempIndex];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp("POSL", (*it)->name))
|
||||
{
|
||||
readVertex(dataDestination, (*it)->position);
|
||||
readVertex(tempData, (*it)->position);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -420,7 +422,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
|
||||
if (!strcmp("UV0L", (*it)->name))
|
||||
{
|
||||
readUV(dataDestination, (*it)->position);
|
||||
readUV(tempData, (*it)->position);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -429,11 +431,11 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
fsMesh.seekg((*it)->position);
|
||||
|
||||
fsMesh.seekg((*it)->position);
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->meshSize), sizeof(dataDestination->meshSize));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempData->meshSize), sizeof(tempData->meshSize));
|
||||
|
||||
dataDestination->mesh = new std::uint32_t[dataDestination->meshSize];
|
||||
tempData->mesh = new std::uint32_t[tempData->meshSize];
|
||||
|
||||
for (unsigned int i = 0; i < dataDestination->meshSize; i += 3)
|
||||
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));
|
||||
@@ -446,18 +448,21 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
tempValue[0] = (std::uint16_t(tempValue[0] << 1) >> 1);
|
||||
tempValue[1] = (std::uint16_t(tempValue[1] << 1) >> 1);
|
||||
|
||||
dataDestination->mesh[i] = (std::uint32_t)tempValue[0];
|
||||
dataDestination->mesh[i + 1] = (std::uint32_t)tempValue[1];
|
||||
dataDestination->mesh[i + 2] = (std::uint32_t)tempValue[2];
|
||||
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;
|
||||
}
|
||||
}
|
||||
dataDestination->segmLst.push_back(tempData);
|
||||
}
|
||||
|
||||
void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>& chunkList)
|
||||
{
|
||||
Segment* tempData = new Segment;
|
||||
|
||||
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
|
||||
{
|
||||
if (!strcmp("CTEX", (*it)->name))
|
||||
@@ -466,42 +471,43 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
char* buffer = new char[(*it)->size];
|
||||
*buffer = { 0 };
|
||||
fsMesh.read(buffer, (*it)->size);
|
||||
dataDestination->texture = buffer;
|
||||
tempData->texture = buffer;
|
||||
delete buffer;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp("CPOS", (*it)->name))
|
||||
{
|
||||
readVertex(dataDestination, (*it)->position);
|
||||
readVertex(tempData, (*it)->position);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp("CUV0", (*it)->name))
|
||||
{
|
||||
readUV(dataDestination, (*it)->position);
|
||||
readUV(tempData, (*it)->position);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp("CMSH", (*it)->name))
|
||||
{
|
||||
fsMesh.seekg((*it)->position);
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->meshSize), sizeof(dataDestination->meshSize));
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempData->meshSize), sizeof(tempData->meshSize));
|
||||
|
||||
dataDestination->mesh = new std::uint32_t[dataDestination->meshSize * 3];
|
||||
tempData->mesh = new std::uint32_t[tempData->meshSize * 3];
|
||||
|
||||
for (unsigned int i = 0; i < dataDestination->meshSize; i += 3)
|
||||
for (unsigned int i = 0; i < tempData->meshSize; i += 3)
|
||||
{
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->mesh[i]), sizeof(std::uint32_t));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->mesh[i + 1]), sizeof(std::uint32_t));
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->mesh[i + 2]), sizeof(std::uint32_t));
|
||||
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));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
dataDestination->segmLst.push_back(tempData);
|
||||
}
|
||||
|
||||
void Object::readVertex(Modl* dataDestination, std::streampos position)
|
||||
void Object::readVertex(Segment* dataDestination, std::streampos position)
|
||||
{
|
||||
std::uint32_t tempSize;
|
||||
fsMesh.seekg(position);
|
||||
@@ -513,7 +519,7 @@ void Object::readVertex(Modl* dataDestination, std::streampos position)
|
||||
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i]), sizeof(float));
|
||||
}
|
||||
|
||||
void Object::readUV(Modl* dataDestination, std::streampos position)
|
||||
void Object::readUV(Segment* dataDestination, std::streampos position)
|
||||
{
|
||||
std::uint32_t tempSize;
|
||||
fsMesh.seekg(position);
|
||||
|
||||
Reference in New Issue
Block a user