2021-11-12 21:16:43 +01:00
|
|
|
//
|
|
|
|
// Created by martin on 12.11.21.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ANIMTESTBED_ANIMNODE_H
|
|
|
|
#define ANIMTESTBED_ANIMNODE_H
|
|
|
|
|
2021-11-21 12:33:22 +01:00
|
|
|
#include <ozz/base/maths/transform.h>
|
|
|
|
|
2021-11-12 21:16:43 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "AnimationController.h"
|
2021-11-16 18:15:56 +01:00
|
|
|
#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),
|
2021-12-03 15:58:20 +01:00
|
|
|
m_time_current(0.f),
|
2021-11-19 12:40:14 +01:00
|
|
|
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;
|
2021-12-03 15:58:20 +01:00
|
|
|
float m_time_current;
|
2021-11-16 18:15:56 +01:00
|
|
|
SyncTrack m_sync_track;
|
2021-11-12 21:16:43 +01:00
|
|
|
|
2021-12-03 15:58:20 +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.
|
2021-11-19 12:40:14 +01:00
|
|
|
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(
|
2021-11-21 12:33:22 +01:00
|
|
|
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-12 22:12:25 +01:00
|
|
|
|
2021-11-13 00:08:32 +01:00
|
|
|
virtual void DrawDebugUi(){};
|
2021-11-12 21:16:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //ANIMTESTBED_ANIMNODE_H
|