diff --git a/SHADE_Engine/src/Animation/SHAnimationSystem.cpp b/SHADE_Engine/src/Animation/SHAnimationSystem.cpp new file mode 100644 index 00000000..28b1a80e --- /dev/null +++ b/SHADE_Engine/src/Animation/SHAnimationSystem.cpp @@ -0,0 +1,20 @@ +/************************************************************************************//*! +\file SHAnimationSystem.cpp +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 20, 2022 +\brief Contains the function definitions of the SHAnimationSystem class. + +Copyright (C) 2022 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. +*//*************************************************************************************/ +// Pre-compiled Header +#include "SHpch.h" +// Primary Include +#include "SHAnimationSystem.h" + +namespace SHADE +{ + +} diff --git a/SHADE_Engine/src/Animation/SHAnimationSystem.h b/SHADE_Engine/src/Animation/SHAnimationSystem.h new file mode 100644 index 00000000..eac839ad --- /dev/null +++ b/SHADE_Engine/src/Animation/SHAnimationSystem.h @@ -0,0 +1,32 @@ +/************************************************************************************//*! +\file SHAnimationSystem.h +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 20, 2022 +\brief Contains the definition of the SHAnimationSystem class and related types. + +Copyright (C) 2022 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 + +// Project Includes +#include "SH_API.h" +#include "ECS_Base/System/SHSystem.h" +#include "ECS_Base/System/SHSystemRoutine.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Forward Declarations */ + /*-----------------------------------------------------------------------------------*/ + + /*-----------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*-----------------------------------------------------------------------------------*/ + class SH_API SHAnimationSystem : public SHSystem + { + + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/Animation/SHAnimatorComponent.cpp b/SHADE_Engine/src/Animation/SHAnimatorComponent.cpp new file mode 100644 index 00000000..271129f1 --- /dev/null +++ b/SHADE_Engine/src/Animation/SHAnimatorComponent.cpp @@ -0,0 +1,28 @@ +/************************************************************************************//*! +\file SHAnimatorComponent.cpp +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 20, 2022 +\brief Contains the definition of functions of the SHRenderable Component class. + +Copyright (C) 2022 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. +*//*************************************************************************************/ +// Pre-compiled Header +#include "SHpch.h" +// Primary Include +#include "SHAnimatorComponent.h" + +namespace SHADE +{ + +} + +RTTR_REGISTRATION +{ + using namespace SHADE; + using namespace rttr; + + registration::class_("Animator Component"); +} \ No newline at end of file diff --git a/SHADE_Engine/src/Animation/SHAnimatorComponent.h b/SHADE_Engine/src/Animation/SHAnimatorComponent.h new file mode 100644 index 00000000..86744aec --- /dev/null +++ b/SHADE_Engine/src/Animation/SHAnimatorComponent.h @@ -0,0 +1,36 @@ +/************************************************************************************//*! +\file SHAnimatorComponent.h +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 20, 2022 +\brief Contains the definition of the SHAnimationSystem class and related types. + +Copyright (C) 2022 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 + +// External Dependencies +#include +// Project Includes +#include "ECS_Base/Components/SHComponent.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Forward Declarations */ + /*-----------------------------------------------------------------------------------*/ + + /*-----------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*-----------------------------------------------------------------------------------*/ + class SH_API SHAnimatorComponent final : public SHComponent + { + private: + /*-------------------------------------------------------------------------------*/ + /* Data Members */ + /*-------------------------------------------------------------------------------*/ + RTTR_ENABLE() + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/Animation/SHRig.cpp b/SHADE_Engine/src/Animation/SHRig.cpp new file mode 100644 index 00000000..0ef2a0e6 --- /dev/null +++ b/SHADE_Engine/src/Animation/SHRig.cpp @@ -0,0 +1,89 @@ +/************************************************************************************//*! +\file SHRig.cpp +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 20, 2022 +\brief Contains the function definitions of the SHRig class. + +Copyright (C) 2022 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. +*//*************************************************************************************/ +// Pre-compiled Header +#include "SHpch.h" +// Primary Header +#include "SHRig.h" +// STL Includes +#include +// Project Headers +#include "Assets/Asset Types/Models/SHRigAsset.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Constructors */ + /*-----------------------------------------------------------------------------------*/ + SHRig::SHRig(const SHRigAsset& asset) + { + // Don't bother if empty + if (asset.root == nullptr) + return; + + // Do a recursive depth first traversal to populate the rig + rootNode = recurseCreateNode(asset, asset.root); + } + + /*-----------------------------------------------------------------------------------*/ + /* Usage Functions */ + /*-----------------------------------------------------------------------------------*/ + const std::string& SHRig::GetName(Handle node) const noexcept + { + static const std::string EMPTY_STRING = ""; + + if (nodeNames.contains(node)) + return nodeNames.at(node); + + return EMPTY_STRING; + } + + Handle SHRig::GetNode(const std::string& name) const noexcept + { + if (nodesByName.contains(name)) + return nodesByName.at(name); + + return {}; + } + + /*-----------------------------------------------------------------------------------*/ + /* Helper Functions */ + /*-----------------------------------------------------------------------------------*/ + Handle SHRig::recurseCreateNode(const SHRigAsset& asset, const RigNode* sourceNode) + { + // Construct the node + auto newNode = nodeStore.Create(); + + // Fill the node with data + const auto& NODE_DATA = asset.nodeDataCollection.at(sourceNode->idRef); + newNode->Transform = NODE_DATA.transform; + + // Populate maps + if (!NODE_DATA.name.empty()) + { + nodeNames.emplace(newNode, NODE_DATA.name); + nodesByName.emplace(NODE_DATA.name, newNode); + } + + // Fill child nodes + for (const auto& child : sourceNode->children) + { + // Ignore nulls + if (child == nullptr) + continue; + + // Recursively create children + newNode->Children.emplace_back(recurseCreateNode(asset, child)); + } + + return newNode; + } +} \ No newline at end of file diff --git a/SHADE_Engine/src/Animation/SHRig.h b/SHADE_Engine/src/Animation/SHRig.h new file mode 100644 index 00000000..39dbe1c4 --- /dev/null +++ b/SHADE_Engine/src/Animation/SHRig.h @@ -0,0 +1,91 @@ +/************************************************************************************//*! +\file SHRig.h +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 20, 2022 +\brief Contains the definition of the SHRig struct and related types. + +Copyright (C) 2022 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 +#include +#include +#include + +// Project Includes +#include "Math/SHMatrix.h" +#include "Resource/SHHandle.h" +#include "Resource/SHResourceLibrary.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Forward Declarations */ + /*-----------------------------------------------------------------------------------*/ + struct SHRigAsset; + struct RigNode; + + /*-----------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*-----------------------------------------------------------------------------------*/ + class SHRig + { + /*---------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*---------------------------------------------------------------------------------*/ + struct Node + { + SHMatrix Transform; + std::vector> Children; + }; + + /*---------------------------------------------------------------------------------*/ + /* Constructors */ + /*---------------------------------------------------------------------------------*/ + /// + /// + /// + /// + explicit SHRig(const SHRigAsset& asset); + + /*---------------------------------------------------------------------------------*/ + /* Usage Functions */ + /*---------------------------------------------------------------------------------*/ + /// + /// Retrieves the name of a node. + /// + /// Node to get the name of. + /// + /// Name of the node. If it does not have a name or is invalid, an empty string will + /// be provided. + /// + const std::string& GetName(Handle node) const noexcept; + /// + /// Retrieves a node via name. + /// + /// Name of the node to retrieve. + /// + /// Node with the specified name. If it does not have a name or is invalid, an empty + /// handle will be provided. + /// + Handle GetNode(const std::string& name) const noexcept; + + private: + /*---------------------------------------------------------------------------------*/ + /* Data Members */ + /*---------------------------------------------------------------------------------*/ + Handle rootNode; + std::unordered_map, std::string> nodeNames; + std::unordered_map> nodesByName; + SHResourceLibrary nodeStore; + + /*---------------------------------------------------------------------------------*/ + /* Helper Functions */ + /*---------------------------------------------------------------------------------*/ + Handle recurseCreateNode(const SHRigAsset& asset, const RigNode* sourceNode); + }; +} \ No newline at end of file