2016-09-06 13:15:29 +00:00
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
2016-09-13 17:48:27 +00:00
|
|
|
#include <list>
|
|
|
|
#include <fstream>
|
2016-10-11 11:41:24 +00:00
|
|
|
#include <string>
|
2016-10-16 10:33:25 +00:00
|
|
|
#include <gl\glew.h>
|
2016-10-11 11:41:24 +00:00
|
|
|
|
2016-10-12 13:55:36 +00:00
|
|
|
enum Mtyp {
|
2016-10-11 11:41:24 +00:00
|
|
|
null,
|
|
|
|
dynamicMesh,
|
|
|
|
cloth,
|
|
|
|
bone,
|
|
|
|
staticMesh,
|
|
|
|
shadowMesh = 6
|
|
|
|
};
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-10-12 13:55:36 +00:00
|
|
|
struct ChunkHeader {
|
2016-09-13 17:48:27 +00:00
|
|
|
char name[5];
|
2016-10-10 10:34:01 +00:00
|
|
|
std::uint32_t size;
|
2016-09-13 17:48:27 +00:00
|
|
|
std::streampos position;
|
|
|
|
};
|
2016-09-12 14:49:05 +00:00
|
|
|
|
2016-10-12 13:55:36 +00:00
|
|
|
struct Modl {
|
2016-10-11 11:41:24 +00:00
|
|
|
std::string name;
|
|
|
|
std::string parent;
|
2016-10-12 13:55:36 +00:00
|
|
|
Mtyp type;
|
2016-10-11 11:41:24 +00:00
|
|
|
std::uint32_t renderFlags;
|
|
|
|
struct {
|
|
|
|
float scale[3];
|
|
|
|
float rotation[4];
|
|
|
|
float translation[3];
|
|
|
|
} tran;
|
|
|
|
struct {
|
|
|
|
std::uint32_t type;
|
|
|
|
float data1;
|
|
|
|
float data2;
|
|
|
|
float data3;
|
|
|
|
} swci;
|
2016-10-16 10:33:25 +00:00
|
|
|
std::string texture;
|
|
|
|
float* vertex;
|
|
|
|
float* uv;
|
|
|
|
std::uint32_t meshSize;
|
|
|
|
std::uint32_t* mesh;
|
2016-10-11 11:41:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-06 13:15:29 +00:00
|
|
|
class Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Object(const char* path);
|
|
|
|
~Object();
|
|
|
|
|
|
|
|
private:
|
2016-09-13 17:48:27 +00:00
|
|
|
|
2016-10-12 13:55:36 +00:00
|
|
|
std::list<ChunkHeader*> lChunkMsh2;
|
|
|
|
std::list<Modl*> lModls;
|
2016-09-13 17:48:27 +00:00
|
|
|
std::fstream fsMesh;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2016-10-16 10:33:25 +00:00
|
|
|
void setModlDefault(Modl* model);
|
2016-10-12 13:55:36 +00:00
|
|
|
void loadChunks(std::list<ChunkHeader*> &destination, std::streampos start, const std::uint32_t end);
|
|
|
|
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-10-16 10:33:25 +00:00
|
|
|
void readVertex(Modl* dataDestination, std::streampos position);
|
|
|
|
void readUV(Modl* dataDestination, std::streampos position);
|
|
|
|
void readMesh(Modl* dataDestination, std::streampos position);
|
|
|
|
|
2016-09-06 13:15:29 +00:00
|
|
|
|
|
|
|
public:
|
2016-10-16 10:33:25 +00:00
|
|
|
std::vector<GLfloat> getVertex() const;
|
|
|
|
std::vector<GLfloat> getUV() const;
|
2016-09-06 13:15:29 +00:00
|
|
|
|
|
|
|
};
|