raylib-cpp
C++ object-oriented wrapper library for raylib.
ModelAnimation.hpp
1 /*
2 * LICENSE: zlib/libpng
3 *
4 * raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
5 * BSD-like license that allows static linking with closed source software:
6 *
7 * Copyright (c) 2020 Rob Loach (@RobLoach)
8 *
9 * This software is provided "as-is", without any express or implied warranty. In no event
10 * will the authors be held liable for any damages arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose, including commercial
13 * applications, and to alter it and redistribute it freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must not claim that you
16 * wrote the original software. If you use this software in a product, an acknowledgment
17 * in the product documentation would be appreciated but is not required.
18 *
19 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
20 * as being the original software.
21 *
22 * 3. This notice may not be removed or altered from any source distribution.
23 */
24 
25 #ifndef RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
26 #define RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
27 
28 #include <vector>
29 #include <string>
30 
31 #include "./raylib.hpp"
32 #include "./raylib-cpp-utils.hpp"
33 #include "./Mesh.hpp"
34 
35 namespace raylib {
40  public:
41  ModelAnimation(const ::ModelAnimation& model) {
42  set(model);
43  }
44 
46  Unload();
47  }
48 
52  static std::vector<ModelAnimation> Load(const std::string& fileName) {
53  int count = 0;
54  ::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
55  return std::vector<ModelAnimation>(modelAnimations, modelAnimations + count);
56  }
57 
58  GETTERSETTER(int, BoneCount, boneCount)
59  GETTERSETTER(::BoneInfo*, Bones, bones)
60  GETTERSETTER(int, FrameCount, frameCount)
61  GETTERSETTER(::Transform**, FramePoses, framePoses)
62 
63  ModelAnimation& operator=(const ::ModelAnimation& model) {
64  set(model);
65  return *this;
66  }
67 
71  inline void Unload() {
72  ::UnloadModelAnimation(*this);
73  }
74 
78  inline ModelAnimation& Update(const ::Model& model, int frame) {
79  ::UpdateModelAnimation(model, *this, frame);
80  return *this;
81  }
82 
86  inline bool IsValid(const ::Model& model) const {
87  return ::IsModelAnimationValid(model, *this);
88  }
89 
90  protected:
91  inline void set(const ::ModelAnimation& model) {
92  boneCount = model.boneCount;
93  bones = model.bones;
94  frameCount = model.frameCount;
95  framePoses = model.framePoses;
96  }
97 };
98 } // namespace raylib
99 
100 #endif // RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:31
raylib::ModelAnimation::~ModelAnimation
~ModelAnimation()
Definition: ModelAnimation.hpp:45
raylib::ModelAnimation::ModelAnimation
ModelAnimation(const ::ModelAnimation &model)
Definition: ModelAnimation.hpp:41
raylib::ModelAnimation::Update
ModelAnimation & Update(const ::Model &model, int frame)
Update model animation pose.
Definition: ModelAnimation.hpp:78
raylib::ModelAnimation::Load
static std::vector< ModelAnimation > Load(const std::string &fileName)
Load model animations from file.
Definition: ModelAnimation.hpp:52
raylib::ModelAnimation::set
void set(const ::ModelAnimation &model)
Definition: ModelAnimation.hpp:91
raylib::ModelAnimation::Unload
void Unload()
Unload animation data.
Definition: ModelAnimation.hpp:71
raylib::ModelAnimation::IsValid
bool IsValid(const ::Model &model) const
Check model animation skeleton match.
Definition: ModelAnimation.hpp:86
raylib::ModelAnimation
Model animation.
Definition: ModelAnimation.hpp:39