Compare commits
6 Commits
main
...
SP3-17-ani
Author | SHA1 | Date |
---|---|---|
Kah Wei | da3b54a86b | |
Kah Wei | 5abcf49271 | |
Xiao Qi | 4aa032833c | |
Kah Wei | 933e963950 | |
Kah Wei | a0bafcc526 | |
Kah Wei | b9e12db44d |
|
@ -15,6 +15,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
#include "Math/SHMatrix.h"
|
#include "Math/SHMatrix.h"
|
||||||
#include "Assets/Asset Types/Models/SHAnimationAsset.h"
|
#include "Assets/Asset Types/Models/SHAnimationAsset.h"
|
||||||
|
#include "Math/SHQuaternion.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -76,10 +77,5 @@ namespace SHADE
|
||||||
std::vector<Channel> channels;
|
std::vector<Channel> channels;
|
||||||
int ticksPerSecond;
|
int ticksPerSecond;
|
||||||
float totalTime;
|
float totalTime;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
|
||||||
/* Helper Functions */
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
// Primary Include
|
// Primary Include
|
||||||
#include "SHAnimatorComponent.h"
|
#include "SHAnimatorComponent.h"
|
||||||
|
#include "SHAnimatorComponent.hpp" // Include here as they are private function templates
|
||||||
// STL Includes
|
// STL Includes
|
||||||
#include <queue>
|
#include <queue>
|
||||||
// Project Includes
|
// Project Includes
|
||||||
|
@ -161,7 +162,6 @@ namespace SHADE
|
||||||
|
|
||||||
// Apply transformations to this node
|
// Apply transformations to this node
|
||||||
const int BONE_MTX_IDX = rig->GetNodeIndex(node);
|
const int BONE_MTX_IDX = rig->GetNodeIndex(node);
|
||||||
std::optional<SHVec3> position;
|
|
||||||
if (BONE_MTX_IDX >= 0)
|
if (BONE_MTX_IDX >= 0)
|
||||||
{
|
{
|
||||||
boneMatrices[BONE_MTX_IDX] = node->OffsetMatrix * transformMatrix;
|
boneMatrices[BONE_MTX_IDX] = node->OffsetMatrix * transformMatrix;
|
||||||
|
|
|
@ -151,5 +151,3 @@ namespace SHADE
|
||||||
RTTR_ENABLE()
|
RTTR_ENABLE()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "SHAnimatorComponent.hpp"
|
|
|
@ -20,7 +20,6 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
#include "Math/SHMatrix.h"
|
#include "Math/SHMatrix.h"
|
||||||
#include "Resource/SHHandle.h"
|
#include "Resource/SHHandle.h"
|
||||||
#include "Resource/SHResourceLibrary.h"
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Math/SHMath.h"
|
|
||||||
#include "Assets/Asset Types/SHAssetData.h"
|
#include "Assets/Asset Types/SHAssetData.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "Math/Vector/SHVec3.h"
|
||||||
|
#include "Math/Vector/SHVec4.h"
|
||||||
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
|
|
@ -68,6 +68,11 @@ namespace SHADE
|
||||||
ReadMeshData(file, asset.meshHeaders, asset.meshes);
|
ReadMeshData(file, asset.meshHeaders, asset.meshes);
|
||||||
ReadAnimData(file, asset.animHeaders, asset.anims);
|
ReadAnimData(file, asset.animHeaders, asset.anims);
|
||||||
|
|
||||||
|
/*for (auto& mesh : asset.meshes)
|
||||||
|
{
|
||||||
|
mesh->BoneCount = asset.rig.nodeDataCollection.size();
|
||||||
|
}*/
|
||||||
|
|
||||||
// Not eof yet, animation exists
|
// Not eof yet, animation exists
|
||||||
if (file.peek() != EOF)
|
if (file.peek() != EOF)
|
||||||
{
|
{
|
||||||
|
|
|
@ -608,25 +608,34 @@ namespace SHADE
|
||||||
boneMatrixIndices.emplace_back(static_cast<uint32_t>(boneMatrixData.size()));
|
boneMatrixIndices.emplace_back(static_cast<uint32_t>(boneMatrixData.size()));
|
||||||
|
|
||||||
auto animator = SHComponentManager::GetComponent_s<SHAnimatorComponent>(rendId);
|
auto animator = SHComponentManager::GetComponent_s<SHAnimatorComponent>(rendId);
|
||||||
auto mesh = renderable->GetMesh();
|
|
||||||
const int BONE_COUNT = static_cast<int>(mesh->BoneCount);
|
|
||||||
int extraMatricesToAdd = BONE_COUNT;
|
|
||||||
if (animator)
|
if (animator)
|
||||||
{
|
{
|
||||||
// Add matrices
|
|
||||||
const auto& MATRICES = animator->GetBoneMatrices();
|
const auto& MATRICES = animator->GetBoneMatrices();
|
||||||
if (MATRICES.size() <= BONE_COUNT)
|
boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
|
||||||
{
|
|
||||||
boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
|
|
||||||
extraMatricesToAdd = std::max({0, BONE_COUNT - static_cast<int>(MATRICES.size())});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we need to patch up with more matrices, add it
|
//auto mesh = renderable->GetMesh();
|
||||||
if (extraMatricesToAdd > 0)
|
//const int BONE_COUNT = static_cast<int>(mesh->BoneCount);
|
||||||
{
|
//int extraMatricesToAdd = BONE_COUNT;
|
||||||
boneMatrixData.insert(boneMatrixData.end(), extraMatricesToAdd, SHMatrix::Identity);
|
//if (animator)
|
||||||
}
|
//{
|
||||||
|
// const auto& MATRICES = animator->GetBoneMatrices();
|
||||||
|
// boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
|
||||||
|
|
||||||
|
// // Add matrices
|
||||||
|
// const auto& MATRICES = animator->GetBoneMatrices();
|
||||||
|
// if (MATRICES.size() <= BONE_COUNT)
|
||||||
|
// {
|
||||||
|
// boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
|
||||||
|
// extraMatricesToAdd = std::max({0, BONE_COUNT - static_cast<int>(MATRICES.size())});
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// If we need to patch up with more matrices, add it
|
||||||
|
//if (extraMatricesToAdd > 0)
|
||||||
|
//{
|
||||||
|
// boneMatrixData.insert(boneMatrixData.end(), extraMatricesToAdd, SHMatrix::Identity);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "SHResourceManagerInterface.h"
|
#include "SHResourceManagerInterface.h"
|
||||||
// Project Includes
|
// Project Includes
|
||||||
#include "SHResourceManager.h"
|
#include "SHResourceManager.h"
|
||||||
|
#include "Animation/SHAnimationClip.h"
|
||||||
|
#include "Animation/SHRig.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -23,6 +25,17 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
return SHResourceManager::LoadOrGet<SHMesh>(assetId);
|
return SHResourceManager::LoadOrGet<SHMesh>(assetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle<SHRig> SHResourceManagerInterface::LoadOrGetRig(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHRig>(assetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle<SHAnimationClip> SHResourceManagerInterface::LoadOrGetAnimationClip(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHAnimationClip>(assetId);
|
||||||
|
}
|
||||||
|
|
||||||
Handle<SHTexture> SHResourceManagerInterface::LoadOrGetTexture(AssetID assetId)
|
Handle<SHTexture> SHResourceManagerInterface::LoadOrGetTexture(AssetID assetId)
|
||||||
{
|
{
|
||||||
return SHResourceManager::LoadOrGet<SHTexture>(assetId);
|
return SHResourceManager::LoadOrGet<SHTexture>(assetId);
|
||||||
|
|
|
@ -29,6 +29,8 @@ namespace SHADE
|
||||||
struct SHMaterialSpec;
|
struct SHMaterialSpec;
|
||||||
class SHMaterial;
|
class SHMaterial;
|
||||||
class SHFont;
|
class SHFont;
|
||||||
|
class SHRig;
|
||||||
|
class SHAnimationClip;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* Type Definitions */
|
/* Type Definitions */
|
||||||
|
@ -43,13 +45,24 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Loading Functions */
|
/* Loading Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrapper for SHResourceManager::LoadOrGet<SHMesh>().
|
/// Wrapper for SHResourceManager::LoadOrGet<SHMesh>().
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetId">Asset ID of the resource to load.</param>
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
/// <returns>Handle to the resource to retrieve.</returns>
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
static Handle<SHMesh> LoadOrGetMesh(AssetID assetId);
|
static Handle<SHMesh> LoadOrGetMesh(AssetID assetId);
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHRig>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHRig> LoadOrGetRig(AssetID assetId);
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHAnimationClip>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHAnimationClip> LoadOrGetAnimationClip(AssetID assetId);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrapper for SHResourceManager::LoadOrGet<SHTexture>().
|
/// Wrapper for SHResourceManager::LoadOrGet<SHTexture>().
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file AnimationClipAsset.cxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Jan 31, 2023
|
||||||
|
\brief Contains the implementation of the functions of the managed
|
||||||
|
AnimationClipAsset class.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Headers
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Header
|
||||||
|
#include "AnimationClipAsset.hxx"
|
||||||
|
// External Dependencies
|
||||||
|
#include "Resource/SHResourceManagerInterface.h"
|
||||||
|
// Project Headers
|
||||||
|
#include "Utility/Convert.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
Handle<SHAnimationClip> AnimationClipAsset::NativeObject::get()
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return SHResourceManagerInterface::LoadOrGetAnimationClip(asset.NativeAssetID);
|
||||||
|
}
|
||||||
|
catch (const BadHandleCastException&)
|
||||||
|
{
|
||||||
|
return Handle<SHAnimationClip>();
|
||||||
|
}
|
||||||
|
AssetID AnimationClipAsset::NativeAssetID::get()
|
||||||
|
{
|
||||||
|
return asset.NativeAssetID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructors/Destructor */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
AnimationClipAsset::AnimationClipAsset(AssetID meshId)
|
||||||
|
: asset{ meshId }
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Operator Overloads */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
AnimationClipAsset::operator bool(AnimationClipAsset asset)
|
||||||
|
{
|
||||||
|
return asset.asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Conversion Operators */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
AnimationClipAsset::operator Asset(AnimationClipAsset nativeAsset)
|
||||||
|
{
|
||||||
|
return nativeAsset.asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationClipAsset::operator AnimationClipAsset(Asset asset)
|
||||||
|
{
|
||||||
|
return AnimationClipAsset(asset.NativeAssetID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file AnimationClipAsset.hxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Jan 31, 2023
|
||||||
|
\brief Contains the definition of the managed AnimationClip class.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
// External Dependencies
|
||||||
|
#include "Resource/SHHandle.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "NativeAsset.hxx"
|
||||||
|
#include "Engine/GenericHandle.hxx"
|
||||||
|
#include "Animation/SHAnimationClip.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Managed counterpart of the native AnimationClip object containing vertex data
|
||||||
|
/// that can be fed to an Animator for rendering.
|
||||||
|
/// </summary>
|
||||||
|
public value struct AnimationClipAsset
|
||||||
|
{
|
||||||
|
internal:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Copy of the Handle to the native object.
|
||||||
|
/// </summary>
|
||||||
|
property Handle<SHAnimationClip> NativeObject
|
||||||
|
{
|
||||||
|
Handle<SHAnimationClip> get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The raw asset ID of the asset.
|
||||||
|
/// </summary>
|
||||||
|
property AssetID NativeAssetID
|
||||||
|
{
|
||||||
|
AssetID get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Constructors/Destructor */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the AnimationClip.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="meshId">AssetID to the Mesh asset.</param>
|
||||||
|
AnimationClipAsset(AssetID assetId);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Operator Overloads */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Implicit conversion operator to enable checking if a AnimationClip is valid.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gameObj">Asset to check.</param>
|
||||||
|
/// <returns>True if the Asset is valid.</returns>
|
||||||
|
static operator bool(AnimationClipAsset asset);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Conversion Operators */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Conversion operator to enable casting from a AnimationClip to an Asset.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vec">Vector3 to convert from.</param>
|
||||||
|
static explicit operator Asset(AnimationClipAsset nativeAsset);
|
||||||
|
/// <summary>
|
||||||
|
/// Conversion operator to enable casting from a Asset to a AnimationClip.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="asset"></param>
|
||||||
|
static explicit operator AnimationClipAsset(Asset asset);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Data Members */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
Asset asset;
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/************************************************************************************//*!
|
/************************************************************************************//*!
|
||||||
\file Mesh.cxx
|
\file MeshAsset.cxx
|
||||||
\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 Oct 28, 2022
|
\date Oct 28, 2022
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/************************************************************************************//*!
|
/************************************************************************************//*!
|
||||||
\file Mesh.hxx
|
\file MeshAsset.hxx
|
||||||
\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 Oct 28, 2022
|
\date Oct 28, 2022
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file RigAsset.cxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Jan 31, 2023
|
||||||
|
\brief Contains the implementation of the functions of the managed RigAsset
|
||||||
|
class.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Headers
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Header
|
||||||
|
#include "RigAsset.hxx"
|
||||||
|
// External Dependencies
|
||||||
|
#include "Resource/SHResourceManagerInterface.h"
|
||||||
|
// Project Headers
|
||||||
|
#include "Utility/Convert.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
Handle<SHRig> RigAsset::NativeObject::get()
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return SHResourceManagerInterface::LoadOrGetRig(asset.NativeAssetID);
|
||||||
|
}
|
||||||
|
catch (const BadHandleCastException&)
|
||||||
|
{
|
||||||
|
return Handle<SHRig>();
|
||||||
|
}
|
||||||
|
AssetID RigAsset::NativeAssetID::get()
|
||||||
|
{
|
||||||
|
return asset.NativeAssetID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructors/Destructor */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
RigAsset::RigAsset(AssetID assetId)
|
||||||
|
: asset { assetId }
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Operator Overloads */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
RigAsset::operator bool(RigAsset asset)
|
||||||
|
{
|
||||||
|
return asset.asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Conversion Operators */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
RigAsset::operator Asset(RigAsset nativeAsset)
|
||||||
|
{
|
||||||
|
return nativeAsset.asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
RigAsset::operator RigAsset(Asset asset)
|
||||||
|
{
|
||||||
|
return RigAsset(asset.NativeAssetID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file RigAsset.hxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Jan 31, 2023
|
||||||
|
\brief Contains the definition of the managed RigAsset class.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
// External Dependencies
|
||||||
|
#include "Resource/SHHandle.h"
|
||||||
|
#include "Animation/SHRig.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "NativeAsset.hxx"
|
||||||
|
#include "Engine/GenericHandle.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Managed counterpart of the native Rig object containing the skeleton of a model
|
||||||
|
/// that can be fed to an Animator for animations.
|
||||||
|
/// </summary>
|
||||||
|
public value struct RigAsset
|
||||||
|
{
|
||||||
|
internal:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Copy of the Handle to the native object.
|
||||||
|
/// </summary>
|
||||||
|
property Handle<SHRig> NativeObject
|
||||||
|
{
|
||||||
|
Handle<SHRig> get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The raw asset ID of the asset.
|
||||||
|
/// </summary>
|
||||||
|
property AssetID NativeAssetID
|
||||||
|
{
|
||||||
|
AssetID get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Constructors/Destructor */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the RigAsset.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="meshId">AssetID to the SHRig asset.</param>
|
||||||
|
RigAsset(AssetID assetId);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Operator Overloads */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Implicit conversion operator to enable checking if a Rig is valid.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gameObj">Asset to check.</param>
|
||||||
|
/// <returns>True if the Asset is valid.</returns>
|
||||||
|
static operator bool(RigAsset asset);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Conversion Operators */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Conversion operator to enable casting from a RigAsset to an Asset.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vec">Vector3 to convert from.</param>
|
||||||
|
static explicit operator Asset(RigAsset nativeAsset);
|
||||||
|
/// <summary>
|
||||||
|
/// Conversion operator to enable casting from a Asset to a RigAsset.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="asset"></param>
|
||||||
|
static explicit operator RigAsset(Asset asset);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Data Members */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
Asset asset;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file Animator.cxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Jan 31, 2023
|
||||||
|
\brief Contains the definition of the functions of the managed Renderable class.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Headers
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Header
|
||||||
|
#include "Animator.hxx"
|
||||||
|
#include "Assets/NativeAsset.hxx"
|
||||||
|
#include "Utility/Convert.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructors */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
Animator::Animator(Entity entity)
|
||||||
|
: Component(entity)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
RigAsset Animator::Rig::get()
|
||||||
|
{
|
||||||
|
auto rig = GetNativeComponent()->GetRig();
|
||||||
|
return rig ? RigAsset(rig) : RigAsset();
|
||||||
|
}
|
||||||
|
void Animator::Rig::set(RigAsset value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
GetNativeComponent()->SetRig(Handle<SHRig>());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetNativeComponent()->SetRig(value.NativeObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AnimationClipAsset Animator::Clip::get()
|
||||||
|
{
|
||||||
|
auto clip = GetNativeComponent()->GetCurrentClip();
|
||||||
|
return clip ? AnimationClipAsset(clip) : AnimationClipAsset();
|
||||||
|
}
|
||||||
|
void Animator::Clip::set(AnimationClipAsset value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
GetNativeComponent()->SetClip(Handle<SHAnimationClip>());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetNativeComponent()->SetClip(value.NativeObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool Animator::IsPlaying::get()
|
||||||
|
{
|
||||||
|
return GetNativeComponent()->IsPlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Usage Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
void Animator::Play()
|
||||||
|
{
|
||||||
|
GetNativeComponent()->Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animator::Play(AnimationClipAsset clip)
|
||||||
|
{
|
||||||
|
GetNativeComponent()->Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animator::PlayFromStart()
|
||||||
|
{
|
||||||
|
GetNativeComponent()->PlayFromStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animator::Pause()
|
||||||
|
{
|
||||||
|
GetNativeComponent()->Pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animator::Stop()
|
||||||
|
{
|
||||||
|
GetNativeComponent()->Stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file Animator.hxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Jan 31, 2023
|
||||||
|
\brief Contains the definition of the managed Animator class with the
|
||||||
|
declaration of functions for working with it.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
// External Dependencies
|
||||||
|
#include "Animation/SHAnimatorComponent.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "Components/Component.hxx"
|
||||||
|
#include "Math/Vector3.hxx"
|
||||||
|
#include "Math/Quaternion.hxx"
|
||||||
|
#include "Assets/RigAsset.hxx"
|
||||||
|
#include "Assets/AnimationClipAsset.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// CLR version of the SHADE Engine's SHAnimatorComponent.
|
||||||
|
/// </summary>
|
||||||
|
public ref class Animator : public Component<SHAnimatorComponent>
|
||||||
|
{
|
||||||
|
internal:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Constructors */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a Animator Component that represents a native Animator
|
||||||
|
/// component tied to the specified Entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">Entity that this Component will be tied to.</param>
|
||||||
|
Animator(Entity entity);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// The current animation rig used to animate models for this Animator.
|
||||||
|
/// </summary>
|
||||||
|
property RigAsset Rig
|
||||||
|
{
|
||||||
|
RigAsset get();
|
||||||
|
void set(RigAsset asset);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The current animation clip that is played on the animation rig and model for
|
||||||
|
/// this Animator.
|
||||||
|
/// </summary>
|
||||||
|
property AnimationClipAsset Clip
|
||||||
|
{
|
||||||
|
AnimationClipAsset get();
|
||||||
|
void set(AnimationClipAsset asset);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Whether an animation is currently playing.
|
||||||
|
/// </summary>
|
||||||
|
property bool IsPlaying
|
||||||
|
{
|
||||||
|
bool get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Usage Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Plays the currently loaded animation from the last time.
|
||||||
|
/// </summary>
|
||||||
|
void Play();
|
||||||
|
/// <summary>
|
||||||
|
/// Plays the specified animation clip from the start.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clip">Animation clip to play.</param>
|
||||||
|
void Play(AnimationClipAsset clip);
|
||||||
|
/// <summary>
|
||||||
|
/// Plays the currently loaded animation clip from the start.
|
||||||
|
/// </summary>
|
||||||
|
void PlayFromStart();
|
||||||
|
/// <summary>
|
||||||
|
/// Pauses the animation at the current time.
|
||||||
|
/// </summary>
|
||||||
|
void Pause();
|
||||||
|
/// <summary>
|
||||||
|
/// Stops the animation and resets the play time back to 0.
|
||||||
|
/// </summary>
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Usage Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
void Renderable::SetMaterial(MaterialAsset materialAsset)
|
void Renderable::SetMaterial(MaterialAsset materialAsset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the Material used by this Renderable to be an instance of the specified
|
/// Sets the Material used by this Renderable to be an instance of the specified
|
||||||
|
|
|
@ -18,6 +18,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Editor/Editor.hxx"
|
#include "Editor/Editor.hxx"
|
||||||
// STL Includes
|
// STL Includes
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
// Project Headers
|
// Project Headers
|
||||||
#include "Components/Component.hxx"
|
#include "Components/Component.hxx"
|
||||||
#include "Scripts/ScriptStore.hxx"
|
#include "Scripts/ScriptStore.hxx"
|
||||||
|
@ -30,7 +31,8 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "RangeAttribute.hxx"
|
#include "RangeAttribute.hxx"
|
||||||
#include "Math/Vector2.hxx"
|
#include "Math/Vector2.hxx"
|
||||||
#include "Math/Vector3.hxx"
|
#include "Math/Vector3.hxx"
|
||||||
#include <string>
|
#include "Assets/RigAsset.hxx"
|
||||||
|
#include "Assets/AnimationClipAsset.hxx"
|
||||||
|
|
||||||
// Using Directives
|
// Using Directives
|
||||||
using namespace System;
|
using namespace System;
|
||||||
|
@ -162,24 +164,26 @@ namespace SHADE
|
||||||
bool isHovered = false;
|
bool isHovered = false;
|
||||||
|
|
||||||
const bool MODIFIED_PRIMITIVE =
|
const bool MODIFIED_PRIMITIVE =
|
||||||
renderSpecificField<int , Int16 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
renderSpecificField<int , Int16 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||||
renderSpecificField<int , Int32 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
renderSpecificField<int , Int32 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||||
renderSpecificField<int , Int64 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
renderSpecificField<int , Int64 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||||
renderSpecificField<int , UInt16 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
renderSpecificField<int , UInt16 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||||
renderSpecificField<int , UInt32 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
renderSpecificField<int , UInt32 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||||
renderSpecificField<int , UInt64 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
renderSpecificField<int , UInt64 >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||||
renderSpecificField<int , Byte >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
renderSpecificField<int , Byte >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||||
renderSpecificField<bool , bool >(field, object, SHEditorUI::InputCheckbox, &isHovered) ||
|
renderSpecificField<bool , bool >(field, object, SHEditorUI::InputCheckbox, &isHovered) ||
|
||||||
renderSpecificField<float , float >(field, object, SHEditorUI::InputFloat , &isHovered) ||
|
renderSpecificField<float , float >(field, object, SHEditorUI::InputFloat , &isHovered) ||
|
||||||
renderSpecificField<double , double >(field, object, SHEditorUI::InputDouble , &isHovered) ||
|
renderSpecificField<double , double >(field, object, SHEditorUI::InputDouble , &isHovered) ||
|
||||||
renderSpecificField<SHVec2 , Vector2 >(field, object, SHEditorUI::InputVec2 , &isHovered) ||
|
renderSpecificField<SHVec2 , Vector2 >(field, object, SHEditorUI::InputVec2 , &isHovered) ||
|
||||||
renderSpecificField<SHVec3 , Vector3 >(field, object, SHEditorUI::InputVec3 , &isHovered) ||
|
renderSpecificField<SHVec3 , Vector3 >(field, object, SHEditorUI::InputVec3 , &isHovered) ||
|
||||||
renderSpecificField<uint32_t , GameObject >(field, object, nullptr , &isHovered) ||
|
renderSpecificField<uint32_t , GameObject >(field, object, nullptr , &isHovered) ||
|
||||||
renderSpecificField<std::string, System::String^>(field, object, nullptr , &isHovered) ||
|
renderSpecificField<std::string, System::String^ >(field, object, nullptr , &isHovered) ||
|
||||||
renderSpecificField<int , System::Enum >(field, object, nullptr , &isHovered) ||
|
renderSpecificField<int , System::Enum >(field, object, nullptr , &isHovered) ||
|
||||||
renderSpecificField<AssetID , FontAsset >(field, object, nullptr , &isHovered) ||
|
renderSpecificField<AssetID , FontAsset >(field, object, nullptr , &isHovered) ||
|
||||||
renderSpecificField<AssetID , MeshAsset >(field, object, nullptr , &isHovered) ||
|
renderSpecificField<AssetID , MeshAsset >(field, object, nullptr , &isHovered) ||
|
||||||
renderSpecificField<AssetID , MaterialAsset >(field, object, nullptr , &isHovered);
|
renderSpecificField<AssetID , MaterialAsset >(field, object, nullptr , &isHovered) ||
|
||||||
|
renderSpecificField<AssetID , RigAsset >(field, object, nullptr , &isHovered) ||
|
||||||
|
renderSpecificField<AssetID , AnimationClipAsset>(field, object, nullptr , &isHovered);
|
||||||
|
|
||||||
if (!MODIFIED_PRIMITIVE)
|
if (!MODIFIED_PRIMITIVE)
|
||||||
{
|
{
|
||||||
|
@ -323,24 +327,26 @@ namespace SHADE
|
||||||
bool modified;
|
bool modified;
|
||||||
|
|
||||||
const bool RENDERED =
|
const bool RENDERED =
|
||||||
renderFieldEditor<int , Int16 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , Int16 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<int , Int32 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , Int32 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<int , Int64 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , Int64 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<int , UInt16 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , UInt16 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<int , UInt32 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , UInt32 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<int , UInt64 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , UInt64 >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<int , Byte >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , Byte >(fieldName, object, SHEditorUI::InputInt , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<bool , bool >(fieldName, object, SHEditorUI::InputCheckbox, nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<bool , bool >(fieldName, object, SHEditorUI::InputCheckbox, nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<float , float >(fieldName, object, SHEditorUI::InputFloat , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<float , float >(fieldName, object, SHEditorUI::InputFloat , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<double , double >(fieldName, object, SHEditorUI::InputDouble , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<double , double >(fieldName, object, SHEditorUI::InputDouble , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<SHVec2 , Vector2 >(fieldName, object, SHEditorUI::InputVec2 , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<SHVec2 , Vector2 >(fieldName, object, SHEditorUI::InputVec2 , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<SHVec3 , Vector3 >(fieldName, object, SHEditorUI::InputVec3 , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<SHVec3 , Vector3 >(fieldName, object, SHEditorUI::InputVec3 , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<uint32_t , GameObject >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<uint32_t , GameObject >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<std::string, System::String^>(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<std::string, System::String^ >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<int , System::Enum >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<int , System::Enum >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<AssetID , FontAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<AssetID , FontAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<AssetID , MeshAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
renderFieldEditor<AssetID , MeshAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
||||||
renderFieldEditor<AssetID , MaterialAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified);
|
renderFieldEditor<AssetID , MaterialAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified)||
|
||||||
|
renderFieldEditor<AssetID , RigAsset >(fieldName, object, nullptr , nullptr, rangeAttrib, modified) ||
|
||||||
|
renderFieldEditor<AssetID , AnimationClipAsset>(fieldName, object, nullptr , nullptr, rangeAttrib, modified);
|
||||||
|
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Assets/FontAsset.hxx"
|
#include "Assets/FontAsset.hxx"
|
||||||
#include "Assets/MeshAsset.hxx"
|
#include "Assets/MeshAsset.hxx"
|
||||||
#include "Assets/MaterialAsset.hxx"
|
#include "Assets/MaterialAsset.hxx"
|
||||||
|
#include "Assets/RigAsset.hxx"
|
||||||
|
#include "Assets/AnimationClipAsset.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -237,6 +239,30 @@ namespace SHADE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
template<>
|
||||||
|
bool Editor::renderFieldEditorInternal<AssetID, RigAsset>(const std::string& fieldName, interior_ptr<RigAsset> managedValPtr, EditorFieldFunc<uint32_t>, bool* isHovered, RangeAttribute^)
|
||||||
|
{
|
||||||
|
uint32_t assetId = managedValPtr->NativeAssetID;
|
||||||
|
if (SHEditorUI::InputAssetField(fieldName, assetId, AssetType::MODEL, isHovered))
|
||||||
|
{
|
||||||
|
*managedValPtr = RigAsset(assetId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
template<>
|
||||||
|
bool Editor::renderFieldEditorInternal<AssetID, AnimationClipAsset>(const std::string& fieldName, interior_ptr<AnimationClipAsset> managedValPtr, EditorFieldFunc<uint32_t>, bool* isHovered, RangeAttribute^)
|
||||||
|
{
|
||||||
|
uint32_t assetId = managedValPtr->NativeAssetID;
|
||||||
|
if (SHEditorUI::InputAssetField(fieldName, assetId, AssetType::MODEL, isHovered))
|
||||||
|
{
|
||||||
|
*managedValPtr = AnimationClipAsset(assetId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Assets/MaterialAsset.hxx"
|
#include "Assets/MaterialAsset.hxx"
|
||||||
#include "Assets/MeshAsset.hxx"
|
#include "Assets/MeshAsset.hxx"
|
||||||
#include "Scripts/Script.hxx"
|
#include "Scripts/Script.hxx"
|
||||||
|
#include "Assets/RigAsset.hxx"
|
||||||
|
#include "Assets/AnimationClipAsset.hxx"
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------*/
|
||||||
/* File-Level Constants */
|
/* File-Level Constants */
|
||||||
|
@ -144,24 +146,26 @@ namespace SHADE
|
||||||
YAML::Node fieldNode;
|
YAML::Node fieldNode;
|
||||||
|
|
||||||
// Retrieve string for the YAML
|
// Retrieve string for the YAML
|
||||||
const bool PRIMITIVE_SERIALIZED = fieldInsertYaml<System::Int16 >(fieldInfo, object, fieldNode) ||
|
const bool PRIMITIVE_SERIALIZED = fieldInsertYaml<System::Int16 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::Int32 >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::Int32 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::Int64 >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::Int64 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::UInt16>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::UInt16 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::UInt32>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::UInt32 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::UInt64>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::UInt64 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::Byte >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::Byte >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<bool >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<bool >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<float >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<float >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<double >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<double >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::Enum >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::Enum >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<System::String>(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<System::String >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<Vector2 >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<Vector2 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<Vector3 >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<Vector3 >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<GameObject >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<GameObject >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<FontAsset >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<FontAsset >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<MaterialAsset >(fieldInfo, object, fieldNode) ||
|
fieldInsertYaml<MaterialAsset >(fieldInfo, object, fieldNode) ||
|
||||||
fieldInsertYaml<MeshAsset >(fieldInfo, object, fieldNode);
|
fieldInsertYaml<MeshAsset >(fieldInfo, object, fieldNode) ||
|
||||||
|
fieldInsertYaml<RigAsset >(fieldInfo, object, fieldNode) ||
|
||||||
|
fieldInsertYaml<AnimationClipAsset>(fieldInfo, object, fieldNode);
|
||||||
|
|
||||||
// Serialization of more complex types
|
// Serialization of more complex types
|
||||||
if (!PRIMITIVE_SERIALIZED)
|
if (!PRIMITIVE_SERIALIZED)
|
||||||
|
@ -208,24 +212,26 @@ namespace SHADE
|
||||||
bool SerialisationUtilities::varInsertYaml(System::Object^ object, YAML::Node& fieldNode)
|
bool SerialisationUtilities::varInsertYaml(System::Object^ object, YAML::Node& fieldNode)
|
||||||
{
|
{
|
||||||
const bool INSERTED =
|
const bool INSERTED =
|
||||||
varInsertYamlInternal<System::Int16 >(object, fieldNode) ||
|
varInsertYamlInternal<System::Int16 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::Int32 >(object, fieldNode) ||
|
varInsertYamlInternal<System::Int32 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::Int64 >(object, fieldNode) ||
|
varInsertYamlInternal<System::Int64 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::UInt16>(object, fieldNode) ||
|
varInsertYamlInternal<System::UInt16 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::UInt32>(object, fieldNode) ||
|
varInsertYamlInternal<System::UInt32 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::UInt64>(object, fieldNode) ||
|
varInsertYamlInternal<System::UInt64 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::Byte >(object, fieldNode) ||
|
varInsertYamlInternal<System::Byte >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<bool >(object, fieldNode) ||
|
varInsertYamlInternal<bool >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<float >(object, fieldNode) ||
|
varInsertYamlInternal<float >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<double >(object, fieldNode) ||
|
varInsertYamlInternal<double >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::Enum >(object, fieldNode) ||
|
varInsertYamlInternal<System::Enum >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<System::String>(object, fieldNode) ||
|
varInsertYamlInternal<System::String >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<Vector2 >(object, fieldNode) ||
|
varInsertYamlInternal<Vector2 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<Vector3 >(object, fieldNode) ||
|
varInsertYamlInternal<Vector3 >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<GameObject >(object, fieldNode) ||
|
varInsertYamlInternal<GameObject >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<FontAsset >(object, fieldNode) ||
|
varInsertYamlInternal<FontAsset >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<MaterialAsset >(object, fieldNode) ||
|
varInsertYamlInternal<MaterialAsset >(object, fieldNode) ||
|
||||||
varInsertYamlInternal<MeshAsset >(object, fieldNode);
|
varInsertYamlInternal<MeshAsset >(object, fieldNode) ||
|
||||||
|
varInsertYamlInternal<RigAsset >(object, fieldNode) ||
|
||||||
|
varInsertYamlInternal<AnimationClipAsset>(object, fieldNode);
|
||||||
return INSERTED;
|
return INSERTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,24 +241,26 @@ namespace SHADE
|
||||||
bool SerialisationUtilities::writeYamlIntoField(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
|
bool SerialisationUtilities::writeYamlIntoField(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
|
||||||
{
|
{
|
||||||
const bool ASSIGNED =
|
const bool ASSIGNED =
|
||||||
fieldAssignYaml<System::Int16> (fieldInfo, object, node) ||
|
fieldAssignYaml<System::Int16> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::Int32> (fieldInfo, object, node) ||
|
fieldAssignYaml<System::Int32> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::Int64> (fieldInfo, object, node) ||
|
fieldAssignYaml<System::Int64> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::UInt16>(fieldInfo, object, node) ||
|
fieldAssignYaml<System::UInt16> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::UInt32>(fieldInfo, object, node) ||
|
fieldAssignYaml<System::UInt32> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::UInt64>(fieldInfo, object, node) ||
|
fieldAssignYaml<System::UInt64> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::Byte> (fieldInfo, object, node) ||
|
fieldAssignYaml<System::Byte> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<bool> (fieldInfo, object, node) ||
|
fieldAssignYaml<bool> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<float> (fieldInfo, object, node) ||
|
fieldAssignYaml<float> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<double> (fieldInfo, object, node) ||
|
fieldAssignYaml<double> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::Enum> (fieldInfo, object, node) ||
|
fieldAssignYaml<System::Enum> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<System::String>(fieldInfo, object, node) ||
|
fieldAssignYaml<System::String> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<Vector2> (fieldInfo, object, node) ||
|
fieldAssignYaml<Vector2> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<Vector3> (fieldInfo, object, node) ||
|
fieldAssignYaml<Vector3> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<GameObject> (fieldInfo, object, node) ||
|
fieldAssignYaml<GameObject> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<FontAsset> (fieldInfo, object, node) ||
|
fieldAssignYaml<FontAsset> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<MaterialAsset> (fieldInfo, object, node) ||
|
fieldAssignYaml<MaterialAsset> (fieldInfo, object, node) ||
|
||||||
fieldAssignYaml<MeshAsset> (fieldInfo, object, node);
|
fieldAssignYaml<MeshAsset> (fieldInfo, object, node) ||
|
||||||
|
fieldAssignYaml<RigAsset> (fieldInfo, object, node) ||
|
||||||
|
fieldAssignYaml<AnimationClipAsset>(fieldInfo, object, node);
|
||||||
if (!ASSIGNED)
|
if (!ASSIGNED)
|
||||||
{
|
{
|
||||||
if (ReflectionUtilities::FieldIsList(fieldInfo))
|
if (ReflectionUtilities::FieldIsList(fieldInfo))
|
||||||
|
@ -309,24 +317,26 @@ namespace SHADE
|
||||||
bool SerialisationUtilities::varAssignYaml(System::Object^% object, YAML::Node& node)
|
bool SerialisationUtilities::varAssignYaml(System::Object^% object, YAML::Node& node)
|
||||||
{
|
{
|
||||||
const bool DESERIALISED =
|
const bool DESERIALISED =
|
||||||
varAssignYamlInternal<System::Int16> (object, node) ||
|
varAssignYamlInternal<System::Int16> (object, node) ||
|
||||||
varAssignYamlInternal<System::Int32> (object, node) ||
|
varAssignYamlInternal<System::Int32> (object, node) ||
|
||||||
varAssignYamlInternal<System::Int64> (object, node) ||
|
varAssignYamlInternal<System::Int64> (object, node) ||
|
||||||
varAssignYamlInternal<System::UInt16>(object, node) ||
|
varAssignYamlInternal<System::UInt16> (object, node) ||
|
||||||
varAssignYamlInternal<System::UInt32>(object, node) ||
|
varAssignYamlInternal<System::UInt32> (object, node) ||
|
||||||
varAssignYamlInternal<System::UInt64>(object, node) ||
|
varAssignYamlInternal<System::UInt64> (object, node) ||
|
||||||
varAssignYamlInternal<System::Byte> (object, node) ||
|
varAssignYamlInternal<System::Byte> (object, node) ||
|
||||||
varAssignYamlInternal<bool> (object, node) ||
|
varAssignYamlInternal<bool> (object, node) ||
|
||||||
varAssignYamlInternal<float> (object, node) ||
|
varAssignYamlInternal<float> (object, node) ||
|
||||||
varAssignYamlInternal<double> (object, node) ||
|
varAssignYamlInternal<double> (object, node) ||
|
||||||
varAssignYamlInternal<System::Enum> (object, node) ||
|
varAssignYamlInternal<System::Enum> (object, node) ||
|
||||||
varAssignYamlInternal<System::String>(object, node) ||
|
varAssignYamlInternal<System::String> (object, node) ||
|
||||||
varAssignYamlInternal<Vector2> (object, node) ||
|
varAssignYamlInternal<Vector2> (object, node) ||
|
||||||
varAssignYamlInternal<Vector3> (object, node) ||
|
varAssignYamlInternal<Vector3> (object, node) ||
|
||||||
varAssignYamlInternal<GameObject> (object, node) ||
|
varAssignYamlInternal<GameObject> (object, node) ||
|
||||||
varAssignYamlInternal<FontAsset> (object, node) ||
|
varAssignYamlInternal<FontAsset> (object, node) ||
|
||||||
varAssignYamlInternal<MaterialAsset> (object, node) ||
|
varAssignYamlInternal<MaterialAsset> (object, node) ||
|
||||||
varAssignYamlInternal<MeshAsset> (object, node);
|
varAssignYamlInternal<MeshAsset> (object, node) ||
|
||||||
|
varAssignYamlInternal<RigAsset> (object, node) ||
|
||||||
|
varAssignYamlInternal<AnimationClipAsset>(object, node);
|
||||||
return DESERIALISED;
|
return DESERIALISED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,11 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
fieldNode = MAX_EID;
|
fieldNode = MAX_EID;
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
||||||
std::is_same_v<FieldType, MaterialAsset> ||
|
std::is_same_v<FieldType, MaterialAsset> ||
|
||||||
std::is_same_v<FieldType, MeshAsset>)
|
std::is_same_v<FieldType, MeshAsset> ||
|
||||||
|
std::is_same_v<FieldType, RigAsset> ||
|
||||||
|
std::is_same_v<FieldType, AnimationClipAsset>)
|
||||||
{
|
{
|
||||||
fieldNode = INVALID_ASSET_ID;
|
fieldNode = INVALID_ASSET_ID;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +132,9 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
||||||
std::is_same_v<FieldType, MaterialAsset> ||
|
std::is_same_v<FieldType, MaterialAsset> ||
|
||||||
std::is_same_v<FieldType, MeshAsset>)
|
std::is_same_v<FieldType, MeshAsset> ||
|
||||||
|
std::is_same_v<FieldType, RigAsset> ||
|
||||||
|
std::is_same_v<FieldType, AnimationClipAsset>)
|
||||||
{
|
{
|
||||||
if (object->GetType() == FieldType::typeid)
|
if (object->GetType() == FieldType::typeid)
|
||||||
{
|
{
|
||||||
|
@ -256,7 +260,9 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
else if constexpr (std::is_same_v<FieldType, FontAsset> ||
|
||||||
std::is_same_v<FieldType, MaterialAsset> ||
|
std::is_same_v<FieldType, MaterialAsset> ||
|
||||||
std::is_same_v<FieldType, MeshAsset>)
|
std::is_same_v<FieldType, MeshAsset> ||
|
||||||
|
std::is_same_v<FieldType, RigAsset> ||
|
||||||
|
std::is_same_v<FieldType, AnimationClipAsset>)
|
||||||
{
|
{
|
||||||
if (object->GetType() == FieldType::typeid)
|
if (object->GetType() == FieldType::typeid)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue