summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-27 22:38:25 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-27 22:38:25 +1000
commitca4c92f7b74ebbfc80bd24630cd0ad3def6c20fc (patch)
tree97add3d530402670068a114fc803658d562993e1
parentf37e974a19fca37d0e7999c7ffc49dcbcd50b081 (diff)
serialize transform
-rw-r--r--README.md2
-rw-r--r--bindgen/rust/celeritas-sys/build.rs1
-rw-r--r--bindgen/rust/src/lib.rs16
-rw-r--r--examples/game_demo/game_demo.c6
-rw-r--r--src/new_render/render.c2
5 files changed, 18 insertions, 9 deletions
diff --git a/README.md b/README.md
index cdcb50e..0260939 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,9 @@ All third-party dependencies are licensed under their own license.
- [ ] SIMD 4x4 multiply
- [ ] Quaternion functions (not fully fleshed out)
- [x] Camera
+ - [x] Fly camera
- [ ] Swap to quaternion for internal orientation
+ - [ ] Arcball / Orbit camera
- [ ] Transform gizmo
- [ ] Mesh generation
- [x] Cube
diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs
index 9eaa44f..e2c240b 100644
--- a/bindgen/rust/celeritas-sys/build.rs
+++ b/bindgen/rust/celeritas-sys/build.rs
@@ -9,6 +9,7 @@ const SERIALIZABLE_TYPES: &[&'static str] = &[
"Vec4",
"Mat4",
"Quat",
+ "Transform",
"DirectionalLight",
"PointLight",
];
diff --git a/bindgen/rust/src/lib.rs b/bindgen/rust/src/lib.rs
index 6f25752..c86e2d6 100644
--- a/bindgen/rust/src/lib.rs
+++ b/bindgen/rust/src/lib.rs
@@ -3,6 +3,9 @@
#![warn(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
+pub use celeritas_sys as ffi;
+
+/// Commonly used types
pub mod prelude;
use std::{
@@ -11,8 +14,7 @@ use std::{
path::Path,
};
-pub use celeritas_sys as ffi;
-use celeritas_sys::{DirectionalLight, PointLight, Vec3};
+use celeritas_sys::{DirectionalLight, PointLight, Transform, Vec3};
use serde::{Deserialize, Serialize};
/// Wrapper around a string that is the path to a gltf model **relative** to the configured
@@ -20,13 +22,21 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct ModelPath(String);
+///
+#[derive(Debug, Serialize, Deserialize)]
+pub struct ModelNode {
+ model_path: ModelPath,
+ transform: Transform
+}
+
/// Scene that can be saved and loaded from disk
#[derive(Debug, Serialize, Deserialize)]
pub struct SerializableScene {
+ /// main light
pub sun: DirectionalLight,
pub point_lights: [Option<PointLight>; 4],
pub camera_orientation: (Vec3, Vec3),
- pub models: Vec<ModelPath>,
+ pub models: Vec<ModelNode>,
}
// Runtime Scene <-> Serialized Scene
diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c
index 1bb2a63..c510ee0 100644
--- a/examples/game_demo/game_demo.c
+++ b/examples/game_demo/game_demo.c
@@ -47,15 +47,11 @@ int main() {
Heightmap hmap = Heightmap_FromImage(str8("assets/test_heightmap.png"));
Terrain_Storage* terrain = Render_GetTerrainStorage();
Terrain_LoadHeightmap(terrain, hmap, 2.0, false);
- // assert(Terrain_IsActive());
// --- Skybox
Skybox skybox = Skybox_Create(faces, 6);
// --- Models
- // ModelHandle player_model = ModelLoad_gltf("Player Model", "assets/demo/player.gltf");
- // ModelHandle sword_model = ModelLoad("Sword Model", "assets/demo/sword.gltf");
-
// create a wooden crate - loads mesh and material directly rather than via loading a model from a
// gltf file
Geometry cube_geo = Geo_CreateCuboid(f32x3(2.0, 2.0, 2.0));
@@ -114,7 +110,7 @@ int main() {
Shadow_DrawDebugQuad();
}
- // Terrain_Draw(terrain);
+ Terrain_Draw(terrain);
// END Draw calls
Frame_Draw();
diff --git a/src/new_render/render.c b/src/new_render/render.c
index 96ab0d1..49b2bf9 100644
--- a/src/new_render/render.c
+++ b/src/new_render/render.c
@@ -137,7 +137,7 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window
PBR_Init(ren->pbr);
ren->terrain = malloc(sizeof(Terrain_Storage));
- // Terrain_Init(ren->terrain);
+ Terrain_Init(ren->terrain);
// load default textures
ren->white_1x1 = TextureLoadFromFile("assets/textures/white1x1.png");