diff --git a/MshViewer/Source/Object.cpp b/MshViewer/Source/Object.cpp index 85336eb..a6380b9 100644 --- a/MshViewer/Source/Object.cpp +++ b/MshViewer/Source/Object.cpp @@ -420,11 +420,17 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list& if (!strcmp("STRP", (*it)->name)) { - fsMesh.seekg((*it)->position); - + // jump to the data section and read the size; fsMesh.seekg((*it)->position); fsMesh.read(reinterpret_cast(&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) @@ -447,6 +453,67 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list& continue; } + +///////////////////////////////////////////////////////////////////////////////////////// +/////DEV ZONE + + if (!strcmp("STRP", (*it)->name)) + { + // this needs to be a member + std::vector*> tempVector; + + // jump to the data section and read the size; + fsMesh.seekg((*it)->position); + fsMesh.read(reinterpret_cast(&tempData->meshSize), sizeof(tempData->meshSize)); + + int highBitCount(0); + std::vector* tempPoly = new std::vector; + + for (unsigned int i = 0; i < tempData->meshSize; i++) + { + // ReadData + std::uint16_t tempValue; + fsMesh.read(reinterpret_cast(&tempValue), sizeof(std::uint16_t)); + + // Check for highbit + if (tempValue >> 15) + { + highBitCount++; + tempValue = (std::uint16_t(tempValue << 1) >> 1); + } + + tempPoly->push_back((std::uint32_t)tempValue); + + if (highBitCount == 2) + { + // reset highBitCount + highBitCount == 0; + + // remove the last two values.. + std::uint32_t saveData[2]; + for (int i = 0; i < 2; i++) + { + saveData[0] = tempPoly->back(); + tempPoly->pop_back(); + } + + // ..and save them in the new vector + std::vector* newPointer = new std::vector; + for (int i = 1; i >= 0; i--) + newPointer->push_back(saveData[i]); + + // save the old vector and set the pointer to the new one + tempVector.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); + continue; + } + +//////////////////////////////////////////////////////////////////////////////////////// } dataDestination->segmLst.push_back(tempData); }