Object.cpp 1.54 KB
Newer Older
1
#include "Object.h"
Anakin's avatar
Anakin committed
2
3
#include <fstream>
#include <iostream>
4
5
6
7
8
9



/////////////////////////////////////////////////////////////////////////
// public constructor/destructor

Anakin's avatar
Anakin committed
10
Object::Object(const char* path)
11
{
Anakin's avatar
Anakin committed
12
13
	// open file
	std::fstream fsMesh(path, std::ios::in | std::ios::binary);
14

Anakin's avatar
Anakin committed
15
16
	if (!fsMesh.is_open())
		throw std::invalid_argument(std::string("file not found: ") += path);
17

Anakin's avatar
Anakin committed
18
	std::uint8_t ui8x4Header[5] = { 0 };
19

Anakin's avatar
Anakin committed
20
21
22
	fsMesh.seekg(4, std::ios_base::cur);
	std::uint32_t ui32FileSize;
	fsMesh.read(reinterpret_cast<char*>(&ui32FileSize), sizeof(ui32FileSize));
23

Anakin's avatar
Anakin committed
24
25
26
	fsMesh.seekg(4, std::ios_base::cur);
	std::uint32_t ui32MshSize;
	fsMesh.read(reinterpret_cast<char*>(&ui32MshSize), sizeof(ui32MshSize));
27

Anakin's avatar
Anakin committed
28
29
	std::cout << "Hedr " << ui32FileSize << std::endl;
	std::cout << "Msh " << ui32MshSize << std::endl;
30
31


Anakin's avatar
Anakin committed
32
33
	do
	{
34

Anakin's avatar
Anakin committed
35
36
37
38
		char tempChunkName[5] = { 0 };
		std::uint32_t tempChunkSize = 0;
		fsMesh.read(reinterpret_cast<char*>(&tempChunkName[0]), sizeof(tempChunkName) - 1);
		fsMesh.read(reinterpret_cast<char*>(&tempChunkSize), sizeof(tempChunkSize));
39

Anakin's avatar
Anakin committed
40
		std::cout << tempChunkName << " " << tempChunkSize << std::endl;
41

Anakin's avatar
Anakin committed
42
		fsMesh.seekg(tempChunkSize, std::ios_base::cur);
43

Anakin's avatar
Anakin committed
44
45
46
47
48
49
		if (!std::strcmp(tempChunkName, "CL1L"))
			break;
	} while (!fsMesh.eof());


	fsMesh.close();
50
51
}

Anakin's avatar
Anakin committed
52
Object::~Object()
53
{
Anakin's avatar
Anakin committed
54
	
55
56
57
58
}


/////////////////////////////////////////////////////////////////////////
Anakin's avatar
Anakin committed
59
// private functions
60
61
62



Anakin's avatar
Anakin committed
63
64
/////////////////////////////////////////////////////////////////////////
// public getter
65
66
67
68
69
70



/////////////////////////////////////////////////////////////////////////
// public functions