AnimTestbed/src/AnimNode.h

57 lines
1.6 KiB
C
Raw Normal View History

2021-11-12 21:16:43 +01:00
//
// Created by martin on 12.11.21.
//
#ifndef ANIMTESTBED_ANIMNODE_H
#define ANIMTESTBED_ANIMNODE_H
#include <ozz/base/maths/transform.h>
2021-11-12 21:16:43 +01:00
#include <string>
#include "AnimationController.h"
#include "SkinnedMesh.h"
2021-11-12 21:16:43 +01:00
2021-11-13 12:35:23 +01:00
enum class AnimNodeType { Blend, SpeedScale, AnimSampler };
2021-11-12 21:16:43 +01:00
2021-11-13 00:08:32 +01:00
struct AnimNode {
AnimNode(AnimationController* animation_controller)
: m_animation_controller(animation_controller),
m_time_current(0.f),
m_is_time_synced(false) {}
2021-11-13 00:08:32 +01:00
virtual ~AnimNode(){};
AnimNodeType m_anim_node_type;
2021-11-12 21:16:43 +01:00
std::string m_name;
2021-11-13 12:35:23 +01:00
AnimationController* m_animation_controller;
// When synced then current time is relative to the node's anim duration.:w
2021-11-13 00:08:32 +01:00
bool m_is_time_synced;
float m_time_current;
SyncTrack m_sync_track;
2021-11-12 21:16:43 +01:00
virtual void Reset() { m_time_current = 0.f; }
2021-11-13 00:08:32 +01:00
2021-11-13 12:35:23 +01:00
// Mark current node according to is_synced and propagate flag to animation inputs.
2021-11-13 00:08:32 +01:00
virtual void UpdateIsSynced(bool is_synced) = 0;
2021-11-13 12:35:23 +01:00
// Evaluate the animation duration of this node. All input nodes must have already evaluated
// their anim durations.
virtual void UpdateSyncTrack() = 0;
2021-11-12 21:16:43 +01:00
2021-11-13 12:35:23 +01:00
// Evaluate current time and propagate time step to inputs.
virtual void UpdateTime(float dt) = 0;
2021-11-12 21:16:43 +01:00
2021-11-13 12:35:23 +01:00
// Evaluate the current node and write output to local_matrices.
2021-11-13 00:08:32 +01:00
virtual void Evaluate(
ozz::vector<ozz::math::SoaTransform>* local_matrices,
ozz::math::Transform* root_transform) = 0;
2021-11-12 21:16:43 +01:00
2021-11-13 12:35:23 +01:00
// Returns a list of animation nodes that provide input for this node.
virtual void GetInputNodes(std::vector<AnimNode*>& input_nodes) const = 0 ;
2021-11-13 00:08:32 +01:00
virtual void DrawDebugUi(){};
2021-11-12 21:16:43 +01:00
};
#endif //ANIMTESTBED_ANIMNODE_H