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
7 changed files with 181 additions and 16 deletions
Showing only changes of commit dfb53bf290 - Show all commits

View File

@ -131,6 +131,7 @@ namespace SHADE
/// </summary> /// </summary>
struct Node struct Node
{ {
std::string Name = "Unnamed Node";
Handle<SHAnimationClip> Clip; Handle<SHAnimationClip> Clip;
std::vector<Transition> Transitions; std::vector<Transition> Transitions;
}; };

View File

@ -0,0 +1,107 @@
/************************************************************************************//*!
\file SHAnimationControllerEditor.cpp
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Mar 1, 2023
\brief Contains the definition of SHAnimationControllerEditor's functions.
Copyright (C) 2023 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#include "SHpch.h"
#include "SHAnimationControllerEditor.h"
// STL Includes
#include <format>
// External Dependencies
#include <imgui.h>
#include <imnodes.h>
// Project Includes
#include "Editor/IconsMaterialDesign.h"
#include "Animation/SHAnimationController.h"
#include "../../SHEditorUI.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Cosntructors/Destructors */
/*-----------------------------------------------------------------------------------*/
SHAnimationControllerEditor::SHAnimationControllerEditor()
: SHEditorWindow("Animation Controller Editor", ImGuiWindowFlags_MenuBar)
{}
/*-----------------------------------------------------------------------------------*/
/* Lifecycle Functions */
/*-----------------------------------------------------------------------------------*/
void SHAnimationControllerEditor::Init()
{
SHEditorWindow::Init();
}
void SHAnimationControllerEditor::Update()
{
SHEditorWindow::Update();
if (Begin())
{
drawMenuBar();
ImNodes::BeginNodeEditor();
{
/* Draw Nodes */
int id = 0;
for (auto node : controller.GetNodes())
{
ImNodes::BeginNode(id);
{
// Title
ImNodes::BeginNodeTitleBar();
{
ImGui::TextUnformatted(node->Name.c_str());
ImGui::SameLine();
ImGui::Button(ICON_MD_EDIT);
}
ImNodes::EndNodeTitleBar();
// Body
ImGui::Text("Clip");
ImGui::SameLine();
std::array<char, 255> buffer = { '\0' };
ImGui::PushItemWidth(80.0f);
ImGui::InputText("", buffer.data(), buffer.size());
ImGui::PopItemWidth();
}
ImNodes::EndNode();
++id;
}
}
ImNodes::MiniMap(0.2f, ImNodesMiniMapLocation_BottomRight);
ImNodes::EndNodeEditor();
}
ImGui::End();
}
void SHAnimationControllerEditor::Exit()
{
SHEditorWindow::Exit();
}
/*-----------------------------------------------------------------------------------*/
/* Helper Functions */
/*-----------------------------------------------------------------------------------*/
void SHAnimationControllerEditor::drawMenuBar()
{
if (ImGui::BeginMenuBar())
{
if (ImGui::Button(std::format("{} Add", ICON_MD_ADD).data()))
{
controller.CreateNode();
}
ImGui::EndMenuBar();
}
}
}

View File

@ -0,0 +1,49 @@
/************************************************************************************//*!
\file SHAnimationControllerEditor.h
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Mar 1, 2023
\brief Contains the definition of SHAnimationControllerEditor.
Copyright (C) 2023 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
// STL Includes
// Project Includes
#include "Resource/SHHandle.h"
#include "Editor/EditorWindow/SHEditorWindow.h"
#include "Animation/SHAnimationController.h"
namespace SHADE
{
class SHAnimationControllerEditor final : public SHEditorWindow
{
public:
/*---------------------------------------------------------------------------------*/
/* Constructors/Destructors */
/*---------------------------------------------------------------------------------*/
SHAnimationControllerEditor();
~SHAnimationControllerEditor() = default;
/*---------------------------------------------------------------------------------*/
/* Lifecycle Functions */
/*---------------------------------------------------------------------------------*/
void Init() override;
void Update() override;
void Exit() override;
private:
/*---------------------------------------------------------------------------------*/
/* Data Members */
/*---------------------------------------------------------------------------------*/
SHAnimationController controller;
/*---------------------------------------------------------------------------------*/
/* Helper Functions */
/*---------------------------------------------------------------------------------*/
void drawMenuBar();
};
}

View File

@ -8,3 +8,4 @@
#include "MaterialInspector/SHMaterialInspector.h" // Material Inspector #include "MaterialInspector/SHMaterialInspector.h" // Material Inspector
#include "ColliderTagPanel/SHColliderTagPanel.h" // Collider Tag Panel #include "ColliderTagPanel/SHColliderTagPanel.h" // Collider Tag Panel
#include "InputBindings/SHInputBindingsPanel.h" // Input Bindings #include "InputBindings/SHInputBindingsPanel.h" // Input Bindings
#include "EditorWindow/Animation/SHAnimationControllerEditor.h" // Animation Controller Editor

View File

@ -39,6 +39,7 @@
//|| Library Includes || //|| Library Includes ||
//#==============================================================# //#==============================================================#
#include <imgui.h> #include <imgui.h>
#include <imnodes.h>
#include <SDL.h> #include <SDL.h>
#include <rttr/registration> #include <rttr/registration>
#include <ImGuizmo.h> #include <ImGuizmo.h>
@ -96,6 +97,10 @@ namespace SHADE
SHLOG_CRITICAL("Failed to create ImGui Context") SHLOG_CRITICAL("Failed to create ImGui Context")
} }
} }
if (ImNodes::CreateContext() == nullptr)
{
SHLOG_CRITICAL("Failed to create ImNodes Context")
}
#ifdef SHEDITOR #ifdef SHEDITOR
editorConfig = &SHConfigurationManager::LoadEditorConfig(); editorConfig = &SHConfigurationManager::LoadEditorConfig();
@ -112,6 +117,7 @@ namespace SHADE
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>(); SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>(); SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHAnimationControllerEditor>();
//Add popup windows //Add popup windows
SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>(); SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>();
@ -339,6 +345,7 @@ namespace SHADE
{ {
window->Init(); window->Init();
} }
ImNodes::DestroyContext();
ImGui_ImplVulkan_Shutdown(); ImGui_ImplVulkan_Shutdown();
ImGui_ImplSDL2_Shutdown(); ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext(); ImGui::DestroyContext();