1#ifndef RAYLIB_CPP_INCLUDE_MODEL_HPP_
2#define RAYLIB_CPP_INCLUDE_MODEL_HPP_
8#include "./raylib-cpp-utils.hpp"
9#include "./Vector3.hpp"
10#include "./BoundingBox.hpp"
11#include "./RaylibException.hpp"
12#include "./RadiansDegrees.hpp"
30 Model(const ::Model& model) {
39 Model(
const std::string_view fileName) {
48 Model(const ::Mesh& mesh) {
71 other.materialCount = 0;
72 other.meshes =
nullptr;
73 other.materials =
nullptr;
74 other.meshMaterial =
nullptr;
76 other.bones =
nullptr;
77 other.bindPose =
nullptr;
81 GETTERSETTER(
int, MeshCount, meshCount)
82 GETTERSETTER(
int, MaterialCount, materialCount)
83 GETTERSETTER(::
Mesh*, Meshes, meshes)
84 GETTERSETTER(::
Material*, Materials, materials)
85 GETTERSETTER(
int*, MeshMaterial, meshMaterial)
86 GETTERSETTER(
int, BoneCount, boneCount)
87 GETTERSETTER(::BoneInfo*, Bones, bones)
106 other.materialCount = 0;
107 other.meshes =
nullptr;
108 other.materials =
nullptr;
109 other.meshMaterial =
nullptr;
111 other.bones =
nullptr;
112 other.bindPose =
nullptr;
121 if (meshes !=
nullptr || materials !=
nullptr) {
122 ::UnloadModel(*
this);
132 ::SetModelMeshMaterial(
this, meshId, materialId);
140 ::UpdateModelAnimation(*
this, anim, frame);
148 return ::IsModelAnimationValid(*
this, anim);
156 ::Color tint = {255, 255, 255, 255})
const {
157 ::DrawModel(*
this, position, scale, tint);
165 ::Vector3 rotationAxis,
166 Degree rotationAngle = 0.0f,
167 ::Vector3 scale = {1.0f, 1.0f, 1.0f},
168 ::Color tint = {255, 255, 255, 255})
const {
169 ::DrawModelEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
177 ::Color tint = {255, 255, 255, 255})
const {
178 ::DrawModelWires(*
this, position, scale, tint);
186 ::Vector3 rotationAxis,
187 Degree rotationAngle = 0.0f,
188 ::Vector3 scale = {1.0f, 1.0f, 1.0f},
189 ::Color tint = {255, 255, 255, 255})
const {
190 ::DrawModelWiresEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
197 return ::GetModelBoundingBox(*
this);
217 return ::IsModelReady(*
this);
225 void Load(
const std::string_view fileName) {
226 set(::LoadModel(fileName.data()));
228 throw RaylibException(
"Failed to load Model from " + std::string(fileName));
237 void Load(const ::Mesh& mesh) {
238 set(::LoadModelFromMesh(mesh));
245 void set(const ::Model& model) {
246 transform = model.transform;
248 meshCount = model.meshCount;
249 materialCount = model.materialCount;
250 meshes = model.meshes;
251 materials = model.materials;
252 meshMaterial = model.meshMaterial;
254 boneCount = model.boneCount;
256 bindPose = model.bindPose;
Degree type (allows automatic worry free conversion between radians and degrees)
Matrix type (OpenGL style 4x4 - right handed, column major)
Vertex data defining a mesh.
bool IsReady() const
Determines whether or not the Model has data in it.
void Draw(::Vector3 position, ::Vector3 rotationAxis, Degree 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 Draw(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255}) const
Draw a model (with texture if set)
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 & SetMeshMaterial(int meshId, int materialId)
Set material for a mesh.
BoundingBox GetTransformedBoundingBox() const
Compute model bounding box limits with respect to the Model's transformation (considers all meshes) T...
void Load(const std::string_view fileName)
Loads a Model from the given file.
void DrawWires(::Vector3 position, ::Vector3 rotationAxis, Degree 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.
void DrawWires(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255}) const
Draw a model wires (with texture if set)
Model(const raylib::Mesh &mesh)=delete
The Model constructor with a Mesh() is removed.
BoundingBox GetBoundingBox() const
Compute model bounding box limits (considers all meshes)
Exception used for most raylib-related exceptions.