1 #ifndef RAYLIB_CPP_INCLUDE_MESH_HPP_
2 #define RAYLIB_CPP_INCLUDE_MESH_HPP_
7 #include "./raylib.hpp"
8 #include "./raylib-cpp-utils.hpp"
9 #include "./BoundingBox.hpp"
10 #include "./Model.hpp"
18 Mesh(const ::Mesh& mesh) {
22 Mesh(
int vertexCount,
int triangleCount) :
::Mesh{
54 other.vertexCount = 0;
55 other.triangleCount = 0;
56 other.vertices =
nullptr;
57 other.texcoords =
nullptr;
58 other.texcoords2 =
nullptr;
59 other.normals =
nullptr;
60 other.tangents =
nullptr;
61 other.colors =
nullptr;
62 other.indices =
nullptr;
63 other.animVertices =
nullptr;
64 other.animNormals =
nullptr;
65 other.boneIds =
nullptr;
66 other.boneWeights =
nullptr;
68 other.vboId =
nullptr;
74 static ::Mesh
Poly(
int sides,
float radius) {
75 return ::GenMeshPoly(sides, radius);
81 static ::Mesh
Plane(
float width,
float length,
int resX,
int resZ) {
82 return ::GenMeshPlane(width, length, resX, resZ);
88 static ::Mesh
Cube(
float width,
float height,
float length) {
89 return ::GenMeshCube(width, height, length);
95 static ::Mesh
Sphere(
float radius,
int rings,
int slices) {
96 return ::GenMeshSphere(radius, rings, slices);
102 static ::Mesh
HemiSphere(
float radius,
int rings,
int slices) {
103 return ::GenMeshHemiSphere(radius, rings, slices);
109 static ::Mesh
Cylinder(
float radius,
float height,
int slices) {
110 return ::GenMeshCylinder(radius, height, slices);
116 static ::Mesh
Torus(
float radius,
float size,
int radSeg,
int sides) {
117 return ::GenMeshTorus(radius, size, radSeg, sides);
123 static ::Mesh
Knot(
float radius,
float size,
int radSeg,
int sides) {
124 return ::GenMeshKnot(radius, size, radSeg, sides);
131 return ::GenMeshHeightmap(heightmap, size);
138 return ::GenMeshCubicmap(cubicmap, cubeSize);
141 GETTERSETTER(
int, VertexCount, vertexCount)
142 GETTERSETTER(
int, TriangleCount, triangleCount)
143 GETTERSETTER(
float*, Vertices, vertices)
144 GETTERSETTER(
float *, TexCoords, texcoords)
145 GETTERSETTER(
float *, TexCoords2, texcoords2)
146 GETTERSETTER(
float *, Normals, normals)
147 GETTERSETTER(
float *, Tangents, tangents)
148 GETTERSETTER(
unsigned char *, Colors, colors)
149 GETTERSETTER(
unsigned short *, Indices, indices)
150 GETTERSETTER(
float *, AnimVertices, animVertices)
151 GETTERSETTER(
float *, AnimNormals, animNormals)
152 GETTERSETTER(
unsigned char *, BoneIds, boneIds)
153 GETTERSETTER(
float *, BoneWeights, boneWeights)
154 GETTERSETTER(
unsigned int, VaoId, vaoId)
155 GETTERSETTER(
unsigned int *, VboId, vboId)
157 Mesh& operator=(const ::
Mesh& mesh) {
162 Mesh& operator=(
const Mesh&) =
delete;
165 if (
this != &other) {
172 other.vertexCount = 0;
173 other.triangleCount = 0;
174 other.vertices =
nullptr;
175 other.texcoords =
nullptr;
176 other.texcoords2 =
nullptr;
177 other.normals =
nullptr;
178 other.tangents =
nullptr;
179 other.colors =
nullptr;
180 other.indices =
nullptr;
181 other.animVertices =
nullptr;
182 other.animNormals =
nullptr;
183 other.boneIds =
nullptr;
184 other.boneWeights =
nullptr;
186 other.vboId =
nullptr;
198 inline void Upload(
bool dynamic =
false) {
199 ::UploadMesh(
this, dynamic);
205 inline void UpdateBuffer(
int index,
void *data,
int dataSize,
int offset = 0) {
206 ::UpdateMeshBuffer(*
this, index, data, dataSize, offset);
212 inline void Draw(const ::Material& material, const ::Matrix& transform) {
213 ::DrawMesh(*
this, material, transform);
219 inline void Draw(const ::Material& material, ::
Matrix* transforms,
int instances) {
220 ::DrawMeshInstanced(*
this, material, transforms, instances);
226 inline bool Export(
const std::string& fileName) {
228 return ExportMesh(*
this, fileName.c_str());
235 if (vboId !=
nullptr) {
245 return ::GetMeshBoundingBox(*
this);
259 ::GenMeshTangents(
this);
267 ::GenMeshBinormals(
this);
275 return ::LoadModelFromMesh(*
this);
282 return ::LoadModelFromMesh(*
this);
286 inline void set(const ::Mesh& mesh) {
287 vertexCount = mesh.vertexCount;
288 triangleCount = mesh.triangleCount;
289 vertices = mesh.vertices;
290 texcoords = mesh.texcoords;
291 texcoords2 = mesh.texcoords2;
292 normals = mesh.normals;
293 tangents = mesh.tangents;
294 colors = mesh.colors;
295 indices = mesh.indices;
296 animVertices = mesh.animVertices;
297 animNormals = mesh.animNormals;
298 boneIds = mesh.boneIds;
299 boneWeights = mesh.boneWeights;
306 #endif // RAYLIB_CPP_INCLUDE_MESH_HPP_