couch/core/Mesh.h

54 lines
1.0 KiB
C
Raw Normal View History

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"
#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 SetupSubMesh();
void Draw(Shader *shader);
private:
Id VAO, VBO, EBO;
};
typedef std::vector<SubMesh*> SubMeshList;
class Mesh : public Spatial {
public:
2021-01-13 10:42:57 -06:00
Mesh();
~Mesh();
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);
virtual bool IsDrawable() const {return true;}
2021-01-20 14:54:54 -06:00
virtual void Draw(Shader *shader);
2021-01-13 10:42:57 -06:00
virtual void SetupMesh();
2021-01-20 14:54:54 -06:00
protected:
SubMeshList submeshes;
2021-01-13 10:42:57 -06:00
private:
2021-01-20 14:54:54 -06:00
static SubMesh *aiMesh2SubMesh(aiMesh *mesh);
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 */