Added WIP AnimationControllerEditor

This commit is contained in:
Kah Wei 2023-03-01 23:49:30 +08:00
parent d21f9d6c4b
commit dfb53bf290
7 changed files with 181 additions and 16 deletions

View File

@ -131,6 +131,7 @@ namespace SHADE
/// </summary>
struct Node
{
std::string Name = "Unnamed Node";
Handle<SHAnimationClip> Clip;
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

@ -1,10 +1,11 @@
#pragma once
#include "MenuBar/SHEditorMenuBar.h" //Menu Bar
#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel
#include "Inspector/SHEditorInspector.h" //Inspector
#include "Profiling/SHEditorProfiler.h" //Profiler
#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport
#include "AssetBrowser/SHAssetBrowser.h" //Asset Browser
#include "MaterialInspector/SHMaterialInspector.h" //Material Inspector
#include "ColliderTagPanel/SHColliderTagPanel.h" //Collider Tag Panel
#include "InputBindings/SHInputBindingsPanel.h" //Input Bindings
#include "MenuBar/SHEditorMenuBar.h" // Menu Bar
#include "HierarchyPanel/SHHierarchyPanel.h" // Hierarchy Panel
#include "Inspector/SHEditorInspector.h" // Inspector
#include "Profiling/SHEditorProfiler.h" // Profiler
#include "ViewportWindow/SHEditorViewport.h" // Editor Viewport
#include "AssetBrowser/SHAssetBrowser.h" // Asset Browser
#include "MaterialInspector/SHMaterialInspector.h" // Material Inspector
#include "ColliderTagPanel/SHColliderTagPanel.h" // Collider Tag Panel
#include "InputBindings/SHInputBindingsPanel.h" // Input Bindings
#include "EditorWindow/Animation/SHAnimationControllerEditor.h" // Animation Controller Editor

View File

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