1#ifndef RAYLIB_CPP_INCLUDE_MODEL_HPP_
2#define RAYLIB_CPP_INCLUDE_MODEL_HPP_
7#include "./raylib-cpp-utils.hpp"
9#include "./RaylibException.hpp"
21 Model(
const std::string& fileName) {
22 if (!
Load(fileName)) {
42 other.bones =
nullptr;
44 other.materials =
nullptr;
45 other.materialCount = 0;
46 other.meshes =
nullptr;
48 other.bindPose =
nullptr;
51 GETTERSETTER(::Matrix, Transform, transform)
52 GETTERSETTER(
int, MeshCount, meshCount)
53 GETTERSETTER(
int, MaterialCount, materialCount)
54 GETTERSETTER(::
Mesh *, Meshes, meshes)
55 GETTERSETTER(::
Material *, Materials, materials)
56 GETTERSETTER(
int *, MeshMaterial, meshMaterial)
57 GETTERSETTER(
int, BoneCount, boneCount)
58 GETTERSETTER(::BoneInfo *, Bones, bones)
59 GETTERSETTER(::Transform *, BindPoe, bindPose)
76 other.bones =
nullptr;
78 other.materials =
nullptr;
79 other.materialCount = 0;
80 other.meshes =
nullptr;
82 other.bindPose =
nullptr;
91 if (meshes !=
nullptr || materials !=
nullptr) {
102 ::UnloadModelKeepMeshes(*
this);
110 ::SetModelMeshMaterial(
this, meshId, materialId);
118 return ::GetRayCollisionModel(ray, *
this);
125 ::UpdateModelAnimation(*
this, anim, frame);
133 return ::IsModelAnimationValid(*
this, anim);
141 ::Color tint = {255, 255, 255, 255}) {
142 ::DrawModel(*
this, position, scale, tint);
151 ::Vector3 rotationAxis,
152 float rotationAngle = 0.0f,
153 ::Vector3 scale = {1.0f, 1.0f, 1.0f},
154 ::Color tint = {255, 255, 255, 255}) {
155 ::DrawModelEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
164 ::Color tint = {255, 255, 255, 255}) {
165 ::DrawModelWires(*
this, position, scale, tint);
174 ::Vector3 rotationAxis,
175 float rotationAngle = 0.0f,
176 ::Vector3 scale = {1.0f, 1.0f, 1.0f},
177 ::Color tint = {255, 255, 255, 255}) {
178 ::DrawModelWiresEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
186 return ::GetModelBoundingBox(*
this);
193 return ::GetModelBoundingBox(*
this);
200 return meshCount > 0 || materialCount > 0 || boneCount > 0;
208 bool Load(
const std::string& fileName) {
209 set(::LoadModel(fileName.c_str()));
218 bool Load(const ::Mesh& mesh) {
219 set(::LoadModelFromMesh(mesh));
224 inline void set(const ::Model& model) {
225 transform = model.transform;
227 meshCount = model.meshCount;
228 materialCount = model.materialCount;
229 meshes = model.meshes;
230 materials = model.materials;
231 meshMaterial = model.meshMaterial;
233 boneCount = model.boneCount;
235 bindPose = model.bindPose;
Vertex data definning a mesh.
bool IsReady() const
Determines whether or not the Model has data in it.
Model & operator=(const Model &)=delete
void Unload()
Unload model (including meshes) from memory (RAM and/or VRAM)
bool IsModelAnimationValid(const ::ModelAnimation &anim) const
Check model animation skeleton match.
Model & SetMeshMaterial(int meshId, int materialId)
Set material for a mesh.
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 & 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(const ::Model &model)
Model(const ::Mesh &mesh)
Model(const std::string &fileName)
Model(const Model &)=delete
bool Load(const ::Mesh &mesh)
Loads a Model from the given Mesh.
Model & UpdateAnimation(const ::ModelAnimation &anim, int frame)
Update model animation pose.
bool Load(const std::string &fileName)
Loads a Model from the given file.
Model & Draw(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255})
Draw a model (with texture if set)
RayCollision GetCollision(const ::Ray &ray) const
Get collision info between ray and model.
Model & UnloadKeepMeshes()
Unload model (but not meshes) from memory (RAM and/or VRAM)
Model & DrawWires(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255})
Draw a model wires (with texture if set)
Model & operator=(Model &&other) noexcept
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.