+
- 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-862/classcubos_1_1engine_1_1ScreenPicker.html b/docs-preview/pr-862/classcubos_1_1engine_1_1ScreenPicker.html
index 75cb4e1d5..d95e11cd9 100644
--- a/docs-preview/pr-862/classcubos_1_1engine_1_1ScreenPicker.html
+++ b/docs-preview/pr-862/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-862/column_8hpp.html b/docs-preview/pr-862/column_8hpp.html
new file mode 100644
index 000000000..dee6541e3
--- /dev/null
+++ b/docs-preview/pr-862/column_8hpp.html
@@ -0,0 +1,134 @@
+
+
+
+
+ core/ecs/table/column.hpp file | CUBOS. Docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Struct cubos::core::ecs::DenseTableId.
+
+ Contents
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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-862/command__buffer_8hpp.html b/docs-preview/pr-862/command__buffer_8hpp.html
new file mode 100644
index 000000000..709ef6a7e
--- /dev/null
+++ b/docs-preview/pr-862/command__buffer_8hpp.html
@@ -0,0 +1,136 @@
+
+
+
+
+ core/ecs/command_buffer.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-862/commands_8hpp.html b/docs-preview/pr-862/commands_8hpp.html
index cc0349335..3b3e74472 100644
--- a/docs-preview/pr-862/commands_8hpp.html
+++ b/docs-preview/pr-862/commands_8hpp.html
@@ -48,7 +48,7 @@
- Class cubos:: core:: ecs:: Commands and related types.
+ Class cubos:: core:: ecs:: Commands .
Contents
diff --git a/docs-preview/pr-862/cubos_8hpp.html b/docs-preview/pr-862/cubos_8hpp.html
index aaeac5659..d701d7f23 100644
--- a/docs-preview/pr-862/cubos_8hpp.html
+++ b/docs-preview/pr-862/cubos_8hpp.html
@@ -2,7 +2,7 @@
-
engine/cubos.hpp file | CUBOS. Docs
+
core/ecs/cubos.hpp file | CUBOS. Docs
@@ -46,9 +46,9 @@
- engine / cubos.hpp file
+ core /ecs / cubos.hpp file
-
Class cubos:: engine:: Cubos .
+
Class cubos:: engine:: Cubos .
Contents
@@ -66,35 +66,37 @@
namespace cubos
CUBOS . libraries namespace.
- namespace cubos::engine
- Engine module.
+ namespace cubos::core
+ Core namespace.
+ namespace cubos::core::ecs
+ ECS module.
- struct cubos::engine::DeltaTime
+ struct cubos::core::ecs::DeltaTime
Resource which stores the time since the last iteration of the main loop started.
- struct cubos::engine::ShouldQuit
+ struct cubos::core::ecs::ShouldQuit
Resource used as a flag to indicate whether the main loop should stop running.
- struct cubos::engine::Arguments
+ struct cubos::core::ecs::Arguments
Resource which stores the command-line arguments.
- class cubos::engine::TagBuilder
+ class cubos::core::ecs::TagBuilder
Used to chain configurations related to tags.
- class cubos::engine::SystemBuilder
+ class cubos::core::ecs::SystemBuilder
Used to chain configurations related to systems.
- class cubos::engine::Cubos
+ class cubos::core::ecs::Cubos
Represents the engine itself, and exposes the interface with which the game developer interacts with. Ties up all the different parts of the engine together.
diff --git a/docs-preview/pr-862/data_8hpp.html b/docs-preview/pr-862/data_8hpp.html
new file mode 100644
index 000000000..0b64cd270
--- /dev/null
+++ b/docs-preview/pr-862/data_8hpp.html
@@ -0,0 +1,135 @@
+
+
+
+
+ core/ecs/query/data.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-862/dense_2registry_8hpp.html b/docs-preview/pr-862/dense_2registry_8hpp.html
new file mode 100644
index 000000000..929f2f20e
--- /dev/null
+++ b/docs-preview/pr-862/dense_2registry_8hpp.html
@@ -0,0 +1,134 @@
+
+
+
+
+ core/ecs/table/dense/registry.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-862/dense_2table_8hpp.html b/docs-preview/pr-862/dense_2table_8hpp.html
new file mode 100644
index 000000000..c6a5eb9e1
--- /dev/null
+++ b/docs-preview/pr-862/dense_2table_8hpp.html
@@ -0,0 +1,134 @@
+
+
+
+
+ core/ecs/table/dense/table.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-862/dir_0b39c986537c7114081f36bbdae17547.html b/docs-preview/pr-862/dir_0b39c986537c7114081f36bbdae17547.html
new file mode 100644
index 000000000..ccb9f5124
--- /dev/null
+++ b/docs-preview/pr-862/dir_0b39c986537c7114081f36bbdae17547.html
@@ -0,0 +1,132 @@
+
+
+
+
+ core/ecs/table/ directory | CUBOS. Docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ core /ecs / table/ directory
+
+
Table directory.
+
+ Contents
+
+
+
+
+
+ directory dense /
+ Dense storage types.
+ directory sparse_relation /
+ Sparse relation storage types.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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-862/dir_1849b6590c20a7c40f18c0337f505edf.html b/docs-preview/pr-862/dir_1849b6590c20a7c40f18c0337f505edf.html
index da57d9ee1..0e3bdc045 100644
--- a/docs-preview/pr-862/dir_1849b6590c20a7c40f18c0337f505edf.html
+++ b/docs-preview/pr-862/dir_1849b6590c20a7c40f18c0337f505edf.html
@@ -71,14 +71,12 @@
- file accessors.hpp
- Class cubos:: core:: ecs:: Read and related types.
file commands.hpp
- Class cubos:: core:: ecs:: Commands and related types.
+ Class cubos:: core:: ecs:: Commands .
file dispatcher.hpp
Class cubos:: core:: ecs:: Dispatcher .
file query.hpp
- Class cubos:: core:: ecs:: Query and related types.
+ Class cubos:: core:: ecs:: Query .
file system.hpp
Class cubos:: core:: ecs:: SystemWrapper and related types.
diff --git a/docs-preview/pr-862/dir_26a5878ebb5e9988b6ffa6f152301254.html b/docs-preview/pr-862/dir_26a5878ebb5e9988b6ffa6f152301254.html
new file mode 100644
index 000000000..0d4997d7b
--- /dev/null
+++ b/docs-preview/pr-862/dir_26a5878ebb5e9988b6ffa6f152301254.html
@@ -0,0 +1,130 @@
+
+
+
+
+ core/ecs/query/ directory | CUBOS. Docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ core /ecs / query/ directory
+
+
Query directory.
+
+ Contents
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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-862/dir_3764e76d8ec4e739fc24b5bb90adc3af.html b/docs-preview/pr-862/dir_3764e76d8ec4e739fc24b5bb90adc3af.html
index 61630b2e1..3e8fef415 100644
--- a/docs-preview/pr-862/dir_3764e76d8ec4e739fc24b5bb90adc3af.html
+++ b/docs-preview/pr-862/dir_3764e76d8ec4e739fc24b5bb90adc3af.html
@@ -63,12 +63,18 @@ Contents
diff --git a/docs-preview/pr-862/dir_cae59223029cd41c022c5f7665ca4fec.html b/docs-preview/pr-862/dir_57aff98960b24114775613a58ec786ad.html
similarity index 92%
rename from docs-preview/pr-862/dir_cae59223029cd41c022c5f7665ca4fec.html
rename to docs-preview/pr-862/dir_57aff98960b24114775613a58ec786ad.html
index 7b81f3f1f..c4424bb49 100644
--- a/docs-preview/pr-862/dir_cae59223029cd41c022c5f7665ca4fec.html
+++ b/docs-preview/pr-862/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-862/dir_649da4752b4164834ba68d7c258c03a8.html b/docs-preview/pr-862/dir_649da4752b4164834ba68d7c258c03a8.html
index 8d06c96d5..91863c544 100644
--- a/docs-preview/pr-862/dir_649da4752b4164834ba68d7c258c03a8.html
+++ b/docs-preview/pr-862/dir_649da4752b4164834ba68d7c258c03a8.html
@@ -65,8 +65,6 @@
file manager.hpp
Class cubos:: core:: ecs:: ComponentManager and related types.
- file reflection.hpp
- Class cubos:: core:: ecs:: ComponentTypeBuilder .
file storage.hpp
Class cubos:: core:: ecs:: Storage and related types.
diff --git a/docs-preview/pr-862/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html b/docs-preview/pr-862/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html
index 9128297e7..0065dba28 100644
--- a/docs-preview/pr-862/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html
+++ b/docs-preview/pr-862/dir_6e3f4c3139d5f8b4a400c5df04d1a451.html
@@ -63,8 +63,8 @@ Contents
diff --git a/docs-preview/pr-862/group__core-ecs-relation.html b/docs-preview/pr-862/dir_9f228de11f2fc2633236213a3ef5c992.html
similarity index 80%
rename from docs-preview/pr-862/group__core-ecs-relation.html
rename to docs-preview/pr-862/dir_9f228de11f2fc2633236213a3ef5c992.html
index a882f1e4e..9715743ea 100644
--- a/docs-preview/pr-862/group__core-ecs-relation.html
+++ b/docs-preview/pr-862/dir_9f228de11f2fc2633236213a3ef5c992.html
@@ -2,7 +2,7 @@
-
Core » ECS » Relation module | CUBOS. Docs
+
core/ecs/table/sparse_relation/ directory | CUBOS. Docs
@@ -46,10 +46,9 @@
- Core »
- ECS »
- Relation module
-
Relation part of the ECS.
+
core /ecs /table /sparse_relation
/ directory
+
+
Sparse relation storage types.
Contents
@@ -64,10 +63,12 @@ Contents
diff --git a/docs-preview/pr-862/dir_b6daa990b896c2c0c53126427e4d978d.html b/docs-preview/pr-862/dir_b6daa990b896c2c0c53126427e4d978d.html
index c0847b602..038d1a19e 100644
--- a/docs-preview/pr-862/dir_b6daa990b896c2c0c53126427e4d978d.html
+++ b/docs-preview/pr-862/dir_b6daa990b896c2c0c53126427e4d978d.html
@@ -68,12 +68,14 @@
Component directory.
directory entity /
Entity directory.
-
directory relation /
-
Relation directory.
+
directory query /
+
Query directory.
directory resource /
Resource directory.
directory system /
System directory.
+
directory table /
+
Table directory.
-
diff --git a/docs-preview/pr-862/dir_23da5564a3f2709d1d4bc8981f00e961.html b/docs-preview/pr-862/dir_c1b5957eb0512b9978230dfb34d9655b.html
similarity index 87%
rename from docs-preview/pr-862/dir_23da5564a3f2709d1d4bc8981f00e961.html
rename to docs-preview/pr-862/dir_c1b5957eb0512b9978230dfb34d9655b.html
index 5453e893c..ee0c5c34c 100644
--- a/docs-preview/pr-862/dir_23da5564a3f2709d1d4bc8981f00e961.html
+++ b/docs-preview/pr-862/dir_c1b5957eb0512b9978230dfb34d9655b.html
@@ -2,7 +2,7 @@
-
core/ecs/relation/ directory | CUBOS. Docs
+
core/ecs/table/dense/ directory | CUBOS. Docs
@@ -46,9 +46,9 @@
- core /ecs / relation/ directory
+ core /ecs /table / dense/ directory
-
Relation directory.
+
Dense storage types.
Contents
@@ -63,10 +63,10 @@ Contents
diff --git a/docs-preview/pr-862/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html b/docs-preview/pr-862/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html
similarity index 94%
rename from docs-preview/pr-862/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html
rename to docs-preview/pr-862/engine_2include_2cubos_2engine_2screen__picker_2plugin_8hpp.html
index a332a7917..2cad6b62c 100644
--- a/docs-preview/pr-862/engine_2include_2cubos_2engine_2screenpicker_2plugin_8hpp.html
+++ b/docs-preview/pr-862/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-862/examples-engine-assets-bridge.html b/docs-preview/pr-862/examples-engine-assets-bridge.html
index f79db8dd5..fdf83afea 100644
--- a/docs-preview/pr-862/examples-engine-assets-bridge.html
+++ b/docs-preview/pr-862/examples-engine-assets-bridge.html
@@ -76,10 +76,10 @@
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 ( Write < Assets > assets )
+}; 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 > ());
+ 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 :
{
@@ -87,10 +87,10 @@
} 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 ( Read < Assets > assets )
+static void loadSystem ( const Assets & assets )
{
// Access the text asset - will be loaded automatically.
- auto text = assets -> read ( SampleAsset );
+ 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" );
diff --git a/docs-preview/pr-862/examples-engine-assets-json.html b/docs-preview/pr-862/examples-engine-assets-json.html
index 4c3a0074a..13b4ff1f8 100644
--- a/docs-preview/pr-862/examples-engine-assets-json.html
+++ b/docs-preview/pr-862/examples-engine-assets-json.html
@@ -75,14 +75,14 @@
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 ( Write < Assets > assets )
+} 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 < old :: JSONBridge < Strings >> ());
+ assets . registerBridge ( ".strings" , std :: make_unique < old :: 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 ( Write < Assets > assets )
+static void loadSystem ( Assets & assets )
{
- auto read = assets -> read ( SampleAsset );
+ auto read = assets . read ( SampleAsset );
for ( const auto & str : read -> strings )
{
Stream :: stdOut . printf ( "String: {} \n " , str );
diff --git a/docs-preview/pr-862/examples-engine-assets-saving.html b/docs-preview/pr-862/examples-engine-assets-saving.html
index a2470ff60..7c45a44df 100644
--- a/docs-preview/pr-862/examples-engine-assets-saving.html
+++ b/docs-preview/pr-862/examples-engine-assets-saving.html
@@ -52,10 +52,10 @@
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 ( Write < Settings > settings )
+
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
+ 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,11 +64,11 @@
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 ( Write < Assets > assets )
+} 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 );
+ 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!
diff --git a/docs-preview/pr-862/examples-engine-events.html b/docs-preview/pr-862/examples-engine-events.html
index 2e71f22bc..0b198e717 100644
--- a/docs-preview/pr-862/examples-engine-events.html
+++ b/docs-preview/pr-862/examples-engine-events.html
@@ -60,19 +60,19 @@
{
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 , Write < State > state , Write < ShouldQuit > quit )
+} 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.
+ 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 )
+ else if ( state . step == 2 )
{
- quit -> value = true ; // Stop the loop.
+ quit . value = true ; // Stop the loop.
writer . push ({ 4 });
writer . push ({ 5 });
writer . push ({ 6 });
diff --git a/docs-preview/pr-862/examples-engine-gizmos.html b/docs-preview/pr-862/examples-engine-gizmos.html
index 52e4f9ee9..1db9fe91d 100644
--- a/docs-preview/pr-862/examples-engine-gizmos.html
+++ b/docs-preview/pr-862/examples-engine-gizmos.html
@@ -52,54 +52,54 @@
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 ( Write < Gizmos > gizmos )
+ 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 ({ 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 });
+ gizmos . color ({ 0.25F , 0.15F , 0.5F });
}
- else if ( gizmos -> pressed ( "cut cone" ))
+ else if ( gizmos . pressed ( "cut cone" ))
{
- gizmos -> color ({ 0.5F , 0.3F , 1 });
+ gizmos . color ({ 0.5F , 0.3F , 1 });
}
else
{
- gizmos -> color ({ 0.1F , 0.05F , 0.25F });
+ 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 ( Write < Gizmos > gizmos )
+ 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 . 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" ))
+ if ( gizmos . hovered ( "cut cone" ))
{
- gizmos -> color ({ 0.25F , 0.15F , 0.5F });
+ gizmos . color ({ 0.25F , 0.15F , 0.5F });
}
- else if ( gizmos -> pressed ( "cut cone" ))
+ else if ( gizmos . pressed ( "cut cone" ))
{
- gizmos -> color ({ 0.5F , 0.3F , 1 });
+ gizmos . color ({ 0.5F , 0.3F , 1 });
}
else
{
- gizmos -> color ({ 0.1F , 0.05F , 0.25F });
+ 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 );
}
diff --git a/docs-preview/pr-862/examples-engine-hello-cubos.html b/docs-preview/pr-862/examples-engine-hello-cubos.html
index 1ba631e15..9afa307a6 100644
--- a/docs-preview/pr-862/examples-engine-hello-cubos.html
+++ b/docs-preview/pr-862/examples-engine-hello-cubos.html
@@ -50,12 +50,12 @@
Engine »
Hello CUBOS.
- Using Cubos to create a simple program.
-
See also Full source code here .
This example shows the basics of how cubos:: engine:: Cubos is used, by making a simple "Hello World" program.
#include <cubos/engine/cubos.hpp>
+ Using Cubos to create a simple program.
+
See also Full source code here .
This example shows the basics of how cubos:: engine:: Cubos is used, by making a simple "Hello World" program.
#include <cubos/engine/prelude.hpp>
using cubos :: engine :: Cubos ; First we'll need to get a Cubos
object.
int main ()
{
- Cubos cubos {}; The Cubos class represents the engine. We'll need it to add functionality to our program.
Let's start by defining what functionality we want to add.
static void sayHelloCubosSystem ()
+ Cubos cubos {}; The Cubos class represents the engine. We'll need it to add functionality to our program.
Let's start by defining what functionality we want to add.
static void sayHelloCubosSystem ()
{
CUBOS_INFO ( "Hello CUBOS" );
} This function simply prints Hello CUBOS
to the console. It uses one of CUBOS.'s logging macros. You can find more about them here . However, this function is not currently called, so we'll need to tell CUBOS. that we want it to run.
cubos . startupSystem ( sayHelloCubosSystem ); Startup systems run only once when the engine is loaded. Now let's make things more interesting. Let's print Hello World
, but split it over two different systems.
static void sayHelloSystem ()
@@ -66,7 +66,7 @@
static void sayWorldSystem ()
{
CUBOS_INFO ( "World" );
-} Instead of using startupSystem
, we'll use Cubos:: system . This means the systems will be called after the startup systems and repeat every cycle, instead of just once at startup.
Note As we don't have anything that would require multiple cycles (such as a window to draw to), the CUBOS. main cycle will run only once.
However, we can't just do as we did for sayHelloCubos
and call it a day. We want sayHello
to come before sayWorld
, so we'll have to explicitly tell that to the engine, or else we risk having them in the wrong order. To do that we use tags. Let's create two tags, one for each system.
cubos . tag ( "helloTag" ). before ( "worldTag" ); Cubos:: tag creates a new tag, and before makes any systems tagged with it come before systems tagged with the one given as parameter. There's also an after that has the inverse effect. Now all we have to do is to assign these tags to our systems.
Note If we wanted to give these tags to a system running on startup, we'd have to use Cubos:: startupTag instead.
cubos . system ( sayHelloSystem ). tagged ( "helloTag" );
+} Instead of using startupSystem
, we'll use Cubos:: system . This means the systems will be called after the startup systems and repeat every cycle, instead of just once at startup.
Note As we don't have anything that would require multiple cycles (such as a window to draw to), the CUBOS. main cycle will run only once.
However, we can't just do as we did for sayHelloCubos
and call it a day. We want sayHello
to come before sayWorld
, so we'll have to explicitly tell that to the engine, or else we risk having them in the wrong order. To do that we use tags. Let's create two tags, one for each system.
cubos . tag ( "helloTag" ). before ( "worldTag" ); Cubos:: tag creates a new tag, and before makes any systems tagged with it come before systems tagged with the one given as parameter. There's also an after that has the inverse effect. Now all we have to do is to assign these tags to our systems.
Note If we wanted to give these tags to a system running on startup, we'd have to use Cubos:: startupTag instead.
cubos . system ( sayHelloSystem ). tagged ( "helloTag" );
cubos . system ( sayWorldSystem ). tagged ( "worldTag" ); Now let's see a bit about entities, components and resources. First we are going to need to use a few more things. We'll go over what each does as it comes up.
Entities have components, so let's create one to give our entities. Because of how the engine works, we cannot declare a component on our main.cpp
file. We'll need to create a components.hpp
for that.
#pragma once
#include <cubos/core/ecs/world.hpp>
@@ -80,20 +80,20 @@
}; Here we create a component called "num" that stores a single integer. We'll use it as the id of the entity it is attached to. Back on our main.cpp
file we'll need to include our new file.
#include "components.hpp" And the component needs to be registered.
cubos . addComponent < Num > (); Let's create a resource now. Unlike components, resources can be declared on the main.cpp
file, so let's do that.
struct Pop
{
int count ;
-}; This resource will store the total number of spawned entities, a population counter of sorts. It too needs to be registered.
cubos . addResource < Pop > (); Now let's create a startup system that spawns some entities.
static void spawnEntitiesSystem ( Commands cmds , Write < Pop > pop )
+}; This resource will store the total number of spawned entities, a population counter of sorts. It too needs to be registered.
cubos . addResource < Pop > (); Now let's create a startup system that spawns some entities.
static void spawnEntitiesSystem ( Commands cmds , Pop & pop )
{
for ( int i = 0 ; i < 10 ; i ++ )
{
- cmds . create ( Num { i });
- pop -> count += 1 ;
+ cmds . create (). add ( Num { i });
+ pop . count += 1 ;
}
-} Commands is a system argument that allows us to interact with the world, in this case, by creating entities that have a Num
component.
Write is a system argument that allows us to modify a resource, in this case Pop
.
Finally, we'll want a system that prints our entities.
static void checkEntitiesSystem ( Query < Read < Num >> query , Read < Pop > pop )
+} Commands is a system argument that allows us to interact with the world, in this case, by creating entities that have a Num
component.
Write is a system argument that allows us to modify a resource, in this case Pop
.
Finally, we'll want a system that prints our entities.
static void checkEntitiesSystem ( Query < const Num &> query , const Pop & pop )
{
- for ( auto [ entity , num ] : query )
+ for ( auto [ num ] : query )
{
- CUBOS_INFO ( "Entity '{}' of '{}'" , num -> value , pop -> count );
+ CUBOS_INFO ( "Entity '{}' of '{}'" , num . value , pop . count );
}
-} Read is similar to Write
, only it just gives us permission to read data from resources and components, we cannot alter them.
Query allows us to access all entities with a given configuration of components. In this case, it will give us all entities with the Num
component.
To finish configuring our program, we just need to register these two new systems. We'll also have the entities be printed after our Hello World
message.
cubos . startupSystem ( spawnEntitiesSystem );
+} Read is similar to Write
, only it just gives us permission to read data from resources and components, we cannot alter them.
Query allows us to access all entities with a given configuration of components. In this case, it will give us all entities with the Num
component.
To finish configuring our program, we just need to register these two new systems. We'll also have the entities be printed after our Hello World
message.
cubos . startupSystem ( spawnEntitiesSystem );
cubos . system ( checkEntitiesSystem ); With everything properly set up, all that remains is to run the engine.
cubos . run ();
}
diff --git a/docs-preview/pr-862/examples-engine-imgui.html b/docs-preview/pr-862/examples-engine-imgui.html
index 8efe9be71..a920183ee 100644
--- a/docs-preview/pr-862/examples-engine-imgui.html
+++ b/docs-preview/pr-862/examples-engine-imgui.html
@@ -119,16 +119,16 @@
{ 2 , 4 },
{ 3 , 6 },
{ 4 , 8 },
- }}); Well now, using the cubos:: engine:: DataInspector is pretty easy, all you have to do is, obviously, access the resource on your system, and use the functions DataInspector::edit
and DataInspector::edit
.
static void exampleDataInspectorSystem ( Write < DataInspector > inspector , Write < DummyResource > data )
+ }}); Well now, using the cubos:: engine:: DataInspector is pretty easy, all you have to do is, obviously, access the resource on your system, and use the functions DataInspector::edit
and DataInspector::edit
.
static void exampleDataInspectorSystem ( DataInspector & inspector , DummyResource & data )
{
ImGui :: Begin ( "Data Inspector" );
ImGui :: BeginTable ( "id1" , 2 );
- inspector -> show ( "data->integer" , data -> integer );
- inspector -> edit ( "data->person" , data -> person );
- inspector -> edit ( "data->persons" , data -> persons );
- inspector -> edit ( "data->vec" , data -> vec );
- inspector -> edit ( "data->map" , data -> map );
+ inspector . show ( "data.integer" , data . integer );
+ inspector . edit ( "data.person" , data . person );
+ inspector . edit ( "data.persons" , data . persons );
+ inspector . edit ( "data.vec" , data . vec );
+ inspector . edit ( "data.map" , data . map );
ImGui :: EndTable ();
ImGui :: End ();
diff --git a/docs-preview/pr-862/examples-engine-input.html b/docs-preview/pr-862/examples-engine-input.html
index 2a2b20a66..0d794de5e 100644
--- a/docs-preview/pr-862/examples-engine-input.html
+++ b/docs-preview/pr-862/examples-engine-input.html
@@ -154,28 +154,28 @@
}
}
} There are two types of bindings: actions
and axes
. An action
is an input that only has two states: pressed or not pressed. This would be most keys on a keyboard. An axe
is an input that has a numeric value. For example, the joysticks on a controller can go from -1 to 1, depending on how much they are tilt in which direction. Using axes
can also be useful for keys with symetric behaviour. For example, in this sample, w
sets the vertical
axe to 1, while s
sets it to -1.
To define an action or an axe, you simply have to add it to the respective list, giving it a name. The very first action in the file is called next-showcase
. Then, if it's an action, you simply have to define which keys trigger it. You can also define key combinations by using a -
. To check which strings map to which keys, you check the keyToString
function implementation on this file .
Now that we have our bindings file, let's get our application to do something with it. The first thing we're going to need is a reference to the bindings asset. For the purposes of this sample we can simply use an hardcoded reference to the asset.
static const Asset < InputBindings > BindingsAsset = AnyAsset ( "bf49ba61-5103-41bc-92e0-8a442d7842c3" ); To utilize the bindings, loading them is essential. This can be accomplished by establishing two startup systems: one to configure the assets.io.path
path and the other to read from the asset and establish the required bindings.
cubos . startupSystem ( config ). tagged ( "cubos.settings" );
- cubos . startupSystem ( init ). tagged ( "cubos.assets" ); static void config ( Write < Settings > settings )
+ cubos . startupSystem ( init ). tagged ( "cubos.assets" ); static void config ( Settings & settings )
{
- settings -> setString ( "assets.io.path" , SAMPLE_ASSETS_FOLDER );
+ settings . setString ( "assets.io.path" , SAMPLE_ASSETS_FOLDER );
}
-static void init ( Read < Assets > assets , Write < Input > input )
+static void init ( const Assets & assets , Input & input )
{
- auto bindings = assets -> read < InputBindings > ( BindingsAsset );
- input -> bind ( * bindings );
- CUBOS_INFO ( "Loaded bindings: {}" , input -> bindings (). at ( 0 ));
-} Getting the input is done through the cubos:: engine:: Input resource. What this sample does is show in order, a series of prompt to showcase the different functionalities of the Input plugin. For this, it keeps a state
integer that indicates the current prompt. Whenever the action next-showcase
is triggered, it advances to the next prompt. However, as the plugin currently does not have events, we have to manually check whether the key has just been pressed, is being pressed continuously, or was just released.
static void update ( Read < Input > input , Read < Window > window , Write < State > state , Write < ShouldQuit > shouldQuit )
+ auto bindings = assets . read < InputBindings > ( BindingsAsset );
+ input . bind ( * bindings );
+ CUBOS_INFO ( "Loaded bindings: {}" , input . bindings (). at ( 0 ));
+} Getting the input is done through the cubos:: engine:: Input resource. What this sample does is show in order, a series of prompt to showcase the different functionalities of the Input plugin. For this, it keeps a state
integer that indicates the current prompt. Whenever the action next-showcase
is triggered, it advances to the next prompt. However, as the plugin currently does not have events, we have to manually check whether the key has just been pressed, is being pressed continuously, or was just released.
static void update ( const Input & input , const Window & window , State & state , ShouldQuit & shouldQuit )
{
// FIXME: This is an hack to have one-shot actions while we don't have input events.
- if ( input -> pressed ( "next-showcase" ))
+ if ( input . pressed ( "next-showcase" ))
{
- state -> nextPressed = true ;
+ state . nextPressed = true ;
}
- else if ( state -> nextPressed )
+ else if ( state . nextPressed )
{
- state -> nextPressed = false ;
- state -> explained = false ;
- state -> showcase ++ ;
+ state . nextPressed = false ;
+ state . explained = false ;
+ state . showcase ++ ;
} What this does is only advance the state when the return key is released. This avoids the state advancing more than once if the user presses it for more than one frame.
Now let's see each of the prompt, to understand the full breadth of the plugin's functionalities.
Note All the functions henceforth are not systems, they are mere functions called by the update
system, which passes the Input
resource to them.
static void showcaseXZ ( const Input & input , bool & explained )
{
if ( ! explained )
diff --git a/docs-preview/pr-862/examples-engine-renderer.html b/docs-preview/pr-862/examples-engine-renderer.html
index 3dbebee8e..108aa49af 100644
--- a/docs-preview/pr-862/examples-engine-renderer.html
+++ b/docs-preview/pr-862/examples-engine-renderer.html
@@ -52,50 +52,50 @@
Using the Renderer plugin.
See also Full source code here .
This example shows how the Renderer plugin can be used and configured with a simple scene, lighting and split-screen rendering.
The plugin function is included from the engine/ renderer/ plugin.hpp header. You may need to include other headers, depending on what you want to access.
cubos . addPlugin ( splitscreenPlugin );
- cubos . addPlugin ( rendererPlugin ); The first thing we're going to worry about is setting the VoxelPalette the renderer will use. This palette would usually be loaded from a file, but for this example we'll just create it manually.
static void setPaletteSystem ( Write < Renderer > renderer )
+ cubos . addPlugin ( rendererPlugin ); The first thing we're going to worry about is setting the VoxelPalette the renderer will use. This palette would usually be loaded from a file, but for this example we'll just create it manually.
static void setPaletteSystem ( Renderer & renderer )
{
// Create a simple palette with 3 materials (red, green and blue).
- ( * renderer ) -> setPalette ( VoxelPalette {{
+ renderer -> setPalette ( VoxelPalette {{
{{ 1 , 0 , 0 , 1 }},
{{ 0 , 1 , 0 , 1 }},
{{ 0 , 0 , 1 , 1 }},
}});
-} We should also spawn a voxel grid , so we have something to render.
static void spawnVoxelGridSystem ( Commands commands , Write < Assets > assets )
+} We should also spawn a voxel grid , so we have something to render.
static void spawnVoxelGridSystem ( Commands commands , Assets & assets )
{
// Create a 2x2x2 grid whose voxels alternate between the materials defined in the palette.
- auto gridAsset = assets -> create ( VoxelGrid {{ 2 , 2 , 2 }, { 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 }});
+ auto gridAsset = assets . create ( VoxelGrid {{ 2 , 2 , 2 }, { 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 }});
// Spawn an entity with a renderable grid component and a identity transform.
- commands . create ( RenderableGrid { gridAsset , { -1.0F , 0.0F , -1.0F }}, LocalToWorld {});
+ commands . create (). add ( RenderableGrid { gridAsset , { -1.0F , 0.0F , -1.0F }}). add ( LocalToWorld {});
} If we don't add any lights, the scene will be completely dark. Lets add a simple PointLight .
static void spawnLightSystem ( Commands commands )
{
// Spawn a point light.
commands . create ()
. add ( PointLight {. color = { 1.0F , 1.0F , 1.0F }, . intensity = 1.0F , . range = 10.0F })
. add ( Position {{ 1.0F , 3.0F , -2.0F }});
-} We can also add some ambient lighting, and even add a sky gradient, through the RendererEnvironment resource.
static void setEnvironmentSystem ( Write < RendererEnvironment > env )
+} We can also add some ambient lighting, and even add a sky gradient, through the RendererEnvironment resource.
static void setEnvironmentSystem ( RendererEnvironment & env )
{
- env -> ambient = { 0.2F , 0.2F , 0.2F };
- env -> skyGradient [ 0 ] = { 0.1F , 0.2F , 0.4F };
- env -> skyGradient [ 1 ] = { 0.6F , 0.6F , 0.8F };
-} Lastly, without a camera, we won't be able to see anything. Cameras can be set using the ActiveCameras resource.
static void spawnCamerasSystem ( Commands commands , Write < ActiveCameras > camera )
+ env . ambient = { 0.2F , 0.2F , 0.2F };
+ env . skyGradient [ 0 ] = { 0.1F , 0.2F , 0.4F };
+ env . skyGradient [ 1 ] = { 0.6F , 0.6F , 0.8F };
+} Lastly, without a camera, we won't be able to see anything. Cameras can be set using the ActiveCameras resource.
static void spawnCamerasSystem ( Commands commands , ActiveCameras & camera )
{
// Spawn the a camera entity for the first viewport.
- camera -> entities [ 0 ] =
+ camera . entities [ 0 ] =
commands . create ()
. add ( Camera {. fovY = 60.0F , . zNear = 0.1F , . zFar = 100.0F })
. add ( Position {{ -3.0 , 1.0F , -3.0F }})
. add ( Rotation { glm :: quatLookAt ( glm :: normalize ( glm :: vec3 { 1.0F , 0.0F , 1.0F }), glm :: vec3 { 0.0F , 1.0F , 0.0F })})
. entity ();
- camera -> entities [ 1 ] =
+ camera . entities [ 1 ] =
commands . create ()
. add ( Camera {. fovY = 60.0F , . zNear = 0.1F , . zFar = 100.0F })
. add ( Position {{ -3.0 , 1.0F , -3.0F }})
. add ( Rotation { glm :: quatLookAt ( glm :: normalize ( glm :: vec3 { 1.0F , 0.0F , 1.0F }), glm :: vec3 { 0.0F , 1.0F , 0.0F })})
. entity ();
- camera -> entities [ 2 ] =
+ camera . entities [ 2 ] =
commands . create ()
. add ( Camera {. fovY = 60.0F , . zNear = 0.1F , . zFar = 100.0F })
. add ( Position {{ -3.0 , 1.0F , -3.0F }})
diff --git a/docs-preview/pr-862/examples-engine-scene.html b/docs-preview/pr-862/examples-engine-scene.html
index d066811c8..3fe8783fb 100644
--- a/docs-preview/pr-862/examples-engine-scene.html
+++ b/docs-preview/pr-862/examples-engine-scene.html
@@ -62,7 +62,7 @@
}
}
}
-} Scene files are JSON files with the extension .cubos
. They must have two fields: imports
and entities
. The entities
field is an object where each field identifies and describes the components of an entity. In this scene we have two entities, root
and child
. root
has a single component, num
, with a value of 1. child
has two components, a parent
and a num
. In this sample, num
is used so we can later identify the entities.
Note Make sure these component names match the ones in your application and that they have been registered with Cubos .
Let's look at a different scene file now, this time with imports
. Imports allows us to instantiate scenes within other scenes.
{
+} Scene files are JSON files with the extension .cubos
. They must have two fields: imports
and entities
. The entities
field is an object where each field identifies and describes the components of an entity. In this scene we have two entities, root
and child
. root
has a single component, num
, with a value of 1. child
has two components, a parent
and a num
. In this sample, num
is used so we can later identify the entities.
Note Make sure these component names match the ones in your application and that they have been registered with Cubos .
Let's look at a different scene file now, this time with imports
. Imports allows us to instantiate scenes within other scenes.
{
"imports": {
"sub1": "00d86ba8-5f34-440f-a180-d9d12c8e8b91"
},
@@ -75,9 +75,9 @@
}
}
}
-} This file imports the asset with id cd007ba2-ee0d-44fd-bf36-85c829dbe66f
, which is the scene we looked at in the previous file, under the name sub1
. It then imports the very same scene again, but this time with the name sub2
instead. This effectively instantiates the entities of the previous scene twice in this new scene, each with their names prefixed with either sub1.
or sub2.
Under entities
, we can override the entities in the sub-scenes to edit components or add new ones. For example, by referencing sub1.root
we are making local changes to the root
entity of that instance of the subscene. The result of the changes we make to both sub1.root
and sub2.root
is that the parent of these entities will be set to be the main
entity.
Now that we have our scene file, let's get our application to load it. The first thing we're going to need is a reference to the scene asset. For the purposes of this sample we can simply use an hardcoded reference to the asset.
static const Asset < Scene > SceneAsset = AnyAsset ( "f0d86ba8-5f34-440f-a180-d9d12c8e8b91" ); Then we'll need a system that spawns that scene. To do this we simply get the Scene object from the asset, and then spawn its entities. Commands:: spawn will create in the world a copy of every entity defined in the scene's blueprint. It won't remove the entities already there, so if you want to close a scene, you'll have to do it yourself.
static void spawnScene ( Commands commands , Read < Assets > assets )
+}This file imports the asset with id cd007ba2-ee0d-44fd-bf36-85c829dbe66f
, which is the scene we looked at in the previous file, under the name sub1
. It then imports the very same scene again, but this time with the name sub2
instead. This effectively instantiates the entities of the previous scene twice in this new scene, each with their names prefixed with either sub1.
or sub2.
Under entities
, we can override the entities in the sub-scenes to edit components or add new ones. For example, by referencing sub1.root
we are making local changes to the root
entity of that instance of the subscene. The result of the changes we make to both sub1.root
and sub2.root
is that the parent of these entities will be set to be the main
entity.
Now that we have our scene file, let's get our application to load it. The first thing we're going to need is a reference to the scene asset. For the purposes of this sample we can simply use an hardcoded reference to the asset.
static const Asset < Scene > SceneAsset = AnyAsset ( "f0d86ba8-5f34-440f-a180-d9d12c8e8b91" ); Then we'll need a system that spawns that scene. To do this we simply get the Scene object from the asset, and then spawn its entities. Commands:: spawn will create in the world a copy of every entity defined in the scene's blueprint. It won't remove the entities already there, so if you want to close a scene, you'll have to do it yourself.
static void spawnScene ( Commands commands , const Assets & assets )
{
- auto sceneRead = assets -> read ( SceneAsset );
+ auto sceneRead = assets . read ( SceneAsset );
commands . spawn ( sceneRead -> blueprint );
} In this case, we'll run this system at startup, since we want to spawn it a single time. Since it's a startup system, we'll have to tag it with cubos.assets
to make sure it runs only after the scene bridge has been registered. On a real game, you could have, for example, a scene for an enemy which you spawn multiple times, instead of just once at startup.
cubos . startupSystem ( spawnScene ). tagged ( "spawn" ). tagged ( "cubos.assets" ); This sample will output the list of every entity in the scene, so you can check that everything is working as expected. If you run it, it should give you a list that has:
an entity with num
set to 0, with no parent. This is the main
entity. two entities with num
set to 1, with same parent, who has num
set to 0. These are the root
entities of each instance of the subscene. two entities with num
set to 2, with different parents, but both of them having num
set to 1. These are the child
entities of each instance of the subscene.