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
47 Resources::ResourceUnknownId InitializeResource(Ids::Id32 entry, const Util::StringAtom& tag, const Ptr<IO::Stream>& stream, bool immediate = false) override;
49 void Unload(const Resources::ResourceId id) override;
50
52 uint StreamResource(const Resources::ResourceId entry, IndexT frameIndex, uint requestedBits) override;
54 uint LodMask(const Ids::Id32 entry, float lod, bool stream) 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
uint LodMask(const Ids::Id32 entry, float lod, bool stream) const override
Create load mask based on LOD.
Definition modelloader.cc:211
ModelLoader()
constructor
Definition modelloader.cc:24
void Unload(const Resources::ResourceId id) override
unload resource
Definition modelloader.cc:179
Util::Dictionary< Util::FourCC, std::function< Models::ModelNode *()> > nodeConstructors
used for looking up constructors
Definition modelloader.h:57
Resources::ResourceUnknownId InitializeResource(Ids::Id32 entry, const Util::StringAtom &tag, const Ptr< IO::Stream > &stream, bool immediate=false) override
perform actual load, override in subclass
Definition modelloader.cc:61
void Setup() override
setup resource loader, initiates the placeholder and error resources if valid
Definition modelloader.cc:41
uint StreamResource(const Resources::ResourceId entry, IndexT frameIndex, uint requestedBits) override
Stream texture.
Definition modelloader.cc:197
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:58
Util::FixedArray< uint > requestedBits
Definition resourceloader.h:244
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 StringAtom.
Definition stringatom.h:22
uint32_t Id32
Definition id.h:138
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 resourceid.h:37
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48