Update documentation and add loading functions

This commit is contained in:
Rob Loach
2020-12-05 13:58:13 -05:00
parent 6722153c0d
commit acc5abf1ed
27 changed files with 332 additions and 50 deletions

View File

@@ -25,6 +25,9 @@
#ifndef RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
#define RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
#include <vector>
#include <string>
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
#include "./Mesh.hpp"
@@ -40,6 +43,15 @@ class ModelAnimation : public ::ModelAnimation {
Unload();
}
/**
* Load model animations from file
*/
static std::vector<ModelAnimation> Load(const std::string& fileName) {
int count = 0;
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
return std::vector<ModelAnimation>(modelAnimations, modelAnimations + count);
}
GETTERSETTER(int, BoneCount, boneCount)
GETTERSETTER(::BoneInfo*, Bones, bones)
GETTERSETTER(int, FrameCount, frameCount)
@@ -55,23 +67,28 @@ class ModelAnimation : public ::ModelAnimation {
return *this;
}
/**
* Unload animation data
*/
inline void Unload() {
::UnloadModelAnimation(*this);
}
inline ModelAnimation& UpdateAnimation(::Model model, int frame) {
/**
* Update model animation pose
*/
inline ModelAnimation& Update(::Model model, int frame) {
::UpdateModelAnimation(model, *this, frame);
return *this;
}
/**
* Check model animation skeleton match
*/
inline bool IsValid(::Model model) const {
return ::IsModelAnimationValid(model, *this);
}
inline bool IsModelAnimationValid(::Model model) const {
return ::IsModelAnimationValid(model, *this);
}
protected:
inline void set(::ModelAnimation model) {
boneCount = model.boneCount;