raylib-cpp
C++ object-oriented wrapper library for raylib.
Mesh.hpp
1 #ifndef RAYLIB_CPP_MESH_HPP_
2 #define RAYLIB_CPP_MESH_HPP_
3 
4 #ifdef __cplusplus
5 extern "C"{
6 #endif
7 #include "raylib.h"
8 #ifdef __cplusplus
9 }
10 #endif
11 
12 #include "./raylib-cpp-utils.hpp"
13 
14 #include "./BoundingBox.hpp"
15 #include "./Model.hpp"
16 
17 namespace raylib {
18  class Mesh : public ::Mesh {
19  public:
20  Mesh(::Mesh mesh) {
21  set(mesh);
22  };
23 
24  Mesh(int VertexCount = 0, int TriangleCount = 0) {
25  vertexCount = VertexCount;
26  triangleCount = TriangleCount;
27  };
28 
29  GETTERSETTER(int,VertexCount,vertexCount)
30  GETTERSETTER(int,TriangleCount,triangleCount)
31 
32  Mesh& operator=(const ::Mesh& mesh) {
33  set(mesh);
34  return *this;
35  }
36 
37  Mesh& operator=(const Mesh& mesh) {
38  set(mesh);
39  return *this;
40  }
41 
42  ~Mesh() {
43  Unload();
44  }
45 
46  inline Mesh& Export(const std::string& fileName) {
47  ExportMesh(*this, fileName.c_str());
48  return *this;
49  }
50 
51  inline void Unload() {
52  ::UnloadMesh(*this);
53  }
54 
56  return ::MeshBoundingBox(*this);
57  }
58  operator raylib::BoundingBox() {
59  return BoundingBox();
60  }
61 
62  inline Mesh& Tangents() {
63  ::MeshTangents(this);
64  return *this;
65  }
66 
67  inline Mesh& Binormals() {
68  ::MeshBinormals(this);
69  return *this;
70  }
71 
72  inline Mesh& NormalsSmooth() {
73  ::MeshNormalsSmooth(this);
74  return *this;
75  }
76 
78  return ::LoadModelFromMesh(*this);
79  }
80  operator raylib::Model() {
81  return LoadModelFrom();
82  }
83 
84  protected:
85  inline void set(::Mesh mesh) {
86  vertexCount = mesh.vertexCount;
87  triangleCount = mesh.triangleCount;
88  vertices = mesh.vertices;
89  texcoords = mesh.texcoords;
90  texcoords2 = mesh.texcoords2;
91  normals = mesh.normals;
92  tangents = mesh.tangents;
93  colors = mesh.colors;
94  indices = mesh.indices;
95  animVertices = mesh.animVertices;
96  animNormals = mesh.animNormals;
97  boneIds = mesh.boneIds;
98  boneWeights = mesh.boneWeights;
99  vaoId = mesh.vaoId;
100  vboId = mesh.vboId;
101  }
102  };
103 }
104 
105 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Mesh::set
void set(::Mesh mesh)
Definition: Mesh.hpp:85
raylib::Mesh::NormalsSmooth
Mesh & NormalsSmooth()
Definition: Mesh.hpp:72
raylib::Mesh::Tangents
Mesh & Tangents()
Definition: Mesh.hpp:62
raylib::Mesh::~Mesh
~Mesh()
Definition: Mesh.hpp:42
raylib::Mesh::LoadModelFrom
raylib::Model LoadModelFrom()
Definition: Mesh.hpp:77
raylib::Mesh::BoundingBox
raylib::BoundingBox BoundingBox()
Definition: Mesh.hpp:55
raylib::Mesh::Binormals
Mesh & Binormals()
Definition: Mesh.hpp:67
raylib::Mesh::Unload
void Unload()
Definition: Mesh.hpp:51
raylib::Mesh
Definition: Mesh.hpp:18
raylib::Mesh::operator=
Mesh & operator=(const Mesh &mesh)
Definition: Mesh.hpp:37
raylib::Mesh::Mesh
Mesh(int VertexCount=0, int TriangleCount=0)
Definition: Mesh.hpp:24
raylib::Model
Definition: Model.hpp:16
raylib::BoundingBox
Definition: BoundingBox.hpp:15
raylib::Mesh::Mesh
Mesh(::Mesh mesh)
Definition: Mesh.hpp:20
raylib::Mesh::Export
Mesh & Export(const std::string &fileName)
Definition: Mesh.hpp:46