1#ifndef RAYLIB_CPP_INCLUDE_MODEL_HPP_
2#define RAYLIB_CPP_INCLUDE_MODEL_HPP_
7#include "./RaylibException.hpp"
8#include "./raylib-cpp-utils.hpp"
10#include "./raylib-cpp-utils.hpp"
11#include "./Vector3.hpp"
12#include "./BoundingBox.hpp"
13#include "./RaylibException.hpp"
14#include "./RadiansDegrees.hpp"
32 Model(const ::Model& model) : ::Model(model) { }
39 Model(
const std::string_view fileName) {
67 other.materialCount = 0;
68 other.meshes =
nullptr;
69 other.materials =
nullptr;
70 other.meshMaterial =
nullptr;
72 other.bones =
nullptr;
73 other.bindPose =
nullptr;
77 GETTERSETTER(
int, MeshCount, meshCount)
78 GETTERSETTER(
int, MaterialCount, materialCount)
79 GETTERSETTER(::
Mesh*, Meshes, meshes)
80 GETTERSETTER(::
Material*, Materials, materials)
81 GETTERSETTER(
int*, MeshMaterial, meshMaterial)
82 GETTERSETTER(
int, BoneCount, boneCount)
83 GETTERSETTER(::BoneInfo*, Bones, bones)
102 other.materialCount = 0;
103 other.meshes =
nullptr;
104 other.materials =
nullptr;
105 other.meshMaterial =
nullptr;
107 other.bones =
nullptr;
108 other.bindPose =
nullptr;
117 if (meshes !=
nullptr || materials !=
nullptr) {
118 ::UnloadModel(*
this);
128 ::SetModelMeshMaterial(
this, meshId, materialId);
136 ::UpdateModelAnimation(*
this, anim, frame);
144 ::UpdateModelAnimationBones(*
this, anim, frame);
151 [[nodiscard]]
bool IsModelAnimationValid(const ::ModelAnimation& anim)
const { return ::IsModelAnimationValid(*
this, anim); }
156 void Draw(::Vector3 position,
float scale = 1.0f, ::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);
175 void DrawWires(::Vector3 position,
float scale = 1.0f, ::Color tint = {255, 255, 255, 255})
const {
176 ::DrawModelWires(*
this, position, scale, tint);
184 ::Vector3 rotationAxis,
185 Degree rotationAngle = 0.0f,
186 ::Vector3 scale = {1.0f, 1.0f, 1.0f},
187 ::Color tint = {255, 255, 255, 255})
const {
188 ::DrawModelWiresEx(*
this, position, rotationAxis, rotationAngle, scale, tint);
194 void DrawPoints(::Vector3 position,
float scale = 1.0f, ::Color tint = {255, 255, 255, 255}) {
195 ::DrawModelPoints(*
this, position, scale, tint);
219 [[nodiscard]]
bool IsValid()
const { return ::IsModelValid(*
this); }
226 void Load(
const std::string_view fileName) {
227 set(::LoadModel(fileName.data()));
229 throw RaylibException(
"Failed to load Model from " + std::string(fileName));
238 void Load(const ::Mesh& mesh) {
239 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.
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 DrawPoints(::Vector3 position, float scale=1.0f, ::Color tint={255, 255, 255, 255})
Draw a model as points.
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.
Model & UpdateAnimationBones(const ::ModelAnimation &anim, int frame)
Update model animation pose.
bool IsValid() const
Determines whether or not the Model has data in it.
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.
All raylib-cpp classes and functions appear in the raylib namespace.