37#ifndef SCENE_ANIMATOR_H_
38#define SCENE_ANIMATOR_H_
50 class SceneAnimatorMeshImporter;
76 void release(
bool releaseAnimations);
89 _animations[animationIndex]->playAnimationForward(
true);
95 _animations[animationIndex]->playAnimationForward(
false);
109 _animations[animationIndex]->ticksPerSecond(ticksPerSecond);
116 return _animations[animationIndex]->ticksPerSecond();
124 return _animations[animationIndex]->frameIndexAt(dt);
130 return _animations[animationIndex]->transforms(index);
138 assert(animation !=
nullptr);
147 assert(animation !=
nullptr);
200 return _animations[animationIndex]->transforms(dt).matrices()[bIndex];
272 const size_t animationCount = animations.size();
274 for (
size_t i = 0; i < animationCount; ++i)
static void buildBuffers(SceneAnimator &animator, GFXDevice &gfxDevice)
static void registerAnimations(SceneAnimator &animator, const vector< AnimEvaluator * > &animations)
PASS OWNERSHIP OF ANIMATIONS TO THE ANIMATOR!!!
friend class Divide::Mesh
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
static void UpdateTransforms(Bone *pNode)
U32 frameCount(const U32 animationIndex) const
U8 boneCount() const noexcept
vector< std::unique_ptr< AnimEvaluator > > _animations
A vector that holds each animation.
static I32 CreateSkeleton(Bone *piNode, const mat4< F32 > &parent, vector< Line > &lines)
Create animation skeleton.
const mat4< F32 > & boneTransform(const U32 animationIndex, const D64 dt, const string &bName)
AnimEvaluator & animationByIndex(const U32 animationIndex)
const BoneTransform & transforms(const U32 animationIndex, const U32 index) const
bool init(PlatformContext &context, Bone *skeleton, const vector< Bone * > &bones)
This will build the skeleton based on the scene passed to it and CLEAR EVERYTHING.
void playAnimationBackward(const U32 animationIndex)
const AnimEvaluator & animationByIndex(const U32 animationIndex) const
vector< LineMap > LineCollection
U32 _maximumAnimationFrames
Frame count of the longest registered animation.
AnimEvaluator::FrameIndex frameIndexForTimeStamp(const U32 animationIndex, const D64 dt) const
void calculate(U32 animationIndex, D64 pTime)
void save(PlatformContext &context, ByteBuffer &dataOut) const
Bone * loadSkeleton(ByteBuffer &dataIn, Bone *parent)
const vector< std::unique_ptr< AnimEvaluator > > & animations() const noexcept
void release(bool releaseAnimations)
Frees all memory and initializes everything to a default state.
vector< vector< Line > > _skeletonLinesContainer
const mat4< F32 > & boneTransform(const U32 animationIndex, const D64 dt, const I32 bIndex)
Same as above, except takes the index.
LineCollection _skeletonLines
Bone * boneByName(const string &name) const
const vector< Line > & skeletonLines(U32 animationIndex, D64 dt)
Renders the current skeleton pose at time index dt.
hashMap< U64, U32 > _animationNameToID
find animations quickly
I32 boneIndex(const string &bName) const
void adjustAnimationSpeedTo(const U32 animationIndex, const D64 ticksPerSecond)
This will set the animation speed.
void buildBuffers(GFXDevice &gfxDevice)
void adjustAnimationSpeedBy(const U32 animationIndex, const D64 percent)
U32 animationID(const string &animationName)
void saveSkeleton(ByteBuffer &dataOut, Bone *parent) const
I/O operations.
void playAnimationForward(const U32 animationIndex)
bool hasSkeleton() const noexcept
Lets the caller know if there is a skeleton present.
const mat4< F32 > & boneOffsetTransform(const string &bName)
Get the bone's global transform.
Bone * _skeleton
Root node of the internal scene structure.
U32 getMaxAnimationFrames() const noexcept
Returns the frame count of the longest registered animation.
mat4< F32 > _boneTransformCache
const string & animationName(const U32 animationIndex) const
D64 animationSpeed(const U32 animationIndex) const
Get the animation speed... in ticks per second.
Handle console commands that start with a forward slash.
constexpr U32 to_U32(const T value)
void insert(eastl::vector< T, A1 > &target, const eastl::vector< T, A2 > &source)
void CalculateBoneToWorldTransform(Bone *pInternalNode) noexcept
Calculates the global transformation matrix for the given internal node.
eastl::vector< Type > vector
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
constexpr U64 _ID(const char *const str, const U64 value=val_64_const) noexcept
constexpr U8 to_U8(const T value)