Nebula
Loading...
Searching...
No Matches
modelloader.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
10#include "core/refcounted.h"
12#include "util/stack.h"
13#include "model.h"
16
17namespace Visibility
18{
19class VisibilityContext;
20}
21namespace Models
22{
23
24class ModelNode;
25class ModelContext;
27{
29public:
33 virtual ~ModelLoader();
34
36 void Setup() override;
37
38private:
39 friend class PrimitiveNode;
40 friend class CharacterNode;
41 friend class CharacterSkinNode;
42 friend class ParticleSystemNode;
45
49 void Unload(const Resources::ResourceId id) override;
50
54 uint LodMask(const _StreamData& stream, float lod, bool async) const override;
55
58
59#define IMPLEMENT_NODE_ALLOCATOR(FourCC, Type) \
60 nodeConstructors.Add(FourCC, []() -> Models::ModelNode* { \
61 Models::ModelNode* node = (Models::ModelNode*)Memory::Alloc(Memory::ObjectHeap, sizeof(Models::Type)); \
62 new (node) Models::Type; \
63 return node; \
64 });
65
66};
67
69const Util::Array<Models::ModelNode*>& ModelGetNodes(const ModelId id);
70
71} // namespace Models
Definition characternode.h:21
Definition characterskinnode.h:19
Definition modelcontext.h:58
Definition modelloader.h:27
ResourceStreamOutput StreamResource(const ResourceLoadJob &job) override
Stream texture.
Definition modelloader.cc:198
ModelLoader()
constructor
Definition modelloader.cc:24
ResourceLoader::ResourceInitOutput InitializeResource(const ResourceLoadJob &job, const Ptr< IO::Stream > &stream) override
perform actual load, override in subclass
Definition modelloader.cc:61
void Unload(const Resources::ResourceId id) override
unload resource
Definition modelloader.cc:180
Util::Dictionary< Util::FourCC, std::function< Models::ModelNode *()> > nodeConstructors
used for looking up constructors
Definition modelloader.h:57
void Setup() override
setup resource loader, initiates the placeholder and error resources if valid
Definition modelloader.cc:41
uint LodMask(const _StreamData &stream, float lod, bool async) const override
Create load mask based on LOD.
Definition modelloader.cc:215
virtual ~ModelLoader()
destructor
Definition modelloader.cc:32
__DeclareClass(ModelLoader)
friend class Visibility::VisibilityContext
Definition modelloader.h:44
Definition modelnode.h:54
Definition particlesystemnode.h:23
Definition primitivenode.h:18
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Definition resourceloader.h:60
bool async
Definition resourceloader.h:291
Nebula's dynamic array class.
Definition array.h:60
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:34
A four-character-code is a quasi-human-readable 32-bit-id.
Definition fourcc.h:19
A model resource consists of nodes, each of which inhibit some information read from an ....
Definition model.cc:10
const Util::Array< Models::ModelNode * > & ModelGetNodes(const ModelId id)
Get model nodes.
Definition model.cc:41
Implements a resource loader for models.
Definition modelcontext.h:35
Definition resourceloader.h:134
Definition resourceloader.h:140
Definition resourceloader.h:164
unsigned int uint
Definition types.h:31