-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"entities": { | ||
"render-target": { | ||
"cubos::engine::RenderTargetDefaults": {} | ||
}, | ||
"camera": { | ||
"cubos::engine::PerspectiveCamera": {}, | ||
"cubos::engine::DrawsTo@render-target": {}, | ||
"cubos::engine::Position": { | ||
"x": 0, | ||
"y": 0, | ||
"z": 0 | ||
} | ||
}, | ||
"car": { | ||
"cubos::engine::RenderVoxelGrid": { | ||
"asset": "059c16e7-a439-44c7-9bdc-6e069dba0c75", | ||
"offset": { | ||
"x": -7.5, | ||
"y": 0.0, | ||
"z": -16.0 | ||
} | ||
}, | ||
"cubos::engine::Position": { | ||
"x": -3, | ||
"y": -2.5, | ||
"z": -14 | ||
}, | ||
"cubos::engine::Scale": 0.2, | ||
"Spin": {} | ||
}, | ||
"spot1": { | ||
"cubos::engine::SpotLight": { | ||
"color": { | ||
"x": 1.0, | ||
"y": 1.0, | ||
"z": 1.0 | ||
}, | ||
"intensity": 10.0, | ||
"range": 20.0, | ||
"spotAngle": 90.0, | ||
"innerSpotAngle": 45.0 | ||
}, | ||
"cubos::engine::Position": { | ||
"x": -13.0, | ||
"y": -2.0, | ||
"z": -18.0 | ||
}, | ||
"cubos::engine::Rotation": { | ||
"w": 0.7071068, | ||
"x": 0.0, | ||
"y": 0.7071068, | ||
"z": 0.0 | ||
}, | ||
"cubos::engine::SpotShadowCaster": {} | ||
}, | ||
"spot2": { | ||
"cubos::engine::SpotLight": { | ||
"color": { | ||
"x": 1.0, | ||
"y": 1.0, | ||
"z": 1.0 | ||
}, | ||
"intensity": 20.0, | ||
"range": 20.0, | ||
"spotAngle": 90.0, | ||
"innerSpotAngle": 45.0 | ||
}, | ||
"cubos::engine::Position": { | ||
"x": 10.0, | ||
"y": -2.0, | ||
"z": -20.0 | ||
}, | ||
"cubos::engine::Rotation": { | ||
"w": 0.8660254, | ||
"x": 0.0, | ||
"y": -0.5, | ||
"z": 0.0 | ||
}, | ||
"cubos::engine::SpotShadowCaster": {} | ||
}, | ||
"spot3": { | ||
"cubos::engine::SpotLight": { | ||
"color": { | ||
"x": 1.0, | ||
"y": 1.0, | ||
"z": 1.0 | ||
}, | ||
"intensity": 10.0, | ||
"range": 20.0, | ||
"spotAngle": 90.0, | ||
"innerSpotAngle": 45.0 | ||
}, | ||
"cubos::engine::Position": { | ||
"x": 6.0, | ||
"y": -2.0, | ||
"z": -10.0 | ||
}, | ||
"cubos::engine::Rotation": { | ||
"w": 0.258819, | ||
"x": 0.0, | ||
"y": -0.9659258, | ||
"z": 0.0 | ||
}, | ||
"cubos::engine::SpotShadowCaster": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "950f0d55-2fdf-4e70-a283-79a2bda10f99" | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "059c16e7-a439-44c7-9bdc-6e069dba0c75" | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "1aa5e234-28cb-4386-99b4-39386b0fc215" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include <cubos/core/ecs/reflection.hpp> | ||
#include <cubos/core/reflection/external/primitives.hpp> | ||
|
||
#include <cubos/engine/assets/plugin.hpp> | ||
#include <cubos/engine/render/defaults/plugin.hpp> | ||
#include <cubos/engine/render/lights/environment.hpp> | ||
#include <cubos/engine/render/voxels/grid.hpp> | ||
#include <cubos/engine/render/voxels/palette.hpp> | ||
#include <cubos/engine/scene/plugin.hpp> | ||
#include <cubos/engine/settings/plugin.hpp> | ||
#include <cubos/engine/transform/plugin.hpp> | ||
#include <cubos/engine/voxels/grid.hpp> | ||
#include <cubos/engine/voxels/plugin.hpp> | ||
#include <cubos/engine/window/plugin.hpp> | ||
|
||
using namespace cubos::engine; | ||
|
||
static const Asset<Scene> SceneAsset = AnyAsset("950f0d55-2fdf-4e70-a283-79a2bda10f99"); | ||
static const Asset<VoxelPalette> PaletteAsset = AnyAsset("1aa5e234-28cb-4386-99b4-39386b0fc215"); | ||
|
||
struct Spin | ||
{ | ||
CUBOS_REFLECT; | ||
}; | ||
|
||
CUBOS_REFLECT_IMPL(Spin) | ||
{ | ||
return cubos::core::ecs::TypeBuilder<Spin>("Spin").build(); | ||
} | ||
|
||
int main() | ||
{ | ||
Cubos cubos{}; | ||
|
||
cubos.component<Spin>(); | ||
|
||
/// [Adding the plugins] | ||
cubos.plugin(settingsPlugin); | ||
cubos.plugin(windowPlugin); | ||
cubos.plugin(transformPlugin); | ||
cubos.plugin(assetsPlugin); | ||
cubos.plugin(voxelsPlugin); | ||
cubos.plugin(renderDefaultsPlugin); | ||
/// [Adding the plugins] | ||
|
||
cubos.plugin(scenePlugin); | ||
|
||
cubos.startupSystem("configure settings").tagged(settingsTag).call([](Settings& settings) { | ||
settings.setString("assets.io.path", SAMPLE_ASSETS_FOLDER); | ||
settings.setBool("window.vSync", false); | ||
}); | ||
|
||
cubos.startupSystem("set the palette and environment and spawn the scene") | ||
.tagged(assetsTag) | ||
.call([](Commands commands, const Assets& assets, RenderPalette& palette, RenderEnvironment& environment) { | ||
palette.asset = PaletteAsset; | ||
environment.ambient = {0.01F, 0.01F, 0.01F}; | ||
environment.skyGradient[0] = {0.1F, 0.2F, 0.4F}; | ||
environment.skyGradient[1] = {0.6F, 0.6F, 0.8F}; | ||
commands.spawn(assets.read(SceneAsset)->blueprint); | ||
}); | ||
|
||
cubos.startupSystem("create a voxel grid").tagged(assetsTag).call([](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}}); | ||
|
||
// Spawn entities with the grid. | ||
// Cube | ||
commands.create() | ||
.add(RenderVoxelGrid{gridAsset, {0.0F, 0.0F, 0.0F}}) | ||
.add(LocalToWorld{}) | ||
.add(Position{{3.0F, -3.0F, -17.0F}}) | ||
.add(Scale{1.5F}); | ||
// Floor | ||
commands.create() | ||
.add(RenderVoxelGrid{gridAsset, {0.0F, 0.0F, 0.0F}}) | ||
.add(LocalToWorld{}) | ||
.add(Position{{-20.0F, -43.0F, -50.0F}}) | ||
.add(Scale{20.0F}); | ||
}); | ||
|
||
cubos.system("spin car").call([](Query<const Spin&, Rotation&> query, DeltaTime& dt) { | ||
for (auto [spin, rotation] : query) | ||
{ | ||
rotation.quat = glm::cross(rotation.quat, glm::quat(glm::vec3{0.0F, dt.value(), 0.0F})); | ||
} | ||
}); | ||
|
||
cubos.run(); | ||
} |