Added model loading
This commit is contained in:
parent
707687b682
commit
8c62929e3c
24 changed files with 199852 additions and 23 deletions
43
include/model/mesh.hpp
Normal file
43
include/model/mesh.hpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef MESH_HPP
|
||||
#define MESH_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <core.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <texture.hpp>
|
||||
#include <shader.hpp>
|
||||
#include <vertexArray.hpp>
|
||||
|
||||
namespace oglu
|
||||
{
|
||||
struct OGLU_API Vertex
|
||||
{
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Normal;
|
||||
glm::vec2 UV;
|
||||
};
|
||||
|
||||
class OGLU_API Mesh
|
||||
{
|
||||
public:
|
||||
Mesh(const std::vector<Vertex>& vertices,
|
||||
const std::vector<GLuint>& indices,
|
||||
const std::vector<Texture>& textures);
|
||||
void Render(Shader& shader);
|
||||
|
||||
private:
|
||||
void CreateMesh();
|
||||
|
||||
public:
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<GLuint> indices;
|
||||
std::vector<Texture> textures;
|
||||
|
||||
private:
|
||||
VertexArray VAO;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
32
include/model/model.hpp
Normal file
32
include/model/model.hpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef MODEL_HPP
|
||||
#define MODEL_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <core.hpp>
|
||||
#include <shader.hpp>
|
||||
#include <model/mesh.hpp>
|
||||
|
||||
#include <assimp/scene.h>
|
||||
|
||||
namespace oglu
|
||||
{
|
||||
class OGLU_API Model
|
||||
{
|
||||
public:
|
||||
Model(const std::string& path);
|
||||
void Render(Shader& shader);
|
||||
|
||||
private:
|
||||
std::vector<Texture> loaded;
|
||||
std::vector<Mesh> meshes;
|
||||
std::string directory;
|
||||
|
||||
void LoadModel(const std::string& path);
|
||||
void ProcessNode(aiNode* node, const aiScene* scene);
|
||||
Mesh ProcessMesh(aiMesh* mesh, const aiScene* scene);
|
||||
std::vector<Texture> LoadMaterialTextures(aiMaterial* mat, aiTextureType type, const std::string& typeName);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue