Nebula
Loading...
Searching...
No Matches
materialdocument.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
21//------------------------------------------------------------------------------
22#if WITH_NEBULA_EDITOR
23#include "editorassets/assetdocument.h"
24#include "dynui/imguicontext.h"
26#include "materials/material.h"
28#include "util/array.h"
29#include "util/dictionary.h"
30
31namespace GraphicsFeature
32{
33
34class MaterialDocument final : public Editor::AssetDocument
35{
37public:
39 virtual ~MaterialDocument();
40
42 void Draw() override;
44 void OnShown(bool shown) override;
46 bool CanSave() const override;
47
49 static void OpenAsset(const IO::Path& asset);
51 static bool CreateAsset(const IO::Path& asset, const IO::URI& workFile, const Util::String& variant, Util::String& outError);
53 static void ListTemplates(Util::Array<Util::String>& out);
54
56 void ApplyValue(uint offset, const void* data, uint size);
59 void ApplyTexture(IndexT slot, const IO::Path& texture);
60
61protected:
62 bool OnOpen() override;
63 void OnClose() override;
64 bool OnSave(Util::String& outError) override;
65
66private:
68 struct Slot
69 {
71 IO::Path texture;
73 IO::Path original;
75 Resources::ResourceId held = Resources::InvalidResourceId;
78 Ids::Id32 imageId = 0;
79 bool hasImageId = false;
80 };
81
83 void Loaded(Resources::ResourceId id);
85 void ReadWorkFile();
87 void DrawTextures(const MaterialTemplatesGPULang::Entry* materialTemplate);
88 void DrawValues(const MaterialTemplatesGPULang::Entry* materialTemplate);
90 void RunPendingTexture();
91
92 Resources::ResourceId resource;
93 Materials::MaterialId material;
94 Graphics::GraphicsEntityId previewObject;
97 Util::Array<ubyte> committed;
99 Util::String workTemplate;
102 IndexT pendingSlot;
103 IO::Path pendingTexture;
104 bool shown;
105};
106
107} // namespace GraphicsFeature
108#endif // WITH_NEBULA_EDITOR
109//------------------------------------------------------------------------------
A material open in the asset editor: its textures and values, edited on the material the scene uses,...
A path is an abstraction around file paths.
Definition path.h:26
An URI object can split a Uniform Resource Identifier string into its components or build a string fr...
Definition uri.h:67
Nebula's dynamic array class.
Definition array.h:61
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:35
Nebula's universal string class.
Definition string.h:50
Definition graphicsfeatureunit.cc:66
uint32_t Id32
Definition id.h:138
#define __DeclareClass(type)
Definition imguicontext.h:54
The graphics entity is only an Id, to which we can attach GraphicsContexts.
Definition graphicsentity.h:16
Definition materialtemplatetypes.h:153
Definition material.h:36
unsigned int uint
Definition types.h:41
int IndexT
Definition types.h:49