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
|
|
@ -20,6 +20,9 @@
|
|||
#include <lighting/point.hpp>
|
||||
#include <lighting/spotlight.hpp>
|
||||
|
||||
#include <model/mesh.hpp>
|
||||
#include <model/model.hpp>
|
||||
|
||||
namespace oglu
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace oglu
|
|||
*
|
||||
* @return A shared pointer to the texture.
|
||||
*/
|
||||
friend Texture OGLU_API MakeTexture(const char* filename);
|
||||
friend Texture OGLU_API MakeTexture(const char* filename, const std::string& name);
|
||||
|
||||
/**
|
||||
* @brief Copy constructor.
|
||||
|
@ -88,7 +88,11 @@ namespace oglu
|
|||
*
|
||||
* @param[in] vertexShaderFile Filepath to the image file
|
||||
*/
|
||||
AbstractTexture(const char* filename);
|
||||
AbstractTexture(const char* filename, const std::string& name);
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
std::string filepath;
|
||||
|
||||
private:
|
||||
int width; ///< Width of the loaded image
|
||||
|
@ -97,7 +101,7 @@ namespace oglu
|
|||
GLuint texture; ///< OpenGL handle to the texture
|
||||
};
|
||||
|
||||
Texture OGLU_API MakeTexture(const char* filename);
|
||||
Texture OGLU_API MakeTexture(const char* filename, const std::string& name);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue