481256e8ea
texture seams not to open, texture display does not work
72 lines
1.5 KiB
C++
72 lines
1.5 KiB
C++
#pragma once
|
|
#include <fstream>
|
|
#include <vector>
|
|
#include <QMatrix4x4>
|
|
|
|
//TODO: shouldn't be here
|
|
enum ModelTyp {
|
|
null,
|
|
dynamicMesh,
|
|
cloth,
|
|
bone,
|
|
staticMesh,
|
|
shadowMesh = 6
|
|
};
|
|
|
|
struct BoundingBox {
|
|
float quaternion[4];
|
|
float center[3];
|
|
float extents[3];
|
|
};
|
|
|
|
struct Segment {
|
|
std::uint32_t textureIndex = 0;
|
|
float* vertex = nullptr;
|
|
float* uv = nullptr;
|
|
std::vector<std::vector<std::uint32_t>> polyIndices; // indices into vertex array
|
|
};
|
|
|
|
struct Model {
|
|
std::string name = "";
|
|
std::string parent = "";
|
|
ModelTyp type = null; //TODO: should be removed
|
|
std::int32_t renderFlags = -1; //TODO: should be removed
|
|
QMatrix4x4 m4x4Translation;
|
|
std::vector<Segment*> segmList;
|
|
};
|
|
|
|
class FileInterface
|
|
{
|
|
public:
|
|
FileInterface(const char* path)
|
|
: m_vModels(new std::vector<Model*>)
|
|
{
|
|
//open file
|
|
m_fsMesh.open(path, std::ios::in | std::ios::binary);
|
|
|
|
if (!m_fsMesh.is_open())
|
|
throw std::invalid_argument(std::string("file not found: ") += path);
|
|
};
|
|
|
|
virtual ~FileInterface()
|
|
{
|
|
// close file
|
|
m_fsMesh.close();
|
|
|
|
//clean up
|
|
m_vTextureNames.clear();
|
|
};
|
|
|
|
protected:
|
|
std::vector<Model*>* m_vModels;
|
|
std::fstream m_fsMesh;
|
|
std::vector<std::string> m_vTextureNames;
|
|
BoundingBox m_sceneBbox;
|
|
|
|
virtual void import() = 0;
|
|
|
|
public:
|
|
virtual std::vector<Model*>* getModels() const { return m_vModels; };
|
|
virtual std::vector<std::string> getTextureNames() const { return m_vTextureNames; };
|
|
virtual BoundingBox getBoundingBox() const { return m_sceneBbox; };
|
|
}; |