Implemented Animation Clip asset and animation controller #410
|
@ -181,7 +181,7 @@ namespace Sandbox
|
||||||
// Link up SHDebugDraw
|
// Link up SHDebugDraw
|
||||||
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
|
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
|
||||||
|
|
||||||
auto clip = SHResourceManager::LoadOrGet<SHAnimationData>(77816045);
|
auto clip = SHResourceManager::LoadOrGet<SHRawAnimation>(77816045);
|
||||||
auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
|
auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Project Includes
|
// Project Includes
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
#include "Resource/SHHandle.h"
|
#include "Resource/SHHandle.h"
|
||||||
#include "SHAnimationData.h"
|
#include "SHRawAnimation.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct Node
|
struct Node
|
||||||
{
|
{
|
||||||
Handle<SHAnimationData> Clip;
|
Handle<SHRawAnimation> Clip;
|
||||||
std::vector<Transition> Transitions;
|
std::vector<Transition> Transitions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Project Includes
|
// Project Includes
|
||||||
#include "SHRig.h"
|
#include "SHRig.h"
|
||||||
#include "Math/SHMatrix.h"
|
#include "Math/SHMatrix.h"
|
||||||
#include "SHAnimationData.h"
|
#include "SHRawAnimation.h"
|
||||||
#include "Graphics/SHVkUtil.h"
|
#include "Graphics/SHVkUtil.h"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
@ -37,14 +37,14 @@ namespace SHADE
|
||||||
playOnce = false;
|
playOnce = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHAnimatorComponent::Play(Handle<SHAnimationData> clip)
|
void SHAnimatorComponent::Play(Handle<SHRawAnimation> clip)
|
||||||
{
|
{
|
||||||
currClip = clip;
|
currClip = clip;
|
||||||
currPlaybackTime = 0.0f;
|
currPlaybackTime = 0.0f;
|
||||||
Play();
|
Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHAnimatorComponent::PlayOneShot(Handle<SHAnimationData> clip)
|
void SHAnimatorComponent::PlayOneShot(Handle<SHRawAnimation> clip)
|
||||||
{
|
{
|
||||||
Play(clip);
|
Play(clip);
|
||||||
playOnce = true;
|
playOnce = true;
|
||||||
|
@ -86,7 +86,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHAnimatorComponent::SetClip(Handle<SHAnimationData> newClip)
|
void SHAnimatorComponent::SetClip(Handle<SHRawAnimation> newClip)
|
||||||
{
|
{
|
||||||
// No change
|
// No change
|
||||||
if (currClip == newClip)
|
if (currClip == newClip)
|
||||||
|
|
|
@ -22,7 +22,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Math/SHMatrix.h"
|
#include "Math/SHMatrix.h"
|
||||||
#include "Math/Vector/SHVec3.h"
|
#include "Math/Vector/SHVec3.h"
|
||||||
#include "Math/SHQuaternion.h"
|
#include "Math/SHQuaternion.h"
|
||||||
#include "SHAnimationData.h"
|
#include "SHRawAnimation.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
class SHRig;
|
class SHRig;
|
||||||
struct SHRigNode;
|
struct SHRigNode;
|
||||||
class SHAnimationData;
|
class SHRawAnimation;
|
||||||
class SHVkBuffer;
|
class SHVkBuffer;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -55,12 +55,12 @@ namespace SHADE
|
||||||
/// Plays the specified animation clip from the start.
|
/// Plays the specified animation clip from the start.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clip">Animation clip to play.</param>
|
/// <param name="clip">Animation clip to play.</param>
|
||||||
void Play(Handle<SHAnimationData> clip);
|
void Play(Handle<SHRawAnimation> clip);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plays the specified animation clip from the start one time only.
|
/// Plays the specified animation clip from the start one time only.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clip">Animation clip to play.</param>
|
/// <param name="clip">Animation clip to play.</param>
|
||||||
void PlayOneShot(Handle<SHAnimationData> clip);
|
void PlayOneShot(Handle<SHRawAnimation> clip);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plays the currently loaded animation clip from the start.
|
/// Plays the currently loaded animation clip from the start.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -88,7 +88,7 @@ namespace SHADE
|
||||||
/// If the clip is the same as the current clip, nothing happens.
|
/// If the clip is the same as the current clip, nothing happens.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="newClip">Clip to use.</param>
|
/// <param name="newClip">Clip to use.</param>
|
||||||
void SetClip(Handle<SHAnimationData> newClip);
|
void SetClip(Handle<SHRawAnimation> newClip);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Getter Functions */
|
/* Getter Functions */
|
||||||
|
@ -108,7 +108,7 @@ namespace SHADE
|
||||||
/// Retrieve the currently set animation clip.
|
/// Retrieve the currently set animation clip.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Handle to the currently set animation clip.</returns>
|
/// <returns>Handle to the currently set animation clip.</returns>
|
||||||
Handle<SHAnimationData> GetCurrentClip() const noexcept { return currClip; }
|
Handle<SHRawAnimation> GetCurrentClip() const noexcept { return currClip; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if an animation is currently playing.
|
/// Checks if an animation is currently playing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -131,7 +131,7 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
// Resources
|
// Resources
|
||||||
Handle<SHRig> rig;
|
Handle<SHRig> rig;
|
||||||
Handle<SHAnimationData> currClip;
|
Handle<SHRawAnimation> currClip;
|
||||||
// Playback Tracking
|
// Playback Tracking
|
||||||
float currPlaybackTime = 0.0f;
|
float currPlaybackTime = 0.0f;
|
||||||
bool isPlaying = true;
|
bool isPlaying = true;
|
||||||
|
@ -141,7 +141,7 @@ namespace SHADE
|
||||||
// Buffer
|
// Buffer
|
||||||
std::vector<SHMatrix> boneMatrices;
|
std::vector<SHMatrix> boneMatrices;
|
||||||
// Caches
|
// Caches
|
||||||
std::unordered_map<std::string, const SHAnimationData::Channel*> channelMap;
|
std::unordered_map<std::string, const SHRawAnimation::Channel*> channelMap;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Helper Functions */
|
/* Helper Functions */
|
||||||
|
|
|
@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Project Includes
|
// Project Includes
|
||||||
#include "SHRig.h"
|
#include "SHRig.h"
|
||||||
#include "Math/SHMatrix.h"
|
#include "Math/SHMatrix.h"
|
||||||
#include "SHAnimationData.h"
|
#include "SHRawAnimation.h"
|
||||||
#include "Graphics/SHVkUtil.h"
|
#include "Graphics/SHVkUtil.h"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
|
|
@ -12,14 +12,14 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Pre-compiled Header
|
// Pre-compiled Header
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
// Primary Header
|
// Primary Header
|
||||||
#include "SHAnimationData.h"
|
#include "SHRawAnimation.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* Constructors */
|
/* Constructors */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
SHAnimationData::SHAnimationData(const SHAnimAsset& asset)
|
SHRawAnimation::SHRawAnimation(const SHAnimAsset& asset)
|
||||||
: ticksPerSecond { static_cast<int>(asset.ticksPerSecond) }
|
: ticksPerSecond { static_cast<int>(asset.ticksPerSecond) }
|
||||||
, totalTime { static_cast<float>(asset.duration) / static_cast<int>(asset.ticksPerSecond) }
|
, totalTime { static_cast<float>(asset.duration) / static_cast<int>(asset.ticksPerSecond) }
|
||||||
{
|
{
|
|
@ -35,7 +35,7 @@ namespace SHADE
|
||||||
/// Represents a animation clip of a 3D animation that is made for a specific model
|
/// Represents a animation clip of a 3D animation that is made for a specific model
|
||||||
/// rig.
|
/// rig.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class SH_API SHAnimationData
|
class SH_API SHRawAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -60,7 +60,7 @@ namespace SHADE
|
||||||
/// Constructs an SHAnimation Clip from a specified SHAnimAsset.
|
/// Constructs an SHAnimation Clip from a specified SHAnimAsset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="asset">Animation asset to load.</param>
|
/// <param name="asset">Animation asset to load.</param>
|
||||||
explicit SHAnimationData(const SHAnimAsset& asset);
|
explicit SHRawAnimation(const SHAnimAsset& asset);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Getter Functions */
|
/* Getter Functions */
|
|
@ -644,13 +644,13 @@ namespace SHADE
|
||||||
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
|
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Handle<SHAnimationData> const& clip = component->GetCurrentClip();
|
Handle<SHRawAnimation> const& clip = component->GetCurrentClip();
|
||||||
const auto CLIP_NAME = clip ? SHResourceManager::GetAssetName<SHAnimationData>(clip).value_or("") : "";
|
const auto CLIP_NAME = clip ? SHResourceManager::GetAssetName<SHRawAnimation>(clip).value_or("") : "";
|
||||||
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Clip", CLIP_NAME,
|
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Clip", CLIP_NAME,
|
||||||
[component]()
|
[component]()
|
||||||
{
|
{
|
||||||
Handle<SHAnimationData> const& clip = component->GetCurrentClip();
|
Handle<SHRawAnimation> const& clip = component->GetCurrentClip();
|
||||||
return SHResourceManager::GetAssetID<SHAnimationData>(clip).value_or(0);
|
return SHResourceManager::GetAssetID<SHRawAnimation>(clip).value_or(0);
|
||||||
},
|
},
|
||||||
[component](AssetID const& id)
|
[component](AssetID const& id)
|
||||||
{
|
{
|
||||||
|
@ -659,13 +659,13 @@ namespace SHADE
|
||||||
SHLOG_WARNING("Attempted to assign non mesh asset to Renderable Mesh property!")
|
SHLOG_WARNING("Attempted to assign non mesh asset to Renderable Mesh property!")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
component->SetClip(SHResourceManager::LoadOrGet<SHAnimationData>(id));
|
component->SetClip(SHResourceManager::LoadOrGet<SHRawAnimation>(id));
|
||||||
}, SHDragDrop::DRAG_RESOURCE);
|
}, SHDragDrop::DRAG_RESOURCE);
|
||||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||||
{
|
{
|
||||||
if (Handle<SHAnimationData> const& clip = component->GetCurrentClip())
|
if (Handle<SHRawAnimation> const& clip = component->GetCurrentClip())
|
||||||
{
|
{
|
||||||
AssetID assetID = SHResourceManager::GetAssetID<SHAnimationData>(clip).value_or(0);
|
AssetID assetID = SHResourceManager::GetAssetID<SHRawAnimation>(clip).value_or(0);
|
||||||
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
|
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"
|
#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"
|
||||||
#include "Assets/Asset Types/SHMaterialAsset.h"
|
#include "Assets/Asset Types/SHMaterialAsset.h"
|
||||||
#include "Graphics/MiddleEnd/TextRendering/SHFont.h"
|
#include "Graphics/MiddleEnd/TextRendering/SHFont.h"
|
||||||
#include "Animation/SHAnimationData.h"
|
#include "Animation/SHRawAnimation.h"
|
||||||
#include "Animation/SHRig.h"
|
#include "Animation/SHRig.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -53,7 +53,7 @@ namespace SHADE
|
||||||
template<> struct SHResourceLoader<SHMaterialSpec> { using AssetType = SHMaterialAsset; };
|
template<> struct SHResourceLoader<SHMaterialSpec> { using AssetType = SHMaterialAsset; };
|
||||||
template<> struct SHResourceLoader<SHMaterial> { using AssetType = SHMaterialSpec; };
|
template<> struct SHResourceLoader<SHMaterial> { using AssetType = SHMaterialSpec; };
|
||||||
template<> struct SHResourceLoader<SHFont> { using AssetType = SHFontAsset; };
|
template<> struct SHResourceLoader<SHFont> { using AssetType = SHFontAsset; };
|
||||||
template<> struct SHResourceLoader<SHAnimationData> { using AssetType = SHModelAsset; };
|
template<> struct SHResourceLoader<SHRawAnimation> { using AssetType = SHModelAsset; };
|
||||||
template<> struct SHResourceLoader<SHRig> { using AssetType = SHModelAsset; };
|
template<> struct SHResourceLoader<SHRig> { using AssetType = SHModelAsset; };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace SHADE
|
||||||
!std::is_same_v<ResourceType, SHMaterialSpec> &&
|
!std::is_same_v<ResourceType, SHMaterialSpec> &&
|
||||||
!std::is_same_v<ResourceType, SHFont> &&
|
!std::is_same_v<ResourceType, SHFont> &&
|
||||||
!std::is_same_v<ResourceType, SHMaterial> &&
|
!std::is_same_v<ResourceType, SHMaterial> &&
|
||||||
!std::is_same_v<ResourceType, SHAnimationData> &&
|
!std::is_same_v<ResourceType, SHRawAnimation> &&
|
||||||
!std::is_same_v<ResourceType, SHRig>
|
!std::is_same_v<ResourceType, SHRig>
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -355,7 +355,7 @@ namespace SHADE
|
||||||
loadedAssetData.emplace_back(assetId);
|
loadedAssetData.emplace_back(assetId);
|
||||||
return resourceHub.Create<ResourceType>(assetData.rig, rigNodeStore);
|
return resourceHub.Create<ResourceType>(assetData.rig, rigNodeStore);
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same_v<ResourceType, SHAnimationData>)
|
else if constexpr (std::is_same_v<ResourceType, SHRawAnimation>)
|
||||||
{
|
{
|
||||||
loadedAssetData.emplace_back(assetId);
|
loadedAssetData.emplace_back(assetId);
|
||||||
return resourceHub.Create<ResourceType>(*assetData.anims[0]);
|
return resourceHub.Create<ResourceType>(*assetData.anims[0]);
|
||||||
|
|
|
@ -400,7 +400,7 @@ namespace YAML
|
||||||
{
|
{
|
||||||
YAML::Node node;
|
YAML::Node node;
|
||||||
node[RIG_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHRig>(rhs.GetRig()).value_or(0);
|
node[RIG_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHRig>(rhs.GetRig()).value_or(0);
|
||||||
node[CLIP_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHAnimationData>(rhs.GetCurrentClip()).value_or(0);
|
node[CLIP_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHRawAnimation>(rhs.GetCurrentClip()).value_or(0);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
static bool decode(YAML::Node const& node, SHAnimatorComponent& rhs)
|
static bool decode(YAML::Node const& node, SHAnimatorComponent& rhs)
|
||||||
|
@ -411,7 +411,7 @@ namespace YAML
|
||||||
}
|
}
|
||||||
if (node[CLIP_YAML_TAG.data()].IsDefined())
|
if (node[CLIP_YAML_TAG.data()].IsDefined())
|
||||||
{
|
{
|
||||||
rhs.SetClip(SHResourceManager::LoadOrGet<SHAnimationData>(node[CLIP_YAML_TAG.data()].as<AssetID>()));
|
rhs.SetClip(SHResourceManager::LoadOrGet<SHRawAnimation>(node[CLIP_YAML_TAG.data()].as<AssetID>()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue