+
- void cubos:: engine:: RendererFrame:: draw (RendererGrid grid,
- glm::mat4 modelMat)
+ void cubos:: engine:: RendererFrame:: draw (RendererGrid grid,
+ glm::mat4 modelMat,
+ uint32_t entityIndex)
Submits a draw command.
@@ -155,6 +157,10 @@
modelMat
Model matrix of the grid, used for applying transformations.
+
+ entityIndex
+ Identifier of the entity being drawn.
+
diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html b/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html
index 75d846c3e..87462feca 100644
--- a/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html
+++ b/docs-preview/pr-880/classcubos_1_1engine_1_1SceneBridge.html
@@ -92,7 +92,8 @@
- SceneBridge (core:: reflection:: TypeRegistry components)
+ SceneBridge (core:: reflection:: TypeRegistry components,
+ core:: reflection:: TypeRegistry relations)
Constructs a bridge.
@@ -104,6 +105,10 @@
auto components ( ) -> core:: reflection:: TypeRegistry &
Returns the type registry used to deserialize components.
+
+ auto relations ( ) -> core:: reflection:: TypeRegistry &
+
+
Returns the type registry used to deserialize relations.
Function documentation
-
+
Constructs a bridge.
@@ -139,6 +145,10 @@
components
Component type registry.
+
+ relations
+ Relation type registry.
+
@@ -156,6 +166,20 @@
+
+
+
Returns the type registry used to deserialize relations.
+
+
+
+ Returns
+ Relations type registry.
+
+
+
+
bool cubos:: engine:: SceneBridge:: loadFromFile (Assets & assets,
diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html b/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html
index 75cb4e1d5..d95e11cd9 100644
--- a/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html
+++ b/docs-preview/pr-880/classcubos_1_1engine_1_1ScreenPicker.html
@@ -47,7 +47,7 @@
Resource which provides a texture to store entity/gizmo ids, for selection with a mouse.
diff --git a/docs-preview/pr-880/classcubos_1_1engine_1_1SystemBuilder.html b/docs-preview/pr-880/classcubos_1_1engine_1_1SystemBuilder.html
deleted file mode 100644
index d663adf51..000000000
--- a/docs-preview/pr-880/classcubos_1_1engine_1_1SystemBuilder.html
+++ /dev/null
@@ -1,276 +0,0 @@
-
-
-
-
- cubos::engine::SystemBuilder class | CUBOS. Docs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Used to chain configurations related to systems.
-
- Contents
-
-
-
-
-
-
-
- auto tagged ( const std::string& tag) -> SystemBuilder &
-
- Sets the current system's tag.
-
- auto before ( const std::string& tag) -> SystemBuilder &
-
- Sets the current system to be executed before another tag.
-
- auto after ( const std::string& tag) -> SystemBuilder &
-
- Sets the current system to be executed after another tag.
-
- template<typename F>
- auto runIf ( F func) -> SystemBuilder &
-
- Adds a condition to the current system. If this condition returns false, the system will not be executed. For a system to run, all conditions must return true.
-
-
-
- Function documentation
-
-
- cubos:: engine:: SystemBuilder:: SystemBuilder (core:: ecs:: Dispatcher & dispatcher,
- std::vector<std::string>& tags)
-
-
Construct.
-
-
- Parameters
-
-
-
- dispatcher
- Dispatcher being configured.
-
-
- tags
- Vector which stores the tags for this dispatcher.
-
-
-
-
-
-
- SystemBuilder & cubos:: engine:: SystemBuilder::tagged (const std::string& tag)
-
-
Sets the current system's tag.
-
-
- Parameters
-
-
-
- tag
- Tag to be set.
-
-
-
-
- Returns
- Reference to this object, for chaining.
-
-
-
-
-
-
- SystemBuilder & cubos:: engine:: SystemBuilder::before (const std::string& tag)
-
-
Sets the current system to be executed before another tag.
-
-
- Parameters
-
-
-
- tag
- Tag to be executed before.
-
-
-
-
- Returns
- Reference to this object, for chaining.
-
-
-
-
-
-
- SystemBuilder & cubos:: engine:: SystemBuilder::after (const std::string& tag)
-
-
Sets the current system to be executed after another tag.
-
-
- Parameters
-
-
-
- tag
- Tag to be executed after.
-
-
-
-
- Returns
- Reference to this object, for chaining.
-
-
-
-
-
-
-
- template<typename F>
-
- SystemBuilder & cubos:: engine:: SystemBuilder::runIf (F func)
-
-
Adds a condition to the current system. If this condition returns false, the system will not be executed. For a system to run, all conditions must return true.
-
-
- Template parameters
-
-
-
- F
- Condition system type.
-
-
-
- Parameters
-
-
-
- func
- Condition system.
-
-
-
-
- Returns
- Reference to this object, for chaining.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Unlike everything else in the docs, the search functionality requires JavaScript.
-
-
Search for symbols, directories, files, pages or
- modules. You can omit any prefix from the symbol or file path; adding a
- :
or /
suffix lists all members of given symbol or
- directory.
-
Use ↓
- / ↑ to navigate through the list,
- Enter to go.
- Tab autocompletes common prefix, you can
- copy a link to the result using ⌘
- L while ⌘
- M produces a Markdown link.
-
-
Sorry, nothing was found.
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1SystemFetcher.html b/docs-preview/pr-880/classcubos_1_1engine_1_1old_1_1JSONBridge.html
similarity index 52%
rename from docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1SystemFetcher.html
rename to docs-preview/pr-880/classcubos_1_1engine_1_1old_1_1JSONBridge.html
index 518b53ad9..defea4daa 100644
--- a/docs-preview/pr-880/structcubos_1_1core_1_1ecs_1_1impl_1_1SystemFetcher.html
+++ b/docs-preview/pr-880/classcubos_1_1engine_1_1old_1_1JSONBridge.html
@@ -2,7 +2,7 @@
- cubos::core::ecs::impl::SystemFetcher struct | CUBOS. Docs
+ cubos::engine::old::JSONBridge class | CUBOS. Docs
@@ -46,11 +46,11 @@
-
Fetches the requested data from a world.
+
Bridge for loading and saving assets which are serialized to and from a JSON file.
Template parameters
@@ -58,7 +58,7 @@
T
- System argument type.
+ Type of asset to load and save. Must be default constructible.
@@ -68,150 +68,140 @@
Contents
Reference
-
-
+This bridge automatically serializes and deserializes assets of type T
to and from a JSON file. Thus, T
must be serializable and deserializable. No additional context is given to the serializer or deserializer.
+
+
-
- using Type = char
+
+ class cubos::engine::FileBridge
- Type of the fetched data.
+ Abstract bridge type defined to reduce boilerplate code in bridge implementations which open a single file to load and save assets.
-
-
+
+
- static void add ( SystemInfo & info)
-
- Adds the argument T
to the given info
.
-
- static auto prepare ( World & world) -> State
+ JSONBridge (int indentation = 4)
- Prepares the argument for being executed on the given world
.
+ Constructs a bridge.
+
+
+
Function documentation
-
-
-
- template<typename T>
-
- static void cubos:: core:: ecs:: impl:: SystemFetcher<T>:: add (SystemInfo & info)
-
-
Adds the argument T
to the given info
.
-
-
- Parameters
-
-
-
- info out
- System information.
-
-
-
-
-
+
template<typename T>
- static State cubos:: core:: ecs:: impl:: SystemFetcher<T>:: prepare (World & world)
+ cubos:: engine:: old:: JSONBridge<T>:: JSONBridge (int indentation = 4)
-
Prepares the argument for being executed on the given world
.
+
Constructs a bridge.
Parameters
- world
- World to prepare the argument for.
+ indentation
+ Indentation level to use when saving the JSON file.
-
-
- Returns
- State of the argument.
-
-
+
If the indentation
level is set to -1, all whitespace is removed.
-
+
template<typename T>
- static Type cubos:: core:: ecs:: impl:: SystemFetcher<T>:: fetch (World & world,
- CommandBuffer & commands,
- State & state)
+ bool cubos:: engine:: old:: JSONBridge<T>:: loadFromFile (Assets & assets,
+ const AnyAsset & handle,
+ core:: memory:: Stream & stream) override protected
-
Fetches the data from the given world
.
+
Loads an asset from a file stream.
Parameters
- world
- World to fetch the data from.
+ assets
+ Manager to write into.
- commands
- Buffer where commands can be submitted to.
+ handle
+ Handle of the asset being loaded.
- state
- State of the argument.
+ stream
+ File stream.
Returns
- Fetched data.
+ Whether the asset was successfully loaded.
-
+
template<typename T>
- static T cubos:: core:: ecs:: impl:: SystemFetcher<T>:: arg (Type && fetched)
+ bool cubos:: engine:: old:: JSONBridge<T>:: saveToFile (const Assets & assets,
+ const AnyAsset & handle,
+ core:: memory:: Stream & stream) override protected
-
Converts the fetched data into the actual desired argument.
+
Saves an asset to a file stream.
Parameters
- fetched
- Fetched data.
+ assets
+ Manager to read from.
+
+
+ handle
+ Handle of the asset being saved.
+
+
+ stream
+ File stream.
Returns
- Actual argument.
+ Whether the asset was successfully saved.
diff --git a/docs-preview/pr-880/commands_8hpp.html b/docs-preview/pr-880/commands_8hpp.html
index 3b3e74472..6b0bfdd3e 100644
--- a/docs-preview/pr-880/commands_8hpp.html
+++ b/docs-preview/pr-880/commands_8hpp.html
@@ -2,7 +2,7 @@
-
core/ecs/system/commands.hpp file | CUBOS. Docs
+
core/ecs/system/arguments/commands.hpp file | CUBOS. Docs
@@ -46,7 +46,7 @@
diff --git a/docs-preview/pr-880/cubos_8hpp.html b/docs-preview/pr-880/cubos_8hpp.html
index aaeac5659..797524138 100644
--- a/docs-preview/pr-880/cubos_8hpp.html
+++ b/docs-preview/pr-880/cubos_8hpp.html
@@ -2,7 +2,7 @@
-
engine/cubos.hpp file | CUBOS. Docs
+
core/ecs/cubos.hpp file | CUBOS. Docs
@@ -46,9 +46,9 @@
diff --git a/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html b/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html
index 0d4997d7b..8714db36a 100644
--- a/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html
+++ b/docs-preview/pr-880/dir_26a5878ebb5e9988b6ffa6f152301254.html
@@ -63,11 +63,9 @@
Contents
- file access.hpp
- Struct cubos:: core:: ecs:: QueryAccess .
file data.hpp
Class cubos:: core:: ecs:: QueryData .
- file fetcher.hpp
+ file fetcher.hpp
Class cubos:: core:: ecs:: QueryFetcher .
file filter.hpp
Class cubos:: core:: ecs:: QueryFilter .
diff --git a/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html b/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html
index 3e8fef415..505b7290b 100644
--- a/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html
+++ b/docs-preview/pr-880/dir_3764e76d8ec4e739fc24b5bb90adc3af.html
@@ -71,8 +71,6 @@
Struct cubos:: core:: ecs:: Entity .
file hash.hpp
Struct cubos:: core:: ecs:: EntityHash .
- file manager.hpp
- Class cubos:: core:: ecs:: EntityManager .
file pool.hpp
Class cubos:: core:: ecs:: EntityPool .
diff --git a/docs-preview/pr-880/dir_cae59223029cd41c022c5f7665ca4fec.html b/docs-preview/pr-880/dir_57aff98960b24114775613a58ec786ad.html
similarity index 92%
rename from docs-preview/pr-880/dir_cae59223029cd41c022c5f7665ca4fec.html
rename to docs-preview/pr-880/dir_57aff98960b24114775613a58ec786ad.html
index 7b81f3f1f..c4424bb49 100644
--- a/docs-preview/pr-880/dir_cae59223029cd41c022c5f7665ca4fec.html
+++ b/docs-preview/pr-880/dir_57aff98960b24114775613a58ec786ad.html
@@ -2,7 +2,7 @@
- engine/screenpicker/ directory | CUBOS. Docs
+ engine/screen_picker/ directory | CUBOS. Docs
@@ -46,9 +46,9 @@
- engine / screenpicker/ directory
+ engine / screen_picker/ directory
-
ScreenPicker plugin directory.
+
ScreenPicker plugin directory.
Contents
@@ -63,9 +63,9 @@ Contents
diff --git a/docs-preview/pr-880/dir_649da4752b4164834ba68d7c258c03a8.html b/docs-preview/pr-880/dir_649da4752b4164834ba68d7c258c03a8.html
deleted file mode 100644
index 91863c544..000000000
--- a/docs-preview/pr-880/dir_649da4752b4164834ba68d7c258c03a8.html
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
- core/ecs/component/ directory | CUBOS. Docs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Unlike everything else in the docs, the search functionality requires JavaScript.
-
-
Search for symbols, directories, files, pages or
- modules. You can omit any prefix from the symbol or file path; adding a
- :
or /
suffix lists all members of given symbol or
- directory.
-
Use ↓
- / ↑ to navigate through the list,
- Enter to go.
- Tab autocompletes common prefix, you can
- copy a link to the result using ⌘
- L while ⌘
- M produces a Markdown link.
-
-
Sorry, nothing was found.
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs-preview/pr-880/dir_64a2fed96ae76f57d94061df7c919db3.html b/docs-preview/pr-880/dir_64a2fed96ae76f57d94061df7c919db3.html
new file mode 100644
index 000000000..b4b0937b7
--- /dev/null
+++ b/docs-preview/pr-880/dir_64a2fed96ae76f57d94061df7c919db3.html
@@ -0,0 +1,102 @@
+
+
+
+
+ events/ directory | CUBOS. Docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ events/ directory
+
+
Event arguments.
+
+
+
+
+
+
+
+
+
+
+
+
+
Unlike everything else in the docs, the search functionality requires JavaScript.
+
+
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ :
or /
suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using ⌘
+ L while ⌘
+ M produces a Markdown link.
+
+
Sorry, nothing was found.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs-preview/pr-880/dir_27c6717ecde74b69d41c3436d8bbd6c7.html b/docs-preview/pr-880/dir_69c88e5af9faf72eaf159ee3e83d9db2.html
similarity index 84%
rename from docs-preview/pr-880/dir_27c6717ecde74b69d41c3436d8bbd6c7.html
rename to docs-preview/pr-880/dir_69c88e5af9faf72eaf159ee3e83d9db2.html
index 8bc9bfb6b..f0ec3d8cb 100644
--- a/docs-preview/pr-880/dir_27c6717ecde74b69d41c3436d8bbd6c7.html
+++ b/docs-preview/pr-880/dir_69c88e5af9faf72eaf159ee3e83d9db2.html
@@ -2,7 +2,7 @@
- core/ecs/system/event/ directory | CUBOS. Docs
+ core/ecs/system/arguments/ directory | CUBOS. Docs
@@ -46,9 +46,9 @@
-
Event system arguments directory.
+
System arguments directory.
Contents
@@ -63,12 +63,14 @@ Contents
diff --git a/docs-preview/pr-880/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html b/docs-preview/pr-880/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html
index 9128297e7..0065dba28 100644
--- a/docs-preview/pr-880/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html
+++ b/docs-preview/pr-880/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html
@@ -63,8 +63,8 @@
Contents
diff --git a/docs-preview/pr-880/dir_b6daa990b896c2c0c53126427e4d978d.html b/docs-preview/pr-880/dir_b6daa990b896c2c0c53126427e4d978d.html
index c0a60b716..1ffae93f8 100644
--- a/docs-preview/pr-880/dir_b6daa990b896c2c0c53126427e4d978d.html
+++ b/docs-preview/pr-880/dir_b6daa990b896c2c0c53126427e4d978d.html
@@ -64,8 +64,6 @@ Contents
@@ -80,8 +79,8 @@
Renderer plugin directory.
directory scene /
Scene plugin directory.
- directory screenpicker /
- ScreenPicker plugin directory.
+ directory screen_picker /
+ ScreenPicker plugin directory.
directory settings /
Settings plugin directory.
directory splitscreen /
@@ -94,13 +93,6 @@
Window plugin directory.
-
diff --git a/docs-preview/pr-880/engine_2include_2cubos_2engine_2assets_2bridges_2old_2json_8hpp.html b/docs-preview/pr-880/engine_2include_2cubos_2engine_2assets_2bridges_2old_2json_8hpp.html
new file mode 100644
index 000000000..889f43d3b
--- /dev/null
+++ b/docs-preview/pr-880/engine_2include_2cubos_2engine_2assets_2bridges_2old_2json_8hpp.html
@@ -0,0 +1,133 @@
+
+
+
+
+
engine/assets/bridges/old/json.hpp file | CUBOS. Docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Unlike everything else in the docs, the search functionality requires JavaScript.
+
+
Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ :
or /
suffix lists all members of given symbol or
+ directory.
+
Use ↓
+ / ↑ to navigate through the list,
+ Enter to go.
+ Tab autocompletes common prefix, you can
+ copy a link to the result using ⌘
+ L while ⌘
+ M produces a Markdown link.
+
+
Sorry, nothing was found.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs-preview/pr-880/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html b/docs-preview/pr-880/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html
similarity index 94%
rename from docs-preview/pr-880/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html
rename to docs-preview/pr-880/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html
index a332a7917..2cad6b62c 100644
--- a/docs-preview/pr-880/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html
+++ b/docs-preview/pr-880/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html
@@ -2,7 +2,7 @@
-
engine/screenpicker/plugin.hpp file | CUBOS. Docs
+
engine/screen_picker/plugin.hpp file | CUBOS. Docs
@@ -46,7 +46,7 @@
Plugin entry point.
@@ -74,7 +74,7 @@
- void screenPickerPlugin ( Cubos& cubos)
+ void screenPickerPlugin ( Cubos& cubos)
Plugin entry function.
diff --git a/docs-preview/pr-880/examples-engine-assets-bridge.html b/docs-preview/pr-880/examples-engine-assets-bridge.html
index fdf83afea..c1cc2cefb 100644
--- a/docs-preview/pr-880/examples-engine-assets-bridge.html
+++ b/docs-preview/pr-880/examples-engine-assets-bridge.html
@@ -76,25 +76,20 @@
stream . print ( * contents );
return true ;
}
-}; Now that we have our bridge type, we must register it with the assets manager before using it.
static void bridgeSystem ( Assets & assets )
-{
- // Add a custom bridge to load .txt files.
- assets . registerBridge ( ".txt" , std :: make_unique < TextBridge > ());
-} After this system runs, any time we load an asset whose path ends with .txt
, the assets manager will use our bridge to load it.
In this sample we have a file sample.txt
on the assets/
directory containing the following text:
How are you holding up?
+}; Now that we have our bridge type, we must register it with the assets manager before using it.
cubos . startupSystem ( "setup bridge to load .txt files" ). tagged ( "cubos.assets.bridge" ). call ([]( Assets & assets ) {
+ assets . registerBridge ( ".txt" , std :: make_unique < TextBridge > ());
+ }); After this system runs, any time we load an asset whose path ends with .txt
, the assets manager will use our bridge to load it.
In this sample we have a file sample.txt
on the assets/
directory containing the following text:
How are you holding up?
Because I'm a potato
<clap clap clap> We also have a file sample.txt.meta
, which describes the asset for the engine. In this case, we only need to specify its UUID, which was generated on a UUID generator website :
{
"id": "6f42ae5a-59d1-5df3-8720-83b8df6dd536"
-} Then, we can load it from our code:
// Assets are identified through UUIDs which are defined in their .meta files.
-static const Asset < std :: string > SampleAsset = AnyAsset ( "6f42ae5a-59d1-5df3-8720-83b8df6dd536" );
+}Then, we can load it from our code:
// Assets are identified through UUIDs which are defined in their .meta files.
+ static const Asset < std :: string > SampleAsset = AnyAsset ( "6f42ae5a-59d1-5df3-8720-83b8df6dd536" );
-static void loadSystem ( const Assets & assets )
-{
- // Access the text asset - will be loaded automatically.
- auto text = assets . read ( SampleAsset );
- Stream :: stdOut . print ( * text );
-} Some care must be taken when registering bridges or loading assets during the startup phase. Systems which add bridges should be tagged with cubos.assets.bridge
so that they run before any assets are loaded. Similarly, startup systems which load assets should be tagged with cubos.assets
so that they run after all bridges have been registered.
cubos . addPlugin ( assetsPlugin );
- cubos . startupSystem ( bridgeSystem ). tagged ( "cubos.assets.bridge" );
- cubos . startupSystem ( loadSystem ). tagged ( "cubos.assets" );
+ cubos . startupSystem ( "access .txt asset" ). tagged ( "cubos.assets" ). call ([]( const Assets & assets ) {
+ // Access the text asset - will be loaded automatically.
+ auto text = assets . read ( SampleAsset );
+ Stream :: stdOut . print ( * text );
+ }); Some care must be taken when registering bridges or loading assets during the startup phase. Systems which add bridges should be tagged with cubos.assets.bridge
so that they run before any assets are loaded. Similarly, startup systems which load assets should be tagged with cubos.assets
so that they run after all bridges have been registered.
diff --git a/docs-preview/pr-880/examples-engine-assets-json.html b/docs-preview/pr-880/examples-engine-assets-json.html
index 82a5280fa..a8e390e15 100644
--- a/docs-preview/pr-880/examples-engine-assets-json.html
+++ b/docs-preview/pr-880/examples-engine-assets-json.html
@@ -2,7 +2,7 @@
-
Examples » Engine » Assets » Loading Serializable Assets | CUBOS. Docs
+
Examples » Engine » Assets » Loading Reflectable Assets | CUBOS. Docs
@@ -49,9 +49,9 @@
Examples »
Engine »
Assets »
- Loading Serializable Assets
+ Loading Reflectable Assets
-
Loading serializable assets from JSON.
+
Loading reflectable assets from JSON.
See also Full source code here .
We'll use the following type as an example:
struct Strings
{
CUBOS_REFLECT ;
@@ -61,35 +61,17 @@
CUBOS_REFLECT_IMPL ( Strings )
{
return Type :: create ( "Strings" ). with ( FieldsTrait {}. withField ( "strings" , & Strings :: strings ));
-} We can make it serializable by implementing the following specializations:
template <>
-void cubos :: core :: data :: old :: serialize < Strings > ( Serializer & ser , const Strings & obj , const char * name )
-{
- ser . beginObject ( name );
- ser . write ( obj . strings , "strings" );
- ser . endObject ();
-}
+} Then, we must register a bridge for this type. We provide JSONBridge for easily loading and saving reflectable assets as JSON.
cubos . startupSystem ( "setup bridge to load .strings files" ). tagged ( "cubos.assets.bridge" ). call ([]( Assets & assets ) {
+ assets . registerBridge ( ".strings" , std :: make_unique < JSONBridge < Strings >> ());
+ }); With the bridge registered, we can just load it from its handle:
static const Asset < Strings > SampleAsset = AnyAsset ( "6f42ae5a-59d1-5df3-8720-83b8df6dd536" );
-template <>
-void cubos :: core :: data :: old :: deserialize < Strings > ( Deserializer & des , Strings & obj )
-{
- des . beginObject ();
- des . read ( obj . strings );
- des . endObject ();
-} Then, we must register a bridge for this type. We provide JSONBridge for easily loading and saving serializable assets as JSON.
static void bridgeSystem ( Assets & assets )
-{
- assets . registerBridge ( ".strings" , std :: make_unique < JSONBridge < Strings >> ());
-} With the bridge registered, we can just load it from its handle:
static const Asset < Strings > SampleAsset = AnyAsset ( "6f42ae5a-59d1-5df3-8720-83b8df6dd536" );
-
-static void loadSystem ( Assets & assets )
-{
- auto read = assets . read ( SampleAsset );
- for ( const auto & str : read -> strings )
- {
- Stream :: stdOut . printf ( "String: {} \n " , str );
- }
-} These sytems are configured the usual way, as explained in Introduction and Custom Bridges .
cubos . addPlugin ( assetsPlugin );
- cubos . startupSystem ( bridgeSystem ). tagged ( "cubos.assets.bridge" );
- cubos . startupSystem ( loadSystem ). tagged ( "cubos.assets" );
+
cubos . startupSystem ( "access .strings asset" ). tagged ( "cubos.assets" ). call ([]( Assets & assets ) {
+
auto read = assets . read ( SampleAsset );
+
for ( const auto & str : read -> strings )
+
{
+
Stream :: stdOut . printf ( "String: {} \n " , str );
+
}
+
}); These sytems are configured the usual way, as explained in Introduction and Custom Bridges .
diff --git a/docs-preview/pr-880/examples-engine-assets-saving.html b/docs-preview/pr-880/examples-engine-assets-saving.html
index 7c45a44df..46e4b8954 100644
--- a/docs-preview/pr-880/examples-engine-assets-saving.html
+++ b/docs-preview/pr-880/examples-engine-assets-saving.html
@@ -52,10 +52,9 @@
Creating and Saving
Creating and saving assets.
-
See also Full source code here .
This example demonstrates how a new asset be created programatically and how it can be saved to the assets directory, which is useful while working on tools such as TESSERATOS.
Before we go any further, if we want to save assets to the filesystem, we must allow assets to be modified. This is done through the following setting:
static void configSystem ( Settings & settings )
-{
- // If we want to save assets, we must set this to false.
- settings . setBool ( "assets.io.readOnly" , false ); We'll use the following asset type as an example, with a JSONBridge registered for it with the extension .int
.
struct IntegerAsset
+
See also Full source code here .
This example demonstrates how a new asset can be created programatically and how it can be saved to the assets directory, which is useful while working on tools such as TESSERATOS
Before we go any further, if we want to save assets to the filesystem, we must allow assets to be modified. This is done through the following setting:
cubos . startupSystem ( "configure Assets plugin" ). tagged ( "cubos.settings" ). call ([]( Settings & settings ) {
+ // If we want to save assets, we must set this to false.
+ settings . setBool ( "assets.io.readOnly" , false ); We'll use the following asset type as an example, with a JSONBridge registered for it with the extension .int
.
struct IntegerAsset
{
CUBOS_REFLECT ;
int value ;
@@ -64,12 +63,10 @@
CUBOS_REFLECT_IMPL ( IntegerAsset )
{
return Type :: create ( "IntegerAsset" ). with ( FieldsTrait {}. withField ( "value" , & IntegerAsset :: value ));
-} First, we'll create an asset of this type:
static void saveSystem ( Assets & assets )
-{
- // Create a new asset (with a random UUID).
- auto handle = assets . create ( IntegerAsset { 1337 }); Then, we'll assign it a path and save it. Its important that the path ends with the correct extension, so that Assets knows which bridge to use when loading it.
assets . writeMeta ( handle ) -> set ( "path" , "/assets/sample/sample.int" );
- assets . save ( handle ); With this, the files sample/sample.int
and sample/sample.int.meta
should have appeared on the assets/
directory. The .meta
file contains the UUID of the asset, which is used by the engine to identify it.
Finally, the engine is configured the following way:
cubos . addPlugin ( assetsPlugin );
- cubos . startupSystem ( saveSystem ). tagged ( "cubos.assets" ); Try running the sample yourself to see the files being created!
+} First, we'll create an asset of this type:
cubos . startupSystem ( "create and save asset" ). tagged ( "cubos.assets" ). call ([]( Assets & assets ) {
+ // Create a new asset (with a random UUID).
+ auto handle = assets . create ( IntegerAsset { 1337 }); Then, we'll assign it a path and save it. It's important that the path ends with the correct extension, so that Assets knows which bridge to use when loading it.
assets . writeMeta ( handle ) -> set ( "path" , "/assets/sample/sample.int" );
+ assets . save ( handle ); With this, the files sample/sample.int
and sample/sample.int.meta
should have appeared on the assets/
directory. The .meta
file contains the UUID of the asset, which is used by the engine to identify it.
Try running the sample yourself to see the files being created!
diff --git a/docs-preview/pr-880/examples-engine-assets.html b/docs-preview/pr-880/examples-engine-assets.html
index 5bdfe7c4b..338f3b9eb 100644
--- a/docs-preview/pr-880/examples-engine-assets.html
+++ b/docs-preview/pr-880/examples-engine-assets.html
@@ -51,7 +51,7 @@
Assets
How to use the Assets plugin.
-
+
diff --git a/docs-preview/pr-880/examples-engine-events.html b/docs-preview/pr-880/examples-engine-events.html
index 9d78ba174..8b825c061 100644
--- a/docs-preview/pr-880/examples-engine-events.html
+++ b/docs-preview/pr-880/examples-engine-events.html
@@ -54,34 +54,24 @@
See also Full source code here .
This example shows how the EventReader and the EventWriter system arguments can be used to communicate from one system to another.
Firstly, we need to create and register the event we want to emit. Here, our event is a simple struct with a single field, however, you can use any type you want.
struct MyEvent
{
int value ;
-}; cubos . addEvent < MyEvent > (); To receive these events, we can make a simple system which takes the EventReader system argument and iterates through all the events it has. This will be the layout of all our reader systems (A, C, D).
static void firstSystem ( EventReader < MyEvent > reader )
-{
- for ( const auto & event : reader )
- {
- CUBOS_INFO ( "A read {}" , event . value );
- }
-} Now, to emit these events, we will use the EventWriter system argument. This system will emit 3 events on the first frame and another 3 on the second frame. By setting the value of the ShouldQuit resource to true on the second frame, the engine stops before reaching the third frame.
static void secondSystem ( EventWriter < MyEvent > writer , State & state , ShouldQuit & quit )
-{
- state . step += 1 ;
- if ( state . step == 1 ) // Write 1 2 3 on first run.
- {
- writer . push ({ 1 });
- writer . push ({ 2 });
- writer . push ({ 3 });
- CUBOS_INFO ( "B wrote 1 2 3" );
- }
- else if ( state . step == 2 )
- {
- quit . value = true ; // Stop the loop.
- writer . push ({ 4 });
- writer . push ({ 5 });
- writer . push ({ 6 });
- CUBOS_INFO ( "B wrote 4 5 6" );
- }
-} Lastly, let's set the order we want these system to execute in.
cubos . system ( firstSystem ). tagged ( "A" ). before ( "B" );
- cubos . system ( secondSystem ). tagged ( "B" );
- cubos . system ( thirdSystem ). tagged ( "C" ). after ( "B" );
- cubos . system ( fourthSystem ). tagged ( "D" ). after ( "C" ); These are the expected results with this order.
// Should print:
+}; cubos . addEvent < MyEvent > (); To receive these events, we can make a simple system which takes the EventReader system argument and iterates through all the events it has. This will be the layout of all our reader systems (A, C, D).
Now, to emit these events, we will use the EventWriter system argument. This system will emit 3 events on the first frame and another 3 on the second frame. By setting the value of the ShouldQuit resource to true on the second frame, the engine stops before reaching the third frame.
cubos . system ( "B" ). tagged ( "b" ). call ([]( EventWriter < MyEvent > writer , State & state , ShouldQuit & quit ) {
+ state . step += 1 ;
+ if ( state . step == 1 ) // Write 1 2 3 on first run.
+ {
+ writer . push ({ 1 });
+ writer . push ({ 2 });
+ writer . push ({ 3 });
+ CUBOS_INFO ( "B wrote 1 2 3" );
+ }
+ else if ( state . step == 2 )
+ {
+ quit . value = true ; // Stop the loop.
+ writer . push ({ 4 });
+ writer . push ({ 5 });
+ writer . push ({ 6 });
+ CUBOS_INFO ( "B wrote 4 5 6" );
+ }
+ }); These are the expected results with this order.
// Should print:
// B wrote 1 2 3
// C read 1
// C read 2
diff --git a/docs-preview/pr-880/examples-engine-gizmos.html b/docs-preview/pr-880/examples-engine-gizmos.html
index 1db9fe91d..421fbb3a1 100644
--- a/docs-preview/pr-880/examples-engine-gizmos.html
+++ b/docs-preview/pr-880/examples-engine-gizmos.html
@@ -52,55 +52,56 @@
Using the Gizmos plugin.
This example shows the Gizmos plugin, which allows drawing simple primitives. These are not intended for use in the final product, only in developer tools and for debugging.
The plugin function is included from the engine/ gizmos/ plugin.hpp header.
Cubos cubos { argc , argv };
- cubos . addPlugin ( gizmosPlugin ); To draw a gizmo, all you need to do is to get a reference to the cubos:: engine:: Gizmos resource, and then call the draw function on it for the gizmo you want to draw. Additionally, you can also call the cubos:: engine:: Gizmos:: color function to set the color for future gizmos. So, for example if you want to draw an arrow in a given system, all you need to do is the following:
static void drawStartingLineSystem ( Gizmos & gizmos )
-{
- gizmos . color ({ 1 , 0 , 1 });
- gizmos . drawArrow ( "arrow" , { 0.6F , 0.6F , 0.0F }, { -0.1F , -0.1F , 0.0F }, 0.003F , 0.009F , 0.7F , 10.0F ,
- Gizmos :: Space :: Screen );
-} This code will draw an arrow poiting at the center of the screen, and it will stay there for 10 seconds.
In this other example, we draw lines, a box, and a wire box. Unlike the one in the previous example, this system is not a start-up system, so the draw functions get called every single frame. When this happens, you should set the lifetime of a gizmo to 0, which means it will be drawn for a single frame only. This way we avoid drawing gizmos on top of identical ones that were already there, or in the case of moving gizmos, leaving a trail of old version behind them.
Let's start with the lines. We are using four cameras in our scene, so let's add two lines to separate each camera. These lines will be in Screen space, as we want them to be just drawn once, indepently of the number of cameras; and we want them to use screen coordinates, as they should be drawn in the middle of the screen.
gizmos . color ({ 1.0F , 1.0F , 1.0F });
- gizmos . drawLine ( "separator line" , { 1.0F , 0.5F , 0.5F }, { 0.0F , 0.5F , 0.5F }, 0 , Gizmos :: Space :: Screen );
- gizmos . drawLine ( "separator line" , { 0.5F , 1.0F , 0.5F }, { 0.5F , 0.0F , 0.5F }, 0 , Gizmos :: Space :: Screen ); Let's now add a wireboxe. We want to know were exactly is the centre of each camera, so let's add a reticule. This box will be in View space, as we want it to be drawn once per camera and we want it to use view coordinates, as it should be drawn in the middle of each viewport.
gizmos . color ({ 1.0F , 0.5F , 1.0F });
- gizmos . drawBox ( "box" , { 0.4 , 0.4 , 0 }, { 0.55 , 0.55 , 0 }, 0 , Gizmos :: Space :: View ); Let's add a box. This box will be in World space, as it's the last space left to cover. It will be drawn by any camera that is looking at it, much like if it was an object in the world.
gizmos . color ({ 0.2F , 0.2F , 1.0F });
- gizmos . drawWireBox ( "wire box" , { -5 , -5 , -5 }, { -7 , -7 , -7 }, 0 , Gizmos :: Space :: World ); Finally let's add a cut cone. A cut cone is cylinder with faces that can have different radiuses. If you set one of the bases to have a radius of 0, you'll have a simple cone. If you set them both to have the same radius, you'll have a cylinder. Our cut cone will have different radiuses:
if ( gizmos . hovered ( "cut cone" ))
- {
- gizmos . color ({ 0.25F , 0.15F , 0.5F });
- }
- else if ( gizmos . pressed ( "cut cone" ))
- {
- gizmos . color ({ 0.5F , 0.3F , 1 });
- }
- else
- {
- gizmos . color ({ 0.1F , 0.05F , 0.25F });
- }
+ cubos . addPlugin ( gizmosPlugin ); To draw a gizmo, all you need to do is to get a reference to the cubos:: engine:: Gizmos resource, and then call the draw function on it for the gizmo you want to draw. Additionally, you can also call the cubos:: engine:: Gizmos:: color function to set the color for future gizmos. So, for example if you want to draw an arrow in a given system, all you need to do is the following:
cubos . startupSystem ( "draw line at startup" )
+ . tagged ( "sample.init" )
+ . after ( "cubos.gizmos.init" )
+ . call ([]( Gizmos & gizmos ) {
+ gizmos . color ({ 1 , 0 , 1 });
+ gizmos . drawArrow ( "arrow" , { 0.6F , 0.6F , 0.0F }, { -0.1F , -0.1F , 0.0F }, 0.003F , 0.009F , 0.7F , 10.0F ,
+ Gizmos :: Space :: Screen );
+ }); This code will draw an arrow poiting at the center of the screen, and it will stay there for 10 seconds.
In this other example, we draw lines, a box, and a wire box. Unlike the one in the previous example, this system is not a start-up system, so the draw functions get called every single frame. When this happens, you should set the lifetime of a gizmo to 0, which means it will be drawn for a single frame only. This way we avoid drawing gizmos on top of identical ones that were already there, or in the case of moving gizmos, leaving a trail of old version behind them.
Let's start with the lines. We are using four cameras in our scene, so let's add two lines to separate each camera. These lines will be in Screen space, as we want them to be just drawn once, indepently of the number of cameras; and we want them to use screen coordinates, as they should be drawn in the middle of the screen.
gizmos . color ({ 1.0F , 1.0F , 1.0F });
+ gizmos . drawLine ( "separator line" , { 1.0F , 0.5F , 0.5F }, { 0.0F , 0.5F , 0.5F }, 0 , Gizmos :: Space :: Screen );
+ gizmos . drawLine ( "separator line" , { 0.5F , 1.0F , 0.5F }, { 0.5F , 0.0F , 0.5F }, 0 , Gizmos :: Space :: Screen ); Let's now add a wireboxe. We want to know were exactly is the centre of each camera, so let's add a reticule. This box will be in View space, as we want it to be drawn once per camera and we want it to use view coordinates, as it should be drawn in the middle of each viewport.
gizmos . color ({ 1.0F , 0.5F , 1.0F });
+ gizmos . drawBox ( "box" , { 0.4 , 0.4 , 0 }, { 0.55 , 0.55 , 0 }, 0 , Gizmos :: Space :: View ); Let's add a box. This box will be in World space, as it's the last space left to cover. It will be drawn by any camera that is looking at it, much like if it was an object in the world.
gizmos . color ({ 0.2F , 0.2F , 1.0F });
+ gizmos . drawWireBox ( "wire box" , { -5 , -5 , -5 }, { -7 , -7 , -7 }, 0 , Gizmos :: Space :: World ); Finally let's add a cut cone. A cut cone is cylinder with faces that can have different radiuses. If you set one of the bases to have a radius of 0, you'll have a simple cone. If you set them both to have the same radius, you'll have a cylinder. Our cut cone will have different radiuses:
if ( gizmos . hovered ( "cut cone" ))
+ {
+ gizmos . color ({ 0.25F , 0.15F , 0.5F });
+ }
+ else if ( gizmos . pressed ( "cut cone" ))
+ {
+ gizmos . color ({ 0.5F , 0.3F , 1 });
+ }
+ else
+ {
+ gizmos . color ({ 0.1F , 0.05F , 0.25F });
+ }
- gizmos . drawCutCone ( "cut cone" , { 0.7F , 0.7F , 0.7F }, 5.0F , { -3 , -3 , -3 }, 3.0F , 0 , Gizmos :: Space :: World ); For the cut cone, we'll set the color a bit differently: We'll make it so the color of the cone changes depending on whether you are pressing the cone, or have your mouse over it. We'll make it a bit darker while the mouse is not over the cone, a bit lighter when it is, and even lighter when the cone is pressed.
The whole system looks like this:
static void drawSystem ( Gizmos & gizmos )
-{
- gizmos . color ({ 1.0F , 1.0F , 1.0F });
- gizmos . drawLine ( "separator line" , { 1.0F , 0.5F , 0.5F }, { 0.0F , 0.5F , 0.5F }, 0 , Gizmos :: Space :: Screen );
- gizmos . drawLine ( "separator line" , { 0.5F , 1.0F , 0.5F }, { 0.5F , 0.0F , 0.5F }, 0 , Gizmos :: Space :: Screen );
+ gizmos . drawCutCone ( "cut cone" , { 0.7F , 0.7F , 0.7F }, 5.0F , { -3 , -3 , -3 }, 3.0F , 0 , Gizmos :: Space :: World ); For the cut cone, we'll set the color a bit differently: We'll make it so the color of the cone changes depending on whether you are pressing the cone, or have your mouse over it. We'll make it a bit darker while the mouse is not over the cone, a bit lighter when it is, and even lighter when the cone is pressed.
The whole system looks like this:
cubos . system ( "draw gizmos" ). call ([]( Gizmos & gizmos ) {
+ gizmos . color ({ 1.0F , 1.0F , 1.0F });
+ gizmos . drawLine ( "separator line" , { 1.0F , 0.5F , 0.5F }, { 0.0F , 0.5F , 0.5F }, 0 , Gizmos :: Space :: Screen );
+ gizmos . drawLine ( "separator line" , { 0.5F , 1.0F , 0.5F }, { 0.5F , 0.0F , 0.5F }, 0 , Gizmos :: Space :: Screen );
- gizmos . color ({ 1.0F , 0.5F , 1.0F });
- gizmos . drawBox ( "box" , { 0.4 , 0.4 , 0 }, { 0.55 , 0.55 , 0 }, 0 , Gizmos :: Space :: View );
+ gizmos . color ({ 1.0F , 0.5F , 1.0F });
+ gizmos . drawBox ( "box" , { 0.4 , 0.4 , 0 }, { 0.55 , 0.55 , 0 }, 0 , Gizmos :: Space :: View );
- gizmos . color ({ 0.2F , 0.2F , 1.0F });
- gizmos . drawWireBox ( "wire box" , { -5 , -5 , -5 }, { -7 , -7 , -7 }, 0 , Gizmos :: Space :: World );
+ gizmos . color ({ 0.2F , 0.2F , 1.0F });
+ gizmos . drawWireBox ( "wire box" , { -5 , -5 , -5 }, { -7 , -7 , -7 }, 0 , Gizmos :: Space :: World );
- if ( gizmos . hovered ( "cut cone" ))
- {
- gizmos . color ({ 0.25F , 0.15F , 0.5F });
- }
- else if ( gizmos . pressed ( "cut cone" ))
- {
- gizmos . color ({ 0.5F , 0.3F , 1 });
- }
- else
- {
- gizmos . color ({ 0.1F , 0.05F , 0.25F });
- }
+ if ( gizmos . hovered ( "cut cone" ))
+ {
+ gizmos . color ({ 0.25F , 0.15F , 0.5F });
+ }
+ else if ( gizmos . pressed ( "cut cone" ))
+ {
+ gizmos . color ({ 0.5F , 0.3F , 1 });
+ }
+ else
+ {
+ gizmos . color ({ 0.1F , 0.05F , 0.25F });
+ }
- gizmos . drawCutCone ( "cut cone" , { 0.7F , 0.7F , 0.7F }, 5.0F , { -3 , -3 , -3 }, 3.0F , 0 , Gizmos :: Space :: World );
-}
+ gizmos . drawCutCone ( "cut cone" , { 0.7F , 0.7F , 0.7F }, 5.0F , { -3 , -3 , -3 }, 3.0F , 0 , Gizmos :: Space :: World );
+ });