Implemented Animation Clip asset and animation controller #410
|
@ -3,7 +3,7 @@
|
||||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
\par email: kahwei.tng\@digipen.edu
|
\par email: kahwei.tng\@digipen.edu
|
||||||
\date Feb 22, 2023
|
\date Feb 22, 2023
|
||||||
\brief Contains the definition of SHAnimationController's functions.
|
\brief Contains the definition of SHAnimationController's functions.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2023 DigiPen Institute of Technology.
|
Copyright (C) 2023 DigiPen Institute of Technology.
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "MenuBar/SHEditorMenuBar.h" //Menu Bar
|
#include "MenuBar/SHEditorMenuBar.h" // Menu Bar
|
||||||
#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel
|
#include "HierarchyPanel/SHHierarchyPanel.h" // Hierarchy Panel
|
||||||
#include "Inspector/SHEditorInspector.h" //Inspector
|
#include "Inspector/SHEditorInspector.h" // Inspector
|
||||||
#include "Profiling/SHEditorProfiler.h" //Profiler
|
#include "Profiling/SHEditorProfiler.h" // Profiler
|
||||||
#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport
|
#include "ViewportWindow/SHEditorViewport.h" // Editor Viewport
|
||||||
#include "AssetBrowser/SHAssetBrowser.h" //Asset Browser
|
#include "AssetBrowser/SHAssetBrowser.h" // Asset Browser
|
||||||
#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
|
|
@ -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();
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace SHADE
|
||||||
/// <returns>True if the header is open, false otherwise.</returns>
|
/// <returns>True if the header is open, false otherwise.</returns>
|
||||||
static bool CollapsingHeader(const std::string& title, bool* isHovered = nullptr);
|
static bool CollapsingHeader(const std::string& title, bool* isHovered = nullptr);
|
||||||
static void SameLine();
|
static void SameLine();
|
||||||
static void Separator();
|
static void Separator();
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Queries */
|
/* ImGui Wrapper Functions - Queries */
|
||||||
|
@ -98,9 +98,9 @@ namespace SHADE
|
||||||
static bool IsItemHovered();
|
static bool IsItemHovered();
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Menu */
|
/* ImGui Wrapper Functions - Menu */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
static bool BeginMenu(const std::string& label);
|
static bool BeginMenu(const std::string& label);
|
||||||
static bool BeginMenu(const std::string& label, const char* icon);
|
static bool BeginMenu(const std::string& label, const char* icon);
|
||||||
static void EndMenu();
|
static void EndMenu();
|
||||||
static void BeginTooltip();
|
static void BeginTooltip();
|
||||||
|
@ -164,8 +164,8 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="title">Text to display.</param>
|
/// <param name="title">Text to display.</param>
|
||||||
/// <returns>True if button was pressed.</returns>
|
/// <returns>True if button was pressed.</returns>
|
||||||
static bool Button(const std::string& title);
|
static bool Button(const std::string& title);
|
||||||
static bool Selectable(const std::string& label);
|
static bool Selectable(const std::string& label);
|
||||||
static bool Selectable(const std::string& label, const char* icon);
|
static bool Selectable(const std::string& label, const char* icon);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a checkbox widget for boolean input.
|
/// Creates a checkbox widget for boolean input.
|
||||||
|
|
Loading…
Reference in New Issue