Added code to evaluate node ordering for spanning tree of blend tree.
parent
1f858d68c0
commit
c659caebb9
|
@ -47,9 +47,9 @@ target_sources(AnimTestbed PRIVATE
|
||||||
src/SkinnedMesh.cc
|
src/SkinnedMesh.cc
|
||||||
src/SkinnedMesh.h
|
src/SkinnedMesh.h
|
||||||
src/AnimNode.cc
|
src/AnimNode.cc
|
||||||
src/AnimSamplerNode.cc
|
src/AnimNodes/AnimSamplerNode.cc
|
||||||
src/SpeedScaleNode.cc
|
src/AnimNodes/SpeedScaleNode.cc
|
||||||
src/BlendNode.cc
|
src/AnimNodes/BlendNode.cc
|
||||||
src/AnimationController.cc
|
src/AnimationController.cc
|
||||||
3rdparty/glfw/deps/glad_gl.c
|
3rdparty/glfw/deps/glad_gl.c
|
||||||
3rdparty/imgui/imgui.cpp
|
3rdparty/imgui/imgui.cpp
|
||||||
|
|
|
@ -28,6 +28,8 @@ struct AnimNode {
|
||||||
|
|
||||||
virtual void Evaluate(ozz::vector<ozz::math::SoaTransform>* local_matrices) = 0;
|
virtual void Evaluate(ozz::vector<ozz::math::SoaTransform>* local_matrices) = 0;
|
||||||
|
|
||||||
|
virtual void CollectNodeOrdering (std::vector<AnimNode*>& anim_nodes) = 0;
|
||||||
|
|
||||||
virtual void DrawDebugUi() {};
|
virtual void DrawDebugUi() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "AnimSamplerNode.h"
|
#include "AnimSamplerNode.h"
|
||||||
#include "SkinnedMesh.h"
|
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include "../SkinnedMesh.h"
|
||||||
|
|
||||||
void AnimSamplerNode::SetAnimation(ozz::animation::Animation* animation) {
|
void AnimSamplerNode::SetAnimation(ozz::animation::Animation* animation) {
|
||||||
m_animation = animation;
|
m_animation = animation;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef ANIMTESTBED_ANIMSAMPLERNODE_H
|
#ifndef ANIMTESTBED_ANIMSAMPLERNODE_H
|
||||||
#define ANIMTESTBED_ANIMSAMPLERNODE_H
|
#define ANIMTESTBED_ANIMSAMPLERNODE_H
|
||||||
|
|
||||||
#include "AnimNode.h"
|
#include "../AnimNode.h"
|
||||||
|
|
||||||
struct AnimSamplerNode : public AnimNode {
|
struct AnimSamplerNode : public AnimNode {
|
||||||
AnimSamplerNode(AnimationController* animation_controller)
|
AnimSamplerNode(AnimationController* animation_controller)
|
||||||
|
@ -33,6 +33,11 @@ struct AnimSamplerNode : public AnimNode {
|
||||||
virtual void Evaluate(
|
virtual void Evaluate(
|
||||||
ozz::vector<ozz::math::SoaTransform>* local_matrices) override;
|
ozz::vector<ozz::math::SoaTransform>* local_matrices) override;
|
||||||
|
|
||||||
|
virtual void CollectNodeOrdering(
|
||||||
|
std::vector<AnimNode*>& anim_nodes) override {
|
||||||
|
anim_nodes.push_back(this);
|
||||||
|
};
|
||||||
|
|
||||||
virtual void DrawDebugUi();
|
virtual void DrawDebugUi();
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
#include "BlendNode.h"
|
#include "BlendNode.h"
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
#include <ozz/animation/runtime/blending_job.h>
|
#include <ozz/animation/runtime/blending_job.h>
|
||||||
|
|
||||||
#include "SkinnedMesh.h"
|
#include "../SkinnedMesh.h"
|
||||||
#include <imgui.h>
|
|
||||||
|
|
||||||
BlendNode::BlendNode(AnimationController* animation_controller)
|
BlendNode::BlendNode(AnimationController* animation_controller)
|
||||||
: AnimNode(animation_controller),
|
: AnimNode(animation_controller),
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef ANIMTESTBED_BLENDNODE_H
|
#ifndef ANIMTESTBED_BLENDNODE_H
|
||||||
#define ANIMTESTBED_BLENDNODE_H
|
#define ANIMTESTBED_BLENDNODE_H
|
||||||
|
|
||||||
#include "AnimNode.h"
|
#include "../AnimNode.h"
|
||||||
|
|
||||||
struct BlendNode : public AnimNode {
|
struct BlendNode : public AnimNode {
|
||||||
BlendNode(AnimationController* animation_controller);
|
BlendNode(AnimationController* animation_controller);
|
||||||
|
@ -30,6 +30,12 @@ struct BlendNode : public AnimNode {
|
||||||
virtual void Evaluate(
|
virtual void Evaluate(
|
||||||
ozz::vector<ozz::math::SoaTransform>* local_matrices) override;
|
ozz::vector<ozz::math::SoaTransform>* local_matrices) override;
|
||||||
|
|
||||||
|
virtual void CollectNodeOrdering (std::vector<AnimNode*>& anim_nodes) override {
|
||||||
|
anim_nodes.push_back(this);
|
||||||
|
m_input_A->CollectNodeOrdering(anim_nodes);
|
||||||
|
m_input_B->CollectNodeOrdering(anim_nodes);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void DrawDebugUi();
|
virtual void DrawDebugUi();
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef ANIMTESTBED_SPEEDSCALENODE_H
|
#ifndef ANIMTESTBED_SPEEDSCALENODE_H
|
||||||
#define ANIMTESTBED_SPEEDSCALENODE_H
|
#define ANIMTESTBED_SPEEDSCALENODE_H
|
||||||
|
|
||||||
#include "AnimNode.h"
|
#include "../AnimNode.h"
|
||||||
|
|
||||||
struct SpeedScaleNode : public AnimNode {
|
struct SpeedScaleNode : public AnimNode {
|
||||||
SpeedScaleNode(AnimationController* animation_controller): AnimNode (animation_controller), m_time_scale(1.f) {}
|
SpeedScaleNode(AnimationController* animation_controller): AnimNode (animation_controller), m_time_scale(1.f) {}
|
||||||
|
@ -26,6 +26,11 @@ struct SpeedScaleNode : public AnimNode {
|
||||||
m_input_node->Evaluate(local_matrices);
|
m_input_node->Evaluate(local_matrices);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual void CollectNodeOrdering (std::vector<AnimNode*>& anim_nodes) override {
|
||||||
|
anim_nodes.push_back(this);
|
||||||
|
m_input_node->CollectNodeOrdering(anim_nodes);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void DrawDebugUi() override;
|
virtual void DrawDebugUi() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
#include <ozz/animation/runtime/local_to_model_job.h>
|
#include <ozz/animation/runtime/local_to_model_job.h>
|
||||||
#include <ozz/animation/runtime/sampling_job.h>
|
#include <ozz/animation/runtime/sampling_job.h>
|
||||||
|
|
||||||
#include "AnimSamplerNode.h"
|
#include "AnimNodes/AnimSamplerNode.h"
|
||||||
#include "BlendNode.h"
|
#include "AnimNodes/BlendNode.h"
|
||||||
|
#include "AnimNodes/SpeedScaleNode.h"
|
||||||
#include "SkinnedMesh.h"
|
#include "SkinnedMesh.h"
|
||||||
#include "SpeedScaleNode.h"
|
|
||||||
|
|
||||||
AnimationController::AnimationController(SkinnedMesh* skinned_mesh)
|
AnimationController::AnimationController(SkinnedMesh* skinned_mesh)
|
||||||
: m_current_time(0.f), m_skinned_mesh(skinned_mesh) {
|
: m_current_time(0.f), m_skinned_mesh(skinned_mesh) {
|
||||||
|
@ -49,6 +49,10 @@ AnimationController::AnimationController(SkinnedMesh* skinned_mesh)
|
||||||
m_anim_nodes.push_back(blend_node);
|
m_anim_nodes.push_back(blend_node);
|
||||||
|
|
||||||
m_output_node = blend_node;
|
m_output_node = blend_node;
|
||||||
|
|
||||||
|
m_output_node->CollectNodeOrdering(m_ordered_nodes);
|
||||||
|
|
||||||
|
std::cout << "Have " << m_ordered_nodes.size() << " nodes in blend tree." << std::endl;
|
||||||
m_output_node->Reset();
|
m_output_node->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,5 +103,13 @@ void AnimationController::DrawDebugUi() {
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_output_node && ImGui::TreeNode("Nodes")) {
|
||||||
|
for (int i = 0; i < m_ordered_nodes.size(); i++) {
|
||||||
|
ImGui::Text(m_ordered_nodes[i]->m_name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
|
@ -44,6 +44,7 @@ struct AnimationController {
|
||||||
AnimNode* m_output_node;
|
AnimNode* m_output_node;
|
||||||
|
|
||||||
std::vector<AnimNode*> m_anim_nodes;
|
std::vector<AnimNode*> m_anim_nodes;
|
||||||
|
std::vector<AnimNode*> m_ordered_nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //ANIMTESTBED_ANIMATIONCONTROLLER_H
|
#endif //ANIMTESTBED_ANIMATIONCONTROLLER_H
|
||||||
|
|
Loading…
Reference in New Issue