18#include "aeongames/ProtoBufHelpers.hpp"
19#include "aeongames/Node.hpp"
20#include "aeongames/Mesh.hpp"
21#include "aeongames/Pipeline.hpp"
22#include "aeongames/Material.hpp"
23#include "aeongames/Skeleton.hpp"
24#include "aeongames/Animation.hpp"
25#include "aeongames/Utilities.hpp"
26#include "aeongames/ProtoBufHelpers.hpp"
27#include "aeongames/ProtoBufUtils.hpp"
28#include "aeongames/CRC.hpp"
29#include "aeongames/AeonEngine.hpp"
30#include "aeongames/ResourceCache.hpp"
31#include "aeongames/Renderer.hpp"
32#include "aeongames/Model.hpp"
34#pragma warning( push )
35#pragma warning( disable : PROTOBUF_WARNINGS )
60 if ( aModelMsg.has_default_pipeline() )
62 default_pipeline = {
"Pipeline"_crc32,
GetReferenceMsgId ( aModelMsg.default_pipeline() ) } ;
63 default_pipeline.
Store();
67 if ( aModelMsg.has_default_material() )
69 default_material = {
"Material"_crc32,
GetReferenceMsgId ( aModelMsg.default_material() ) } ;
70 default_material.
Store();
74 if ( aModelMsg.has_skeleton() )
80 mAssemblies.reserve ( aModelMsg.assembly_size() );
81 for (
auto& assembly : aModelMsg.assembly() )
87 if ( assembly.has_mesh() )
93 if ( assembly.has_pipeline() )
99 if ( assembly.has_material() )
104 mAssemblies.emplace_back ( mesh, pipeline, material );
107 mAnimations.reserve ( aModelMsg.animation_size() );
108 for (
auto& animation : aModelMsg.animation() )
138 for (
const auto& i : mAssemblies )
140 aRenderer.
LoadMesh ( *std::get<0> ( i ).Cast<Mesh>() );
141 aRenderer.
LoadPipeline ( *std::get<1> ( i ).Cast<Pipeline>() );
142 aRenderer.
LoadMaterial ( *std::get<2> ( i ).Cast<Material>() );
148 for (
const auto& i : mAssemblies )
150 aRenderer.
UnloadMesh ( *std::get<0> ( i ).Cast<Mesh>() );
Provides the DLL_PROTOBUF export/import macro for protobuf wrapper classes.
DLL const Skeleton * GetSkeleton() const
Get the skeleton associated with this model.
DLL void Unload() final
Unload model data and free resources.
DLL void LoadFromPBMsg(const ModelMsg &aModelMsg)
Load model data from a protobuf message.
DLL void LoadFromMemory(const void *aBuffer, size_t aBufferSize) final
Load model data from a memory buffer.
DLL void LoadRendererResources(Renderer &aRenderer) const
Load renderer-specific resources for this model.
DLL const std::vector< Assembly > & GetAssemblies() const
Get the list of assemblies that compose this model.
DLL void UnloadRendererResources(Renderer &aRenderer) const
Unload renderer-specific resources for this model.
DLL const std::vector< ResourceId > & GetAnimations() const
Get the list of animation resource identifiers.
Abstract base class for rendering backends.
virtual void UnloadPipeline(const Pipeline &aPipeline)=0
Unloads a rendering pipeline from the renderer.
virtual void LoadPipeline(const Pipeline &aPipeline)=0
Loads a rendering pipeline (shaders and state) into the renderer.
virtual void UnloadMaterial(const Material &aMaterial)=0
Unloads material data from the renderer.
virtual void LoadMaterial(const Material &aMaterial)=0
Loads material data into the renderer.
virtual void LoadMesh(const Mesh &aMesh)=0
Loads mesh data into GPU memory.
virtual void UnloadMesh(const Mesh &aMesh)=0
Unloads mesh data from GPU memory.
Identifies a resource by its type and path CRC32 hashes.
void Store() const
Construct and store the resource in the cache if not already present.
Skeletal animation resource containing a hierarchy of joints.
<- This is here just for the literals
DLL uint32_t GetReferenceMsgId(const ReferenceMsg &reference_buffer)
Retrieve the identifier from a ReferenceMsg.
void LoadFromProtoBufObject(T &aTarget, const void *aBuffer, size_t aBufferSize)
Loads a Protocol Buffer message from a buffer and populates a target object.