Renamed Mesh and Font structs in Managed to MeshAsset and FontAsset and reworked them to be a abstraction for asset IDs
This commit is contained in:
parent
a78b3c0123
commit
719d29dec3
|
@ -0,0 +1,59 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHResourceManagerInterface.cpp
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Nov 22, 2022
|
||||||
|
\brief Contains the definition of the functions of the
|
||||||
|
SHResourceManagerInterface static 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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Header
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Include
|
||||||
|
#include "SHResourceManagerInterface.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "SHResourceManager.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
Handle<SHMesh> SHResourceManagerInterface::LoadOrGetMesh(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHMesh>(assetId);
|
||||||
|
}
|
||||||
|
Handle<SHTexture> SHResourceManagerInterface::LoadOrGetTexture(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHTexture>(assetId);
|
||||||
|
}
|
||||||
|
Handle<SHVkShaderModule> SHResourceManagerInterface::LoadOrGetShaderModule(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHVkShaderModule>(assetId);
|
||||||
|
}
|
||||||
|
Handle<SHMaterialSpec> SHResourceManagerInterface::LoadOrGetMaterialSpec(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHMaterialSpec>(assetId);
|
||||||
|
}
|
||||||
|
Handle<SHMaterial> SHResourceManagerInterface::LoadOrGetMaterial(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHMaterial>(assetId);
|
||||||
|
}
|
||||||
|
Handle<SHFont> SHResourceManagerInterface::LoadOrGetFont(AssetID assetId)
|
||||||
|
{
|
||||||
|
return SHResourceManager::LoadOrGet<SHFont>(assetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Query Functions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
std::optional<AssetID> SHResourceManagerInterface::GetAssetID(Handle<void> handle)
|
||||||
|
{
|
||||||
|
return SHResourceManager::GetAssetID(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> SHResourceManagerInterface::GetAssetName(Handle<void> handle)
|
||||||
|
{
|
||||||
|
return SHResourceManager::GetAssetName(handle);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHResourceManagerInterface.h
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Nov 22, 2022
|
||||||
|
\brief Contains the definition of the SHResourceManagerInterface static 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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// STL Includes
|
||||||
|
#include <optional>
|
||||||
|
// Project Includes
|
||||||
|
#include "SH_API.h"
|
||||||
|
#include "Resource/SHHandle.h"
|
||||||
|
#include "Assets/SHAssetMacros.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Forward Declarations */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
class SHMesh;
|
||||||
|
class SHTexture;
|
||||||
|
class SHVkShaderModule;
|
||||||
|
struct SHMaterialSpec;
|
||||||
|
class SHMaterial;
|
||||||
|
class SHFont;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Type Definitions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Static class providing access to non-templated functions of SHResourceManager for
|
||||||
|
/// SHADE_Managed.
|
||||||
|
/// </summary>
|
||||||
|
class SH_API SHResourceManagerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Loading Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHMesh>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHMesh> LoadOrGetMesh(AssetID assetId);
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHTexture>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId"></param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHTexture> LoadOrGetTexture(AssetID assetId);
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHVkShaderModule>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHVkShaderModule> LoadOrGetShaderModule(AssetID assetId);
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHMaterialSpec>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHMaterialSpec> LoadOrGetMaterialSpec (AssetID assetId);
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHMaterial>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHMaterial> LoadOrGetMaterial(AssetID assetId);
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for SHResourceManager::LoadOrGet<SHFont>().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetId">Asset ID of the resource to load.</param>
|
||||||
|
/// <returns>Handle to the resource to retrieve.</returns>
|
||||||
|
static Handle<SHFont> LoadOrGetFont(AssetID assetId);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Query Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the AssetID associated with a specified Handle.
|
||||||
|
/// Compared to the templated version, this function is slower as it requires
|
||||||
|
/// searching through the storage of all resource types.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handle">Handle to get the AssetID of.</param>
|
||||||
|
/// <return>
|
||||||
|
/// AssetID for the specified Handle. If the Handle is invalid, there will be no
|
||||||
|
/// value.
|
||||||
|
/// </return>
|
||||||
|
static std::optional<AssetID> GetAssetID(Handle<void> handle);
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the name associated with the AssetID that is associated with the
|
||||||
|
/// specified Handle.
|
||||||
|
/// Compared to the templated version, this function is slower as it requires
|
||||||
|
/// searching through the storage of all resource types.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handle">Handle to get the name of.</param>
|
||||||
|
/// <return>
|
||||||
|
/// Name for the specified Handle. If the Handle is invalid, there will be no
|
||||||
|
/// value.
|
||||||
|
/// </return>
|
||||||
|
static std::optional<std::string> GetAssetName(Handle<void> handle);
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
/************************************************************************************//*!
|
|
||||||
\file SHResourceManagerWrapper.cpp
|
|
||||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
|
||||||
\par email: kahwei.tng\@digipen.edu
|
|
||||||
\date Nov 22, 2022
|
|
||||||
\brief Contains the definition of the functions of the SHResourceManagerWraper
|
|
||||||
static 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.
|
|
||||||
*//*************************************************************************************/
|
|
||||||
// Precompiled Header
|
|
||||||
#include "SHpch.h"
|
|
||||||
// Primary Include
|
|
||||||
#include "SHResourceManagerWrapper.h"
|
|
||||||
// Project Includes
|
|
||||||
#include "SHResourceManager.h"
|
|
||||||
|
|
||||||
namespace SHADE
|
|
||||||
{
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
/* Query Functions */
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
std::optional<AssetID> SHResourceManagerWrapper::GetAssetID(Handle<void> handle)
|
|
||||||
{
|
|
||||||
return SHResourceManager::GetAssetID(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<std::string> SHResourceManagerWrapper::GetAssetName(Handle<void> handle)
|
|
||||||
{
|
|
||||||
return SHResourceManager::GetAssetName(handle);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
/************************************************************************************//*!
|
|
||||||
\file SHResourceManagerWrapper.h
|
|
||||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
|
||||||
\par email: kahwei.tng\@digipen.edu
|
|
||||||
\date Nov 22, 2022
|
|
||||||
\brief Contains the definition of the SHResourceManagerWrapper static 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.
|
|
||||||
*//*************************************************************************************/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// STL Includes
|
|
||||||
#include <optional>
|
|
||||||
// Project Includes
|
|
||||||
#include "SH_API.h"
|
|
||||||
#include "Resource/SHHandle.h"
|
|
||||||
#include "Assets/SHAssetMacros.h"
|
|
||||||
|
|
||||||
namespace SHADE
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Static class providing access to non-templated functions of SHResourceManager for
|
|
||||||
/// SHADE_Managed.
|
|
||||||
/// </summary>
|
|
||||||
class SH_API SHResourceManagerWrapper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
|
||||||
/* Query Functions */
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves the AssetID associated with a specified Handle.
|
|
||||||
/// Compared to the templated version, this function is slower as it requires
|
|
||||||
/// searching through the storage of all resource types.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">Handle to get the AssetID of.</param>
|
|
||||||
/// <return>
|
|
||||||
/// AssetID for the specified Handle. If the Handle is invalid, there will be no
|
|
||||||
/// value.
|
|
||||||
/// </return>
|
|
||||||
static std::optional<AssetID> GetAssetID(Handle<void> handle);
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves the name associated with the AssetID that is associated with the
|
|
||||||
/// specified Handle.
|
|
||||||
/// Compared to the templated version, this function is slower as it requires
|
|
||||||
/// searching through the storage of all resource types.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">Handle to get the name of.</param>
|
|
||||||
/// <return>
|
|
||||||
/// Name for the specified Handle. If the Handle is invalid, there will be no
|
|
||||||
/// value.
|
|
||||||
/// </return>
|
|
||||||
static std::optional<std::string> GetAssetName(Handle<void> handle);
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -14,7 +14,9 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Precompiled Headers
|
// Precompiled Headers
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
// Primary Header
|
// Primary Header
|
||||||
#include "Font.hxx"
|
#include "FontAsset.hxx"
|
||||||
|
// External Dependencies
|
||||||
|
#include "Resource/SHResourceManagerInterface.h"
|
||||||
// Project Headers
|
// Project Headers
|
||||||
#include "Utility/Convert.hxx"
|
#include "Utility/Convert.hxx"
|
||||||
|
|
||||||
|
@ -23,20 +25,16 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Handle<SHFont> Font::NativeObject::get()
|
Handle<SHFont> FontAsset::NativeObject::get()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Handle<SHFont>(Convert::ToNative(asset.NativeObjectHandle));
|
return SHResourceManagerInterface::LoadOrGetFont(asset.NativeAssetID);
|
||||||
}
|
}
|
||||||
catch (const BadHandleCastException&)
|
catch (const BadHandleCastException&)
|
||||||
{
|
{
|
||||||
return Handle<SHFont>();
|
return Handle<SHFont>();
|
||||||
}
|
}
|
||||||
GenericHandle Font::NativeObjectHandle::get()
|
AssetID FontAsset::NativeAssetID::get()
|
||||||
{
|
|
||||||
return asset.NativeObjectHandle;
|
|
||||||
}
|
|
||||||
AssetID Font::NativeAssetID::get()
|
|
||||||
{
|
{
|
||||||
return asset.NativeAssetID;
|
return asset.NativeAssetID;
|
||||||
}
|
}
|
||||||
|
@ -44,14 +42,14 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Constructors/Destructor */
|
/* Constructors/Destructor */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Font::Font(Handle<SHFont> font)
|
FontAsset::FontAsset(AssetID fontId)
|
||||||
: asset { Handle<void>(font) }
|
: asset { fontId }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Operator Overloads */
|
/* Operator Overloads */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Font::operator bool(Font asset)
|
FontAsset::operator bool(FontAsset asset)
|
||||||
{
|
{
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
@ -59,13 +57,13 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Conversion Operators */
|
/* Conversion Operators */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Font::operator Asset(Font nativeAsset)
|
FontAsset::operator Asset(FontAsset nativeAsset)
|
||||||
{
|
{
|
||||||
return nativeAsset.asset;
|
return nativeAsset.asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font::operator Font(Asset asset)
|
FontAsset::operator FontAsset(Asset asset)
|
||||||
{
|
{
|
||||||
return Font(Handle<SHFont>(Convert::ToNative(asset.NativeObjectHandle)));
|
return FontAsset(asset.NativeAssetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ namespace SHADE
|
||||||
/// Managed counterpart of the native Font object that can be fed to TextRenderables
|
/// Managed counterpart of the native Font object that can be fed to TextRenderables
|
||||||
/// for rendering.
|
/// for rendering.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public value struct Font
|
public value struct FontAsset
|
||||||
{
|
{
|
||||||
internal:
|
internal:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -40,13 +40,6 @@ namespace SHADE
|
||||||
Handle<SHFont> get();
|
Handle<SHFont> get();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic handle for the native object
|
|
||||||
/// </summary>
|
|
||||||
property GenericHandle NativeObjectHandle
|
|
||||||
{
|
|
||||||
GenericHandle get();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// The raw asset ID of the asset.
|
/// The raw asset ID of the asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property AssetID NativeAssetID
|
property AssetID NativeAssetID
|
||||||
|
@ -60,8 +53,8 @@ namespace SHADE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for the Font.
|
/// Constructor for the Font.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="font">Handle to the font object.</param>
|
/// <param name="fontId">AssetID to the font asset.</param>
|
||||||
Font(Handle<SHFont> font);
|
FontAsset(AssetID fontId);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Operator Overloads */
|
/* Operator Overloads */
|
||||||
|
@ -71,7 +64,7 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gameObj">Asset to check.</param>
|
/// <param name="gameObj">Asset to check.</param>
|
||||||
/// <returns>True if the Asset is valid.</returns>
|
/// <returns>True if the Asset is valid.</returns>
|
||||||
static operator bool(Font asset);
|
static operator bool(FontAsset asset);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Conversion Operators */
|
/* Conversion Operators */
|
||||||
|
@ -80,12 +73,12 @@ namespace SHADE
|
||||||
/// Conversion operator to enable casting from a Font to an Asset.
|
/// Conversion operator to enable casting from a Font to an Asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vec">Vector3 to convert from.</param>
|
/// <param name="vec">Vector3 to convert from.</param>
|
||||||
static explicit operator Asset(Font nativeAsset);
|
static explicit operator Asset(FontAsset nativeAsset);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Conversion operator to enable casting from a Asset to a Font.
|
/// Conversion operator to enable casting from a Asset to a Font.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vec">Vector2 to convert from.</param>
|
/// <param name="asset"></param>
|
||||||
static explicit operator Font(Asset vec);
|
static explicit operator FontAsset(Asset asset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
|
@ -14,7 +14,9 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Precompiled Headers
|
// Precompiled Headers
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
// Primary Header
|
// Primary Header
|
||||||
#include "Mesh.hxx"
|
#include "MeshAsset.hxx"
|
||||||
|
// External Dependencies
|
||||||
|
#include "Resource/SHResourceManagerInterface.h"
|
||||||
// Project Headers
|
// Project Headers
|
||||||
#include "Utility/Convert.hxx"
|
#include "Utility/Convert.hxx"
|
||||||
|
|
||||||
|
@ -23,20 +25,16 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Handle<SHMesh> Mesh::NativeObject::get()
|
Handle<SHMesh> MeshAsset::NativeObject::get()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Handle<SHMesh>(Convert::ToNative(asset.NativeObjectHandle));
|
return SHResourceManagerInterface::LoadOrGetMesh(asset.NativeAssetID);
|
||||||
}
|
}
|
||||||
catch (const BadHandleCastException&)
|
catch (const BadHandleCastException&)
|
||||||
{
|
{
|
||||||
return Handle<SHMesh>();
|
return Handle<SHMesh>();
|
||||||
}
|
}
|
||||||
GenericHandle Mesh::NativeObjectHandle::get()
|
AssetID MeshAsset::NativeAssetID::get()
|
||||||
{
|
|
||||||
return asset.NativeObjectHandle;
|
|
||||||
}
|
|
||||||
AssetID Mesh::NativeAssetID::get()
|
|
||||||
{
|
{
|
||||||
return asset.NativeAssetID;
|
return asset.NativeAssetID;
|
||||||
}
|
}
|
||||||
|
@ -44,14 +42,14 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Constructors/Destructor */
|
/* Constructors/Destructor */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Mesh::Mesh(Handle<SHMesh> Mesh)
|
MeshAsset::MeshAsset(AssetID meshId)
|
||||||
: asset{ Handle<void>(Mesh) }
|
: asset{ meshId }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Operator Overloads */
|
/* Operator Overloads */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Mesh::operator bool(Mesh asset)
|
MeshAsset::operator bool(MeshAsset asset)
|
||||||
{
|
{
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
@ -59,13 +57,13 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Conversion Operators */
|
/* Conversion Operators */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Mesh::operator Asset(Mesh nativeAsset)
|
MeshAsset::operator Asset(MeshAsset nativeAsset)
|
||||||
{
|
{
|
||||||
return nativeAsset.asset;
|
return nativeAsset.asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh::operator Mesh(Asset asset)
|
MeshAsset::operator MeshAsset(Asset asset)
|
||||||
{
|
{
|
||||||
return Mesh(Handle<SHMesh>(Convert::ToNative(asset.NativeObjectHandle)));
|
return MeshAsset(asset.NativeAssetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ namespace SHADE
|
||||||
/// Managed counterpart of the native Mesh object containing vertex data that can
|
/// Managed counterpart of the native Mesh object containing vertex data that can
|
||||||
/// be fed to Renderables for rendering.
|
/// be fed to Renderables for rendering.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public value struct Mesh
|
public value struct MeshAsset
|
||||||
{
|
{
|
||||||
internal:
|
internal:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -40,13 +40,6 @@ namespace SHADE
|
||||||
Handle<SHMesh> get();
|
Handle<SHMesh> get();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic handle for the native object
|
|
||||||
/// </summary>
|
|
||||||
property GenericHandle NativeObjectHandle
|
|
||||||
{
|
|
||||||
GenericHandle get();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// The raw asset ID of the asset.
|
/// The raw asset ID of the asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property AssetID NativeAssetID
|
property AssetID NativeAssetID
|
||||||
|
@ -60,8 +53,8 @@ namespace SHADE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for the Mesh.
|
/// Constructor for the Mesh.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Mesh">Handle to the Mesh object.</param>
|
/// <param name="meshId">AssetID to the Mesh asset.</param>
|
||||||
Mesh(Handle<SHMesh> Mesh);
|
MeshAsset(AssetID meshId);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Operator Overloads */
|
/* Operator Overloads */
|
||||||
|
@ -71,7 +64,7 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gameObj">Asset to check.</param>
|
/// <param name="gameObj">Asset to check.</param>
|
||||||
/// <returns>True if the Asset is valid.</returns>
|
/// <returns>True if the Asset is valid.</returns>
|
||||||
static operator bool(Mesh asset);
|
static operator bool(MeshAsset asset);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Conversion Operators */
|
/* Conversion Operators */
|
||||||
|
@ -80,12 +73,12 @@ namespace SHADE
|
||||||
/// Conversion operator to enable casting from a Mesh to an Asset.
|
/// Conversion operator to enable casting from a Mesh to an Asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vec">Vector3 to convert from.</param>
|
/// <param name="vec">Vector3 to convert from.</param>
|
||||||
static explicit operator Asset(Mesh nativeAsset);
|
static explicit operator Asset(MeshAsset nativeAsset);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Conversion operator to enable casting from a Asset to a Mesh.
|
/// Conversion operator to enable casting from a Asset to a Mesh.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vec">Vector2 to convert from.</param>
|
/// <param name="asset"></param>
|
||||||
static explicit operator Mesh(Asset vec);
|
static explicit operator MeshAsset(Asset asset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
|
@ -18,27 +18,22 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Project Includes
|
// Project Includes
|
||||||
#include "Engine/GenericHandle.hxx"
|
#include "Engine/GenericHandle.hxx"
|
||||||
#include "Utility/Convert.hxx"
|
#include "Utility/Convert.hxx"
|
||||||
#include "Resource/SHResourceManagerWrapper.h"
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
GenericHandle Asset::NativeObjectHandle::get()
|
|
||||||
{
|
|
||||||
return nativeObjHandle;
|
|
||||||
}
|
|
||||||
AssetID Asset::NativeAssetID::get()
|
AssetID Asset::NativeAssetID::get()
|
||||||
{
|
{
|
||||||
return SHResourceManagerWrapper::GetAssetID(Convert::ToNative(nativeObjHandle)).value_or(INVALID_ASSET_ID);
|
return assetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Constructors */
|
/* Constructors */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Asset::Asset(Handle<void> nativeHandle)
|
Asset::Asset(AssetID id)
|
||||||
: nativeObjHandle { Convert::ToCLI(Handle<void>(nativeHandle)) }
|
: assetId { id }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -46,6 +41,6 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
Asset::operator bool(Asset asset)
|
Asset::operator bool(Asset asset)
|
||||||
{
|
{
|
||||||
return asset.nativeObjHandle && asset.NativeAssetID != INVALID_ASSET_ID;
|
return asset.NativeAssetID != INVALID_ASSET_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,13 +31,6 @@ namespace SHADE
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic handle for the native object
|
|
||||||
/// </summary>
|
|
||||||
property GenericHandle NativeObjectHandle
|
|
||||||
{
|
|
||||||
GenericHandle get();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// The raw asset ID of the asset.
|
/// The raw asset ID of the asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property AssetID NativeAssetID
|
property AssetID NativeAssetID
|
||||||
|
@ -51,8 +44,8 @@ namespace SHADE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for the asset.
|
/// Constructor for the asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ptr">Native asset object handle.</param>
|
/// <param name="id">Native asset ID to construct this asset from.</param>
|
||||||
Asset(Handle<void> nativeHandle);
|
explicit Asset(AssetID id);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Operator Overloads */
|
/* Operator Overloads */
|
||||||
|
@ -68,6 +61,6 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Data Members */
|
/* Data Members */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
GenericHandle nativeObjHandle;
|
AssetID assetId;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
SHADE::Mesh^ Renderable::Mesh::get()
|
SHADE::MeshAsset^ Renderable::Mesh::get()
|
||||||
{
|
{
|
||||||
return gcnew SHADE::Mesh(GetNativeComponent()->GetMesh());
|
return gcnew SHADE::MeshAsset(GetNativeComponent()->GetMesh());
|
||||||
}
|
}
|
||||||
void Renderable::Mesh::set(SHADE::Mesh^ value)
|
void Renderable::Mesh::set(SHADE::MeshAsset^ value)
|
||||||
{
|
{
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Math/Quaternion.hxx"
|
#include "Math/Quaternion.hxx"
|
||||||
// External Dependencies
|
// External Dependencies
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
||||||
#include "Assets/Mesh.hxx"
|
#include "Assets/MeshAsset.hxx"
|
||||||
#include "Assets/Material.hxx"
|
#include "Assets/Material.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -48,10 +48,10 @@ namespace SHADE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mesh used to render this Renderable.
|
/// Mesh used to render this Renderable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property SHADE::Mesh^ Mesh
|
property SHADE::MeshAsset^ Mesh
|
||||||
{
|
{
|
||||||
SHADE::Mesh^ get();
|
SHADE::MeshAsset^ get();
|
||||||
void set(SHADE::Mesh^ value);
|
void set(SHADE::MeshAsset^ value);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Material used to render this Renderable.
|
/// Material used to render this Renderable.
|
||||||
|
|
|
@ -39,11 +39,11 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetText(Convert::ToNative(value));
|
GetNativeComponent()->SetText(Convert::ToNative(value));
|
||||||
}
|
}
|
||||||
SHADE::Font^ TextRenderable::Font::get()
|
SHADE::FontAsset^ TextRenderable::Font::get()
|
||||||
{
|
{
|
||||||
return gcnew SHADE::Font(GetNativeComponent()->GetFont());
|
return gcnew SHADE::FontAsset(GetNativeComponent()->GetFont());
|
||||||
}
|
}
|
||||||
void TextRenderable::Font::set(SHADE::Font^ value)
|
void TextRenderable::Font::set(SHADE::FontAsset^ value)
|
||||||
{
|
{
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Components/Component.hxx"
|
#include "Components/Component.hxx"
|
||||||
#include "Math/Vector3.hxx"
|
#include "Math/Vector3.hxx"
|
||||||
#include "Math/Quaternion.hxx"
|
#include "Math/Quaternion.hxx"
|
||||||
#include "Assets/Font.hxx"
|
#include "Assets/FontAsset.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -55,10 +55,10 @@ namespace SHADE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Font to use to render using this TextRenderable.
|
/// Font to use to render using this TextRenderable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property SHADE::Font^ Font
|
property SHADE::FontAsset^ Font
|
||||||
{
|
{
|
||||||
SHADE::Font^ get();
|
SHADE::FontAsset^ get();
|
||||||
void set(SHADE::Font^ value);
|
void set(SHADE::FontAsset^ value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue