* A Model that is not managed by C++ RAII. * * Make sure to Unload() this if needed, otherwise use raylib::Model. * * @see raylib::Model */
| 17 | * @see raylib::Model |
| 18 | */ |
| 19 | class ModelUnmanaged : public ::Model { |
| 20 | public: |
| 21 | /** |
| 22 | * Default constructor. |
| 23 | */ |
| 24 | ModelUnmanaged() {} |
| 25 | |
| 26 | /** |
| 27 | * Creates a ModelUnmanaged from an existing Model struct. |
| 28 | */ |
| 29 | ModelUnmanaged(const ::Model& model) : ::Model(model) {} |
| 30 | |
| 31 | /** |
| 32 | * Loads a Model from the given file. |
| 33 | * |
| 34 | * @throws raylib::RaylibException Throws if failed to load the Model. |
| 35 | */ |
| 36 | ModelUnmanaged(const std::string& fileName) { Load(fileName); } |
| 37 | |
| 38 | /** |
| 39 | * Loads a Model from the given Mesh. |
| 40 | * |
| 41 | * @throws raylib::RaylibException Throws if failed to load the Model. |
| 42 | */ |
| 43 | ModelUnmanaged(const ::Mesh& mesh) { Load(mesh); } |
| 44 | |
| 45 | GETTERSETTER(::Matrix, Transform, transform) |
| 46 | GETTERSETTER(int, MeshCount, meshCount) |
| 47 | GETTERSETTER(int, MaterialCount, materialCount) |
| 48 | GETTERSETTER(::Mesh*, Meshes, meshes) |
| 49 | GETTERSETTER(::Material*, Materials, materials) |
| 50 | GETTERSETTER(int*, MeshMaterial, meshMaterial) |
| 51 | GETTERSETTER(int, BoneCount, skeleton.boneCount) |
| 52 | GETTERSETTER(::BoneInfo*, Bones, skeleton.bones) |
| 53 | GETTERSETTER(::Transform*, BindPose, skeleton.bindPose) |
| 54 | GETTERSETTER(::ModelAnimPose, CurrentPose, currentPose) |
| 55 | GETTERSETTER(::Matrix*, BoneMatrices, boneMatrices) |
| 56 | |
| 57 | ModelUnmanaged& operator=(const ::Model& model) { |
| 58 | set(model); |
| 59 | return *this; |
| 60 | } |
| 61 | |
| 62 | [[nodiscard]] std::string ToString() const { return TextFormat("Model(meshCount=%d, materialCount=%d)", meshCount, materialCount); } |
| 63 | |
| 64 | operator std::string() const { return ToString(); } |
| 65 | |
| 66 | /** |
| 67 | * Loads a Model from the given file. |
| 68 | * |
| 69 | * @throws raylib::RaylibException Throws if failed to load the Model. |
| 70 | */ |
| 71 | void Load(const std::string& fileName) { |
| 72 | set(::LoadModel(fileName.c_str())); |
| 73 | if (!IsValid()) { |
| 74 | throw RaylibException("Failed to load Model from " + fileName); |
| 75 | } |
| 76 | } |
nothing calls this directly
no outgoing calls
no test coverage detected