1 #ifndef RAYLIB_CPP_INCLUDE_MODEL_HPP_
2 #define RAYLIB_CPP_INCLUDE_MODEL_HPP_
6 #include "./raylib.hpp"
7 #include "./raylib-cpp-utils.hpp"
9 #include "./RaylibException.hpp"
24 Model(const ::Model& model) {
33 Model(
const std::string& fileName) {
42 Model(const ::Mesh& mesh) {
56 other.materialCount = 0;
57 other.meshes =
nullptr;
58 other.materials =
nullptr;
59 other.meshMaterial =
nullptr;
61 other.bones =
nullptr;
62 other.bindPose =
nullptr;
65 GETTERSETTER(::
Matrix, Transform, transform)
66 GETTERSETTER(
int, MeshCount, meshCount)
67 GETTERSETTER(
int, MaterialCount, materialCount)
68 GETTERSETTER(::
Mesh*, Meshes, meshes)
69 GETTERSETTER(::
Material*, Materials, materials)
70 GETTERSETTER(
int*, MeshMaterial, meshMaterial)
71 GETTERSETTER(
int, BoneCount, boneCount)
72 GETTERSETTER(::BoneInfo*, Bones, bones)
73 GETTERSETTER(::Transform*, BindPose, bindPose)
91 other.materialCount = 0;
92 other.meshes =
nullptr;
93 other.materials =
nullptr;
94 other.meshMaterial =
nullptr;
96 other.bones =
nullptr;
97 other.bindPose =
nullptr;
106 if (meshes !=
nullptr || materials !=
nullptr) {
107 ::UnloadModel(*
this);
117 ::UnloadModelKeepMeshes(*
this);
125 ::SetModelMeshMaterial(
this, meshId, materialId);
133 ::UpdateModelAnimation(*
this, anim, frame);
141 return ::IsModelAnimationValid(*
this, anim);
149 ::
Color tint = {255, 255, 255, 255}) {
150 ::DrawModel(*
this, position, scale, tint);
160 float rotationAngle = 0.0f,
161 ::
Vector3 scale = {1.0f, 1.0f, 1.0f},
162 ::Color tint = {255, 255, 255, 255}) {
163 ::DrawModelEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
172 ::
Color tint = {255, 255, 255, 255}) {
173 ::DrawModelWires(*
this, position, scale, tint);
183 float rotationAngle = 0.0f,
184 ::
Vector3 scale = {1.0f, 1.0f, 1.0f},
185 ::Color tint = {255, 255, 255, 255}) {
186 ::DrawModelWiresEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
194 return ::GetModelBoundingBox(*
this);
201 return ::GetModelBoundingBox(*
this);
208 return meshCount > 0 || materialCount > 0 || boneCount > 0;
216 void Load(
const std::string& fileName) {
217 set(::LoadModel(fileName.c_str()));
228 void Load(const ::Mesh& mesh) {
229 set(::LoadModelFromMesh(mesh));
236 void set(const ::Model& model) {
237 transform = model.transform;
239 meshCount = model.meshCount;
240 materialCount = model.materialCount;
241 meshes = model.meshes;
242 materials = model.materials;
243 meshMaterial = model.meshMaterial;
245 boneCount = model.boneCount;
247 bindPose = model.bindPose;
Matrix type (OpenGL style 4x4 - right handed, column major)
Vertex data definning a mesh.
bool IsReady() const
Determines whether or not the Model has data in it.
Model & DrawWires(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255})
Draw a model wires (with texture if set)
void Load(const std::string &fileName)
Loads a Model from the given file.
Model & Draw(::Vector3 position, ::Vector3 rotationAxis, float rotationAngle=0.0f, ::Vector3 scale={1.0f, 1.0f, 1.0f}, ::Color tint={255, 255, 255, 255})
Draw a model with extended parameters.
Model & UnloadKeepMeshes()
Unload model (but not meshes) from memory (RAM and/or VRAM)
void Load(const ::Mesh &mesh)
Loads a Model from the given Mesh.
void Unload()
Unload model (including meshes) from memory (RAM and/or VRAM)
bool IsModelAnimationValid(const ::ModelAnimation &anim) const
Check model animation skeleton match.
Model & UpdateAnimation(const ::ModelAnimation &anim, int frame)
Update model animation pose.
Model & DrawWires(::Vector3 position, ::Vector3 rotationAxis, float rotationAngle=0.0f, ::Vector3 scale={1.0f, 1.0f, 1.0f}, ::Color tint={255, 255, 255, 255})
Draw a model wires (with texture if set) with extended parameters.
Model & Draw(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255})
Draw a model (with texture if set)
Model & SetMeshMaterial(int meshId, int materialId)
Set material for a mesh.
BoundingBox GetBoundingBox() const
Compute model bounding box limits (considers all meshes)
Exception used for most raylib-related exceptions.
All raylib-cpp classes and functions appear in the raylib namespace.