NDEVR
API Documentation
Scene.h
1#pragma once
2#include <NDEVR/Model.h>
3namespace NDEVR
4{
9 {
10 public:
16 virtual bool onModel(Model&) { return true; }
22 virtual bool onLayer(Model&) { return true; }
28 virtual bool onGeometry(Geometry&) { return true; }
34 virtual bool onMaterial(Material&) { return true; }
40 virtual bool onEffect(Effect&) { return true; }
41 bool include_deleted = false;
42 bool root_only = true;
43 bool include_scene = true;
44 };
45
51 class NDEVR_DESIGN_API Scene : public Model
52 {
53 public:
57 Scene();//Invalid object
63 Scene(const TranslatedString& name, DesignObjectBase* base = nullptr);
69 Scene(const File& file, DesignObjectBase* base = nullptr);
70 Scene(const String& file, DesignObjectBase* base = nullptr) = delete;
86 explicit Scene(const Model& model);
87
97 bool hasVertexColumn(const StringView& name) const;
103 bool hasVertexColumn(VertexProperty property) const;
113 bool isApplicationOwned() const;
119 void deleteBase() const;
129 Buffer<UUID> allObjectIDs(bool include_deleted) const;
136 [[nodiscard]] Model findLayerByName(const StringView& name, bool allow_deleted = false) const;
143 [[nodiscard]] Model findLayerByName(const TranslatedString& name, bool allow_deleted = false) const;
148 void iterateAll(SceneIterator& iterator);
160 const TableColumn& vertexColumn(const StringView& name) const;
177 static const Scene CreateApplicationScene(const TranslatedString& string);
178 };
179
182 template<>
183 struct ObjectInfo<Scene, false, false>
184 {
185 static const uint01 Dimensions = 0;
186 static const bool Vector = false;
187 static const bool Buffer = false;
188 static const bool Primitive = true;
189 static const bool Pointer = false;
190 static const bool Unsigned = false;
191 static const bool Float = false;
192 static const bool Integer = false;
193 static const bool Number = false;
194 static const bool Enum = false;
195 static const bool String = false;
196 static const bool Color = false;
197 static const bool Boolean = false;
203 };
204}
205namespace std//Define things to allow use within std libs
206{
210 template <>
211 struct hash<Scene>
212 {
218 std::size_t operator()(const Scene& d) const noexcept
219 {
220 UUID s = d.get<NDPO::guid>();
221 std::size_t value = 0;
222 for (uint01 i = 0; i < 8; i++)
223 value = value * 256 + (s[i + 0U] ^ s[i + 8U]);
224 return value;
225 }
226 };
227}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides the underlying data storage for the NDEVR Scene Model hierarchy.
File file() const
Returns the file path associated with this design object as a File object.
DesignObjectBase & base() const
Returns a reference to the underlying DesignObjectBase database.
A core class that provides a dynamic effect to an object in a model hierarchy.
Definition Effect.h:158
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
A core class that represents a node on model hierarchy.
Definition Model.h:292
Model()
Default constructor. Creates an uninitialized Model.
Definition Model.h:365
Allows quick iteration of all scene objects.
Definition Scene.h:9
virtual bool onMaterial(Material &)
Called for each Material encountered during iteration.
Definition Scene.h:34
virtual bool onModel(Model &)
Called for each Model encountered during iteration.
Definition Scene.h:16
bool include_scene
Whether to include the Scene itself in iteration.
Definition Scene.h:43
bool root_only
Whether to iterate only root-level objects.
Definition Scene.h:42
bool include_deleted
Whether to visit deleted objects during iteration.
Definition Scene.h:41
virtual bool onLayer(Model &)
Called for each layer Model encountered during iteration.
Definition Scene.h:22
virtual bool onGeometry(Geometry &)
Called for each Geometry encountered during iteration.
Definition Scene.h:28
virtual bool onEffect(Effect &)
Called for each Effect encountered during iteration.
Definition Scene.h:40
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Scene.h:52
Buffer< UUID > allObjectIDs(bool include_deleted) const
Collects the UUIDs of all objects in this Scene.
bool isApplicationOwned() const
Checks whether this Scene is owned by the application (as opposed to user-created).
TableColumn & vertexColumn(const StringView &name)
Retrieves a mutable reference to the vertex column with the given name.
bool hasVertexColumn(VertexProperty property) const
Checks whether any Geometry in this Scene has a vertex column for the given property.
Scene(const File &file, DesignObjectBase *base=nullptr)
Constructs a new Scene associated with the given file.
const TableColumn & vertexColumn(const StringView &name) const
Retrieves a const reference to the vertex column with the given name.
Model findLayerByName(const TranslatedString &name, bool allow_deleted=false) const
Searches for a layer by translated name within this Scene.
static const Scene CreateApplicationScene(const TranslatedString &string)
Creates a Scene that is owned by the application rather than the user.
Scene()
Constructs an invalid Scene object with no backing data.
void iterateAll(SceneIterator &iterator)
Iterates over all objects in this Scene, calling the appropriate callback on the iterator.
Scene(uint04 idx, DesignObjectBase *base)
Constructs a Scene referencing an existing object by index within a DesignObjectBase.
Scene(const String &file, DesignObjectBase *base=nullptr)=delete
Deleted to prevent implicit String-to-File conversion.
void cleanupMemory()
Releases unused memory held by this Scene's underlying data structures.
bool hasVertexIndexColumn() const
Checks whether any Geometry in this Scene has a vertex index column.
Scene(DesignObjectBase *base)
Constructs a Scene that wraps an existing DesignObjectBase.
Scene(const Model &model)
Constructs a Scene by explicitly converting from a Model.
void createDefaultMaterial()
Creates the default Material for this Scene if one does not already exist.
const TableColumn & vertexIndexColumn() const
Retrieves a const reference to the vertex index column.
const TableColumn & vertexColumn(VertexProperty property) const
Retrieves a const reference to the vertex column for the given property.
void deleteBase() const
Deletes the underlying DesignObjectBase, freeing all associated data.
Model findLayerByName(const StringView &name, bool allow_deleted=false) const
Searches for a layer by name within this Scene.
Scene(const TranslatedString &name, DesignObjectBase *base=nullptr)
Constructs a new Scene with the given display name.
bool hasVertexColumn(const StringView &name) const
Checks whether any Geometry in this Scene has a vertex column with the given name.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:86
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
VertexProperty
Per-vertex data channels that can be stored in the vertex table to be used by Geometry.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ guid
A 128-bit globally unique identifier for the object.
STL namespace.
static const uint01 Dimensions
Number of dimensions (0 for non-spatial types).
Definition Scene.h:185
static const bool Unsigned
Whether this type is unsigned.
Definition Scene.h:190
static const bool Primitive
Whether this type is a primitive.
Definition Scene.h:188
static const bool Enum
Whether this type is an enum.
Definition Scene.h:194
static const bool Buffer
Whether this type is a buffer.
Definition Scene.h:187
static const bool Float
Whether this type is a floating-point type.
Definition Scene.h:191
static const bool Number
Whether this type is numeric.
Definition Scene.h:193
static constexpr ObjectInfo< Scene, false, false > VectorSub()
Returns the ObjectInfo for the vector sub-type (identity for Scene).
Definition Scene.h:202
static const bool Color
Whether this type is a color.
Definition Scene.h:196
static const bool Vector
Whether this type is a vector.
Definition Scene.h:186
static const bool Boolean
Whether this type is a boolean.
Definition Scene.h:197
static const bool String
Whether this type is a string.
Definition Scene.h:195
static const bool Pointer
Whether this type is a pointer.
Definition Scene.h:189
static const bool Integer
Whether this type is an integer.
Definition Scene.h:192
Information about the object.
Definition ObjectInfo.h:55