66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
#include "Object.h"
|
|
#include <iostream>
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
// public constructor/destructor
|
|
|
|
Object::Object(const char* path)
|
|
{
|
|
// open file
|
|
fsMesh.open(path, std::ios::in | std::ios::binary);
|
|
|
|
if (!fsMesh.is_open())
|
|
throw std::invalid_argument(std::string("file not found: ") += path);
|
|
|
|
// get Chunks
|
|
readChunks();
|
|
|
|
// close file
|
|
fsMesh.close();
|
|
}
|
|
|
|
Object::~Object()
|
|
{
|
|
//delete Chunk list;
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
// private functions
|
|
|
|
void Object::readChunks()
|
|
{
|
|
// Jump into Mesh2
|
|
fsMesh.seekg(16, std::ios_base::cur);
|
|
|
|
do
|
|
{
|
|
chunkHeader* tempHeader = new chunkHeader();
|
|
|
|
fsMesh.read(reinterpret_cast<char*>(&tempHeader->name[0]), sizeof(tempHeader->name) - 1);
|
|
fsMesh.read(reinterpret_cast<char*>(&tempHeader->size), sizeof(tempHeader->size));
|
|
tempHeader->position = fsMesh.tellg();
|
|
|
|
lChunk.push_back(tempHeader);
|
|
|
|
fsMesh.seekg(tempHeader->size, std::ios_base::cur);
|
|
|
|
if (!std::strcmp(tempHeader->name, "CL1L"))
|
|
break;
|
|
} while (!fsMesh.eof());
|
|
|
|
std::cout << "got all chunks, totaly found: " << lChunk.size() << std::endl;
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
// public getter
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
// public functions
|
|
|