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})
const {
150 ::DrawModel(*
this, position, scale, tint);
159 float rotationAngle = 0.0f,
160 ::
Vector3 scale = {1.0f, 1.0f, 1.0f},
161 ::Color tint = {255, 255, 255, 255})
const {
162 ::DrawModelEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
170 ::
Color tint = {255, 255, 255, 255})
const {
171 ::DrawModelWires(*
this, position, scale, tint);
180 float rotationAngle = 0.0f,
181 ::
Vector3 scale = {1.0f, 1.0f, 1.0f},
182 ::Color tint = {255, 255, 255, 255})
const {
183 ::DrawModelWiresEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
190 return ::GetModelBoundingBox(*
this);
197 return ::GetModelBoundingBox(*
this);
204 return meshCount > 0 || materialCount > 0 || boneCount > 0;
212 void Load(
const std::string& fileName) {
213 set(::LoadModel(fileName.c_str()));
224 void Load(const ::Mesh& mesh) {
225 set(::LoadModelFromMesh(mesh));
232 void set(const ::Model& model) {
233 transform = model.transform;
235 meshCount = model.meshCount;
236 materialCount = model.materialCount;
237 meshes = model.meshes;
238 materials = model.materials;
239 meshMaterial = model.meshMaterial;
241 boneCount = model.boneCount;
243 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.
void Load(const std::string &fileName)
Loads a Model from the given file.
Model & UnloadKeepMeshes()
Unload model (but not meshes) from memory (RAM and/or VRAM)
void Draw(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255}) const
Draw a model (with texture if set)
void Draw(::Vector3 position, ::Vector3 rotationAxis, float rotationAngle=0.0f, ::Vector3 scale={1.0f, 1.0f, 1.0f}, ::Color tint={255, 255, 255, 255}) const
Draw a model with extended parameters.
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.
void DrawWires(::Vector3 position, ::Vector3 rotationAxis, float rotationAngle=0.0f, ::Vector3 scale={1.0f, 1.0f, 1.0f}, ::Color tint={255, 255, 255, 255}) const
Draw a model wires (with texture if set) with extended parameters.
Model & UpdateAnimation(const ::ModelAnimation &anim, int frame)
Update model animation pose.
Model & SetMeshMaterial(int meshId, int materialId)
Set material for a mesh.
void DrawWires(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255}) const
Draw a model wires (with texture if set)
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.