2016-12-30 11:36:05 +00:00
|
|
|
#pragma once
|
|
|
|
#include "..\Header\FileInterface.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct ChunkHeader {
|
|
|
|
char name[5];
|
|
|
|
std::uint32_t size;
|
|
|
|
std::streampos position;
|
|
|
|
};
|
|
|
|
|
2017-01-02 14:07:39 +00:00
|
|
|
enum ModelTyp {
|
|
|
|
null,
|
|
|
|
dynamicMesh,
|
|
|
|
cloth,
|
|
|
|
bone,
|
|
|
|
staticMesh,
|
|
|
|
shadowMesh = 6
|
|
|
|
};
|
2016-12-30 11:36:05 +00:00
|
|
|
|
|
|
|
class MshFile : public FileInterface
|
|
|
|
{
|
|
|
|
public:
|
2017-01-07 14:59:16 +00:00
|
|
|
explicit MshFile(QString path, QObject *parent = Q_NULLPTR);
|
2016-12-30 11:36:05 +00:00
|
|
|
virtual ~MshFile();
|
|
|
|
|
|
|
|
private:
|
2017-01-02 14:07:39 +00:00
|
|
|
ModelTyp m_currentType = ModelTyp::null;
|
|
|
|
std::int32_t m_currentRenderFlag = -1;
|
|
|
|
|
2016-12-30 11:36:05 +00:00
|
|
|
virtual void import() Q_DECL_OVERRIDE Q_DECL_FINAL;
|
|
|
|
|
|
|
|
void loadChunks(std::list<ChunkHeader*> &destination, std::streampos start, const std::uint32_t length);
|
|
|
|
|
|
|
|
void analyseMsh2Chunks(std::list<ChunkHeader*> &chunkList);
|
|
|
|
|
|
|
|
void analyseMatdChunks(std::list<ChunkHeader*> &chunkList);
|
|
|
|
|
|
|
|
void analyseModlChunks(Model* dataDestination, std::list<ChunkHeader*> &chunkList);
|
|
|
|
void analyseGeomChunks(Model* dataDestination, std::list<ChunkHeader*> &chunkList);
|
|
|
|
void analyseSegmChunks(Model* dataDestination, std::list<ChunkHeader*> &chunkList);
|
|
|
|
void analyseClthChunks(Model* dataDestination, std::list<ChunkHeader*> &chunkList);
|
|
|
|
|
|
|
|
void readVertex(Segment* dataDestination, std::streampos position);
|
|
|
|
void readUV(Segment* dataDestination, std::streampos position);
|
2016-12-31 12:04:03 +00:00
|
|
|
|
2017-01-15 11:33:57 +00:00
|
|
|
void loadTexture(QOpenGLTexture*& destination, QString filepath);
|
2017-01-15 11:26:15 +00:00
|
|
|
|
2016-12-31 12:04:03 +00:00
|
|
|
QMatrix4x4 getParentMatrix(std::string parent) const;
|
2017-01-03 13:18:46 +00:00
|
|
|
QQuaternion getParentRotation(std::string parent) const;
|
2016-12-30 11:36:05 +00:00
|
|
|
};
|