2021-01-13 10:42:57 -06:00
|
|
|
#ifndef MESH_H
|
|
|
|
#define MESH_H
|
|
|
|
|
2021-01-13 16:47:16 -06:00
|
|
|
#include <list>
|
2021-01-20 14:54:54 -06:00
|
|
|
#include <vector>
|
2021-01-18 18:25:47 -06:00
|
|
|
|
2021-01-20 14:54:54 -06:00
|
|
|
// Thirdparty includes
|
2021-01-18 18:25:47 -06:00
|
|
|
#include <assimp/Importer.hpp>
|
|
|
|
#include <assimp/scene.h>
|
|
|
|
#include <assimp/postprocess.h>
|
2021-01-13 16:47:16 -06:00
|
|
|
|
2021-01-13 10:42:57 -06:00
|
|
|
#include "types.h"
|
2021-01-18 18:25:47 -06:00
|
|
|
#include "Util.h"
|
2021-01-14 11:52:01 -06:00
|
|
|
#include "Spatial.h"
|
2021-01-13 10:42:57 -06:00
|
|
|
#include "Vertex.h"
|
|
|
|
#include "Index.h"
|
2021-01-18 13:31:09 -06:00
|
|
|
#include "Material.h"
|
2021-01-13 10:42:57 -06:00
|
|
|
|
2021-01-20 14:54:54 -06:00
|
|
|
#include "Shaders/Shader.h"
|
|
|
|
|
|
|
|
class SubMesh {
|
2021-01-13 10:42:57 -06:00
|
|
|
public:
|
2021-01-20 14:54:54 -06:00
|
|
|
SubMesh();
|
|
|
|
SubMesh(VertexList vertices, IndexList indices);
|
2021-01-13 10:42:57 -06:00
|
|
|
VertexList vertices;
|
|
|
|
IndexList indices;
|
2021-01-20 15:16:44 -06:00
|
|
|
Material material;
|
2021-01-20 14:54:54 -06:00
|
|
|
void Draw(Shader *shader);
|
|
|
|
private:
|
|
|
|
Id VAO, VBO, EBO;
|
2021-01-20 17:05:59 -06:00
|
|
|
void SetupSubMesh();
|
|
|
|
friend class Mesh;
|
2021-01-20 14:54:54 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<SubMesh*> SubMeshList;
|
|
|
|
|
|
|
|
class Mesh : public Spatial {
|
|
|
|
public:
|
2021-01-13 10:42:57 -06:00
|
|
|
Mesh();
|
2021-01-17 14:36:38 -06:00
|
|
|
~Mesh();
|
2021-01-20 20:49:12 -06:00
|
|
|
Material GetMaterial(int submesh);
|
2021-01-20 15:16:44 -06:00
|
|
|
void SetMaterial(int submesh, Material material);
|
2021-01-18 18:25:47 -06:00
|
|
|
static Mesh *FromFile(const char *filename);
|
2021-01-18 13:31:09 -06:00
|
|
|
virtual bool IsDrawable() const {return true;}
|
2021-01-20 14:54:54 -06:00
|
|
|
virtual void Draw(Shader *shader);
|
2021-01-21 15:26:39 -06:00
|
|
|
virtual Name GetType() const;
|
2021-01-23 13:00:08 -06:00
|
|
|
Mesh *Duplicate();
|
2021-01-20 14:54:54 -06:00
|
|
|
protected:
|
|
|
|
SubMeshList submeshes;
|
2021-01-20 17:05:59 -06:00
|
|
|
virtual void SetupMesh();
|
2021-01-13 10:42:57 -06:00
|
|
|
private:
|
2021-01-22 18:44:43 -06:00
|
|
|
static SubMesh *aiMesh2SubMesh(aiMesh *mesh, aiMaterial *material);
|
|
|
|
static Color aiColor3D2Color(aiColor3D aicolor);
|
2021-01-13 10:42:57 -06:00
|
|
|
};
|
|
|
|
|
2021-01-13 16:47:16 -06:00
|
|
|
typedef std::list<Mesh*> MeshList;
|
|
|
|
|
2021-01-13 10:42:57 -06:00
|
|
|
#endif /* MESH_H */
|