OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
Mesh.h
Go to the documentation of this file.
1 
8 #ifndef _MESH_H_
9 #define _MESH_H_
10 
11 #include <vector>
12 
13 #include "system/Shader.h"
14 
16  unsigned int v1, v2, v3, v4; // Vertex list indices
17  unsigned int texture; // Index into object-texture list
18 
19  IndexedRectangle(unsigned int t, unsigned int _v1,
20  unsigned int _v2, unsigned int _v3, unsigned int _v4 = 0)
21  : v1(_v1), v2(_v2), v3(_v3), v4(_v4), texture(t) { }
22 };
23 
25  unsigned int v1, v2, v3, v4, index;
26 
27  IndexedColoredRectangle(unsigned int paletteIndex,
28  unsigned int _v1, unsigned int _v2,
29  unsigned int _v3, unsigned int _v4 = 0)
30  : v1(_v1), v2(_v2), v3(_v3), v4(_v4), index(paletteIndex) { }
31 };
32 
33 // --------------------------------------
34 
35 class Mesh {
36  public:
37  Mesh(const std::vector<glm::vec3>& vertices,
38  const std::vector<IndexedRectangle>& rectangles,
39  const std::vector<IndexedRectangle>& triangles,
40  const std::vector<IndexedColoredRectangle>& coloredRectangles,
41  const std::vector<IndexedColoredRectangle>& coloredTriangles);
42  void prepare();
43  void display(glm::mat4 MVP, ShaderTexture* shaderTexture = nullptr);
44 
45  private:
46  std::vector<unsigned short> indicesBuff;
47  std::vector<glm::vec3> verticesBuff;
48  std::vector<unsigned int> texturesBuff;
49 
50  std::vector<unsigned short> indicesColorBuff;
51  std::vector<glm::vec3> verticesColorBuff;
52  std::vector<unsigned int> colorsBuff;
53 
56 };
57 
58 #endif
59 
unsigned int texture
Definition: Mesh.h:17
Definition: Mesh.h:35
ShaderBuffer vertices
Definition: Mesh.h:54
ShaderBuffer colors
Definition: Mesh.h:55
Mesh(const std::vector< glm::vec3 > &vertices, const std::vector< IndexedRectangle > &rectangles, const std::vector< IndexedRectangle > &triangles, const std::vector< IndexedColoredRectangle > &coloredRectangles, const std::vector< IndexedColoredRectangle > &coloredTriangles)
Definition: Mesh.cpp:12
OpenGL Shader Implementation.
unsigned int v3
Definition: Mesh.h:16
ShaderBuffer uvs
Definition: Mesh.h:54
std::vector< glm::vec3 > verticesColorBuff
Definition: Mesh.h:51
unsigned int v4
Definition: Mesh.h:16
std::vector< unsigned int > colorsBuff
Definition: Mesh.h:52
ShaderBuffer indices
Definition: Mesh.h:54
IndexedRectangle(unsigned int t, unsigned int _v1, unsigned int _v2, unsigned int _v3, unsigned int _v4=0)
Definition: Mesh.h:19
unsigned int v2
Definition: Mesh.h:25
void display(glm::mat4 MVP, ShaderTexture *shaderTexture=nullptr)
Definition: Mesh.cpp:129
IndexedColoredRectangle(unsigned int paletteIndex, unsigned int _v1, unsigned int _v2, unsigned int _v3, unsigned int _v4=0)
Definition: Mesh.h:27
std::vector< unsigned short > indicesColorBuff
Definition: Mesh.h:50
unsigned int v3
Definition: Mesh.h:25
unsigned int v2
Definition: Mesh.h:16
unsigned int v4
Definition: Mesh.h:25
ShaderBuffer verticesColor
Definition: Mesh.h:55
std::vector< unsigned int > texturesBuff
Definition: Mesh.h:48
unsigned int v1
Definition: Mesh.h:25
unsigned int v1
Definition: Mesh.h:16
unsigned int index
Definition: Mesh.h:25
ShaderBuffer indicesColor
Definition: Mesh.h:55
void prepare()
Definition: Mesh.cpp:52
std::vector< glm::vec3 > verticesBuff
Definition: Mesh.h:47
std::vector< unsigned short > indicesBuff
Definition: Mesh.h:46