2016-09-06 15:15:29 +02:00
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
2016-09-13 19:48:27 +02:00
|
|
|
#include <list>
|
|
|
|
#include <fstream>
|
2016-10-11 13:41:24 +02:00
|
|
|
#include <string>
|
2016-10-30 14:22:08 +01:00
|
|
|
#include <glm\gtc\matrix_transform.hpp>
|
2016-10-11 13:41:24 +02:00
|
|
|
|
2016-10-12 15:55:36 +02:00
|
|
|
enum Mtyp {
|
2016-10-11 13:41:24 +02:00
|
|
|
null,
|
|
|
|
dynamicMesh,
|
|
|
|
cloth,
|
|
|
|
bone,
|
|
|
|
staticMesh,
|
|
|
|
shadowMesh = 6
|
|
|
|
};
|
2016-09-06 15:15:29 +02:00
|
|
|
|
2016-10-12 15:55:36 +02:00
|
|
|
struct ChunkHeader {
|
2016-09-13 19:48:27 +02:00
|
|
|
char name[5];
|
2016-10-10 12:34:01 +02:00
|
|
|
std::uint32_t size;
|
2016-09-13 19:48:27 +02:00
|
|
|
std::streampos position;
|
|
|
|
};
|
2016-09-12 16:49:05 +02:00
|
|
|
|
2016-11-13 12:15:33 +01:00
|
|
|
struct Segment {
|
|
|
|
std::string texture = "";
|
|
|
|
float* vertex = nullptr;
|
|
|
|
float* uv = nullptr;
|
|
|
|
std::uint32_t* mesh = nullptr;
|
|
|
|
std::uint32_t meshSize = 0;
|
|
|
|
};
|
|
|
|
|
2016-10-12 15:55:36 +02:00
|
|
|
struct Modl {
|
2016-11-12 12:05:03 +01:00
|
|
|
std::string name = "";
|
|
|
|
std::string parent = "";
|
|
|
|
Mtyp type = null;
|
|
|
|
std::int32_t renderFlags = -1;
|
|
|
|
glm::mat4 m4x4Translation = glm::mat4(1.0f);
|
2016-11-13 12:15:33 +01:00
|
|
|
std::vector<Segment*> segmLst;
|
2016-10-11 13:41:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-06 15:15:29 +02:00
|
|
|
class Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Object(const char* path);
|
|
|
|
~Object();
|
|
|
|
|
|
|
|
private:
|
2016-09-13 19:48:27 +02:00
|
|
|
|
2016-10-30 14:22:08 +01:00
|
|
|
std::vector<Modl*> vModls;
|
2016-09-13 19:48:27 +02:00
|
|
|
std::fstream fsMesh;
|
2016-10-22 13:49:45 +02:00
|
|
|
std::vector<std::string> vTextures;
|
2016-09-13 19:48:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
2016-10-12 15:55:36 +02:00
|
|
|
void loadChunks(std::list<ChunkHeader*> &destination, std::streampos start, const std::uint32_t end);
|
2016-10-21 19:24:30 +02:00
|
|
|
void analyseMsh2Chunks(std::list<ChunkHeader*> &chunkList);
|
2016-10-22 14:05:46 +02:00
|
|
|
void analyseMatdChunks(std::list<ChunkHeader*> &chunkList);
|
2016-10-12 15:55:36 +02:00
|
|
|
void analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
|
|
|
void analyseGeomChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
|
|
|
void analyseSegmChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
|
|
|
void analyseClthChunks(Modl* dataDestination, std::list<ChunkHeader*> &chunkList);
|
2016-11-13 12:15:33 +01:00
|
|
|
void readVertex(Segment* dataDestination, std::streampos position);
|
|
|
|
void readUV(Segment* dataDestination, std::streampos position);
|
2016-10-16 12:33:25 +02:00
|
|
|
|
2016-09-06 15:15:29 +02:00
|
|
|
|
|
|
|
public:
|
2016-10-30 14:22:08 +01:00
|
|
|
std::vector<Modl*> getModels() const;
|
2016-09-06 15:15:29 +02:00
|
|
|
|
|
|
|
};
|