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) {
31 Model(
const std::string& fileName) {
38 Model(const ::Mesh& mesh) {
51 other.materials =
nullptr;
52 other.materialCount = 0;
53 other.meshes =
nullptr;
55 other.bones =
nullptr;
57 other.bindPose =
nullptr;
60 GETTERSETTER(::
Matrix, Transform, transform)
61 GETTERSETTER(
int, MeshCount, meshCount)
62 GETTERSETTER(
int, MaterialCount, materialCount)
63 GETTERSETTER(::
Mesh*, Meshes, meshes)
64 GETTERSETTER(::
Material*, Materials, materials)
65 GETTERSETTER(
int*, MeshMaterial, meshMaterial)
66 GETTERSETTER(
int, BoneCount, boneCount)
67 GETTERSETTER(::BoneInfo*, Bones, bones)
68 GETTERSETTER(::Transform*, BindPose, bindPose)
85 other.bones =
nullptr;
87 other.materials =
nullptr;
88 other.materialCount = 0;
89 other.meshes =
nullptr;
91 other.bindPose =
nullptr;
100 if (meshes !=
nullptr || materials !=
nullptr) {
101 ::UnloadModel(*
this);
111 ::UnloadModelKeepMeshes(*
this);
119 ::SetModelMeshMaterial(
this, meshId, materialId);
127 return ::GetRayCollisionModel(ray, *
this);
134 ::UpdateModelAnimation(*
this, anim, frame);
142 return ::IsModelAnimationValid(*
this, anim);
150 ::
Color tint = {255, 255, 255, 255}) {
151 ::DrawModel(*
this, position, scale, tint);
161 float rotationAngle = 0.0f,
162 ::
Vector3 scale = {1.0f, 1.0f, 1.0f},
163 ::Color tint = {255, 255, 255, 255}) {
164 ::DrawModelEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
173 ::
Color tint = {255, 255, 255, 255}) {
174 ::DrawModelWires(*
this, position, scale, tint);
184 float rotationAngle = 0.0f,
185 ::
Vector3 scale = {1.0f, 1.0f, 1.0f},
186 ::Color tint = {255, 255, 255, 255}) {
187 ::DrawModelWiresEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
195 return ::GetModelBoundingBox(*
this);
202 return ::GetModelBoundingBox(*
this);
209 return meshCount > 0 || materialCount > 0 || boneCount > 0;
217 bool Load(
const std::string& fileName) {
218 set(::LoadModel(fileName.c_str()));
230 bool Load(const ::Mesh& mesh) {
231 set(::LoadModelFromMesh(mesh));
239 void set(const ::Model& model) {
240 transform = model.transform;
242 meshCount = model.meshCount;
243 materialCount = model.materialCount;
244 meshes = model.meshes;
245 materials = model.materials;
246 meshMaterial = model.meshMaterial;
248 boneCount = model.boneCount;
250 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)
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 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)
bool Load(const ::Mesh &mesh)
Loads a Model from the given Mesh.
bool Load(const std::string &fileName)
Loads a Model from the given file.
Model & SetMeshMaterial(int meshId, int materialId)
Set material for a mesh.
RayCollision GetCollision(const ::Ray &ray) const
Get collision info between ray and model.
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.