Implemented Animation Clip asset and animation controller #410

Merged
XiaoQiDigipen merged 66 commits from SP3-22-AnimationController into main 2023-03-09 16:19:40 +08:00
2 changed files with 41 additions and 2 deletions
Showing only changes of commit 97605cc8fe - Show all commits

View File

@ -21,7 +21,7 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes // Project Includes
#include "Editor/IconsMaterialDesign.h" #include "Editor/IconsMaterialDesign.h"
#include "Animation/SHAnimationController.h" #include "Animation/SHAnimationController.h"
#include "../../SHEditorUI.h" #include "Editor/SHEditorUI.h"
namespace SHADE namespace SHADE
{ {
@ -50,10 +50,29 @@ namespace SHADE
ImNodes::BeginNodeEditor(); ImNodes::BeginNodeEditor();
{ {
/* Pre Process Nodes */
std::unordered_map<Handle<SHAnimationController::Node>, int> inputAttribCount;
std::unordered_map<Handle<SHAnimationController::Node>, int> outputAttribCount;
for (auto node : controller.GetNodes())
{
// Have at least one for each
inputAttribCount[node] = 1;
outputAttribCount[node] = 1;
}
for (auto node : controller.GetNodes())
{
for (auto transition : node->Transitions)
{
++inputAttribCount[transition.Target];
}
outputAttribCount[node] += node->Transitions.size();
}
/* Draw Nodes */ /* Draw Nodes */
int id = 0; int id = 0;
for (auto node : controller.GetNodes()) for (auto node : controller.GetNodes())
{ {
// Draw the node
ImNodes::BeginNode(id); ImNodes::BeginNode(id);
{ {
// Title // Title
@ -72,6 +91,26 @@ namespace SHADE
ImGui::PushItemWidth(80.0f); ImGui::PushItemWidth(80.0f);
ImGui::InputText("", buffer.data(), buffer.size()); ImGui::InputText("", buffer.data(), buffer.size());
ImGui::PopItemWidth(); ImGui::PopItemWidth();
// Input Nodes
for (int i = 0; i < inputAttribCount[node]; ++i)
{
NodeAttributeIndex nidx;
nidx.OwnerNodeIndex = id;
nidx.AttributeIndex = i;
ImNodes::BeginInputAttribute(nidx.Raw);
ImNodes::EndInputAttribute();
}
// Output Nodes
for (int i = 0; i < outputAttribCount[node]; ++i)
{
NodeAttributeIndex nidx;
nidx.OwnerNodeIndex = id;
nidx.AttributeIndex = inputAttribCount[node] + i;
ImNodes::BeginOutputAttribute(nidx.Raw);
ImNodes::EndOutputAttribute();
}
} }
ImNodes::EndNode(); ImNodes::EndNode();
++id; ++id;

View File

@ -60,7 +60,7 @@ namespace SHADE
NodeAttributeIndex SourceAttribute; NodeAttributeIndex SourceAttribute;
NodeAttributeIndex DestinationAttribute; NodeAttributeIndex DestinationAttribute;
}; };
}; // What about same source and destination but different link? };
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Data Members */ /* Data Members */