Level H Engine
Mesh.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "GL/glew.h"
4 #include <string>
5 #include "Primitives.h"
6 #include "../Maths/Vec3.h"
7 
11 class Mesh
12 {
13 public:
14 
19  Mesh(std::string objFileName);
20 
26 
32  Mesh(std::string fileName, bool heightmap);
33 
39  Mesh(std::string objFileName, std::string textureFileName);
40 
47  Mesh(std::string fileName, std::string textureFileName, bool heightmap);
48 
52  ~Mesh();
53 
58  GLuint getVAO();
59 
64  GLuint getTextureID();
65 
70  unsigned int getNumberOfVertices();
71 
76  Vec3 getMaxVert() { return maxVert; }
77 
82  Vec3 getMinVert() { return minVert; }
83 
88  unsigned int getNumIndices() {
89  return numberOfIndices;
90  };
91 
96  bool checkHeightmap() { return heightmap; }
97 
102  bool checkPrimitive() { return primative; }
103 
104 private:
108  GLuint indexBuffer;
111 
113  unsigned int numberOfVertices;
114  unsigned int numberOfIndices;
116  std::string textureFileName;
118  GLuint textureID;
124  bool heightmap;
126  bool primative;
127 
132  void initialiseTexture(std::vector<float> vertexTextures);
133 
138  void initialiseVAO(std::string fileName);
139 
145  GLuint initaliseIndicies(std::vector<unsigned int> &inIndices);
146 
154  GLuint initaliseVBO(unsigned int vecNum, std::vector<float> &inVBOData, int linkNum);
155 
160  void calculateMaxAndMinVerticies(std::vector<float> &vertices);
161 };
Vec3 minVert
The Min Verticies.
Definition: Mesh.h:122
GLuint vertexArrayObject
The Vertex Array Object for use with OpenGL.
Definition: Mesh.h:106
Mesh(std::string objFileName)
Creates a vertex array object using a obj file location and OpenGL.
Definition: Mesh.cpp:46
Creates an object from an text file, this can then be used with OpenGL.
Definition: Mesh.h:11
std::string textureFileName
The name of the texture file.
Definition: Mesh.h:116
bool checkPrimitive()
Checks if it is primative.
Definition: Mesh.h:102
unsigned int numberOfIndices
Definition: Mesh.h:114
GLuint getVAO()
Returns the vertex array object.
Definition: Mesh.cpp:204
void initialiseVAO(std::string fileName)
Initialise the vertex array object.
Definition: Mesh.cpp:102
~Mesh()
Destructs an Object.
Definition: Mesh.cpp:82
Vec3 getMaxVert()
Returns the max vertices.
Definition: Mesh.h:76
GLuint initaliseVBO(unsigned int vecNum, std::vector< float > &inVBOData, int linkNum)
Initialise a vertex array object.
Definition: Mesh.cpp:232
GLuint textureID
The Texture.
Definition: Mesh.h:118
GLuint getTextureID()
Returns the Texture ID.
Definition: Mesh.cpp:210
GLuint indexBuffer
The index buffer.
Definition: Mesh.h:108
bool checkHeightmap()
Checks if it is heightmap.
Definition: Mesh.h:96
unsigned int numberOfVertices
Number of vertices in the model.
Definition: Mesh.h:113
Contains the Vec3 structure with functions and overloaded operators.
Definition: Vec3.h:8
unsigned int getNumIndices()
Returns the number of indices.
Definition: Mesh.h:88
PrimativeType
Definition: Primitives.h:13
bool primative
If the mesh is a primitive.
Definition: Mesh.h:126
GLuint initaliseIndicies(std::vector< unsigned int > &inIndices)
Initialise indices.
Definition: Mesh.cpp:222
GLuint textureBuffer
The texture buffer.
Definition: Mesh.h:110
void calculateMaxAndMinVerticies(std::vector< float > &vertices)
Calculated the maximum and minimum indices.
Definition: Mesh.cpp:250
unsigned int getNumberOfVertices()
Returns the number of vertices.
Definition: Mesh.cpp:216
void initialiseTexture(std::vector< float > vertexTextures)
Initialise the texture.
Definition: Mesh.cpp:160
bool heightmap
If the mesh if is a heightmap.
Definition: Mesh.h:124
Vec3 maxVert
The Max Verticies.
Definition: Mesh.h:120
Vec3 getMinVert()
Returns the min vertices.
Definition: Mesh.h:82