1
0
Fork 0

Add meshes as classes

This commit is contained in:
Meoweg 2015-11-12 02:30:04 +00:00
parent bb880d6d0b
commit bb587f809c
4 changed files with 40 additions and 8 deletions

19
src/mesh.hpp Normal file
View File

@ -0,0 +1,19 @@
#ifndef _MESH_HPP_
#define _MESH_HPP_
#include "gl.hpp"
#include <vector>
#include <glm/glm.hpp>
class Mesh
{
public:
std::vector<glm::vec3> positions;
std::vector<glm::vec3> normals;
std::vector<GLushort> elements;
};
#endif // _MESH_HPP_

View File

@ -2,6 +2,7 @@
#include "mtllib.hpp"
#include <vector>
#include <fstream>
#include <sstream>

View File

@ -2,16 +2,17 @@
#define _MODEL_HPP_
#include "resource.hpp"
#include "textured_mesh.hpp"
#include "gl.hpp"
#include "material.hpp"
#include <string>
#include <vector>
#include <glm/glm.hpp>
class Model:
public Resource
public Resource,
public TexturedMesh
{
RESOURCE(Model)
@ -19,16 +20,10 @@ public:
void draw() const;
private:
std::vector<glm::vec3> positions;
GLuint positions_id;
std::vector<glm::vec2> tex_coords;
GLuint tex_coords_id;
std::vector<glm::vec3> normals;
GLuint normals_id;
std::vector<GLushort> elements;
GLuint id;
const Material *_material;

17
src/textured_mesh.hpp Normal file
View File

@ -0,0 +1,17 @@
#ifndef _TEXTURED_MESH_HPP_
#define _TEXTURED_MESH_HPP_
#include "mesh.hpp"
#include <vector>
#include <glm/glm.hpp>
class TexturedMesh:
public Mesh
{
public:
std::vector<glm::vec2> tex_coords;
};
#endif // _TEXTURED_MESH_HPP_