summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-30 16:30:02 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-30 16:30:02 +1000
commit8c74cc9814f241313bf09f60789b3d33c5575d33 (patch)
tree0688af45327c8fb1deb1eba28461ae88549272f7
parent4505fb6585885866ff9a76f76c00ed727d3bb818 (diff)
remove a unused example
-rw-r--r--bindgen/rust/celeritas-sys/examples/scene.rs169
1 files changed, 0 insertions, 169 deletions
diff --git a/bindgen/rust/celeritas-sys/examples/scene.rs b/bindgen/rust/celeritas-sys/examples/scene.rs
deleted file mode 100644
index f3ea135..0000000
--- a/bindgen/rust/celeritas-sys/examples/scene.rs
+++ /dev/null
@@ -1,169 +0,0 @@
-use std::{
- ffi::CString,
- fs::{self, File},
- io::Write,
- path::Path,
- ptr::{self, addr_of_mut},
-};
-
-use serde::{Deserialize, Serialize};
-
-use celeritas_sys::*;
-use egui_backend::egui::{vec2, Pos2, Rect};
-use egui_glfw as egui_backend;
-use egui_glfw::glfw::{fail_on_errors, Context};
-
-use egui_glfw::glfw;
-
-// use celeritas_sys::{ffi::*, SerializableScene};
-use celeritas_sys::*;
-
-/// Wrapper around a string that is the path to a gltf model **relative** to the configured
-/// `ASSETS` folder
-#[derive(Debug, Serialize, Deserialize)]
-pub struct ModelPath(String);
-
-/// Scene that can be saved and loaded from disk
-#[derive(Debug, Serialize, Deserialize)]
-pub struct SerializableScene {
- pub sun: DirectionalLight,
- pub point_lights: [Option<PointLight>; 4],
- pub camera_orientation: (Vec3, Vec3),
- pub models: Vec<ModelPath>,
-}
-
-// Runtime Scene <-> Serialized Scene
-
-impl SerializableScene {
- /// TODO: docs
- pub fn store_to_file(&self, filepath: &Path) {
- let mut file = File::create(filepath).expect("creation failed");
- let json = serde_json::to_string(&self).expect("serialize failed");
- file.write(&json.as_bytes()).expect("writing failed");
- }
- /// TODO: docs
- pub fn load_from_file(filepath: &Path) -> Self {
- let contents = fs::read_to_string(filepath).expect("Filepath should be open and read-able");
-
- serde_json::from_str(&contents).expect("Should be deserializable")
- }
-}
-
-fn main() {
- unsafe {
- let p: *mut GLFWwindow = ptr::null_mut();
- Core_Bringup(p);
-
- // let core = get_global_core();
-
- let camera_pos = Vec3 {
- x: 18.9,
- y: 10.6,
- z: 11.6,
- };
- let camera_front = Vec3 {
- x: -0.6,
- y: -0.2,
- z: -0.7,
- };
- let mut camera = Camera_Create(
- camera_pos,
- camera_front,
- Vec3 {
- x: 0.0,
- y: 1.0,
- z: 0.0,
- },
- 45.0,
- );
- SetCamera(camera);
-
- let mut cube_geo = Geo_CreateCuboid(f32x3 {
- x: 2.0,
- y: 2.0,
- z: 2.0,
- });
-
- let scene = SerializableScene {
- sun: DirectionalLight {
- direction: Vec3 {
- x: 0.0,
- y: 1.0,
- z: 0.0,
- },
- ambient: Vec3 {
- x: 1.0,
- y: 1.0,
- z: 1.0,
- },
- diffuse: Vec3 {
- x: 1.0,
- y: 1.0,
- z: 1.0,
- },
- specular: Vec3 {
- x: 0.0,
- y: 0.0,
- z: 0.0,
- },
- },
- point_lights: [None, None, None, None],
- camera_orientation: (camera_pos, camera_front),
- models: vec![],
- };
-
- let scene_path = Path::new("default_scene.json");
- scene.store_to_file(scene_path);
-
- let rehydrated_scene = SerializableScene::load_from_file(scene_path);
- dbg!(&rehydrated_scene);
-
- // let mut crate_mesh = Mesh_Create(addr_of_mut!(cube_geo), false);
- // let albedo_map = TextureLoadFromFile(
- // CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg")
- // .unwrap()
- // .as_ptr() as *const i8,
- // );
- // let roughness_map = TextureLoadFromFile(
- // CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg")
- // .unwrap()
- // .as_ptr() as *const i8,
- // );
- // let normal_map = TextureLoadFromFile(
- // CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg")
- // .unwrap()
- // .as_ptr() as *const i8,
- // );
- // let ao_map = TextureLoadFromFile(
- // CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg")
- // .unwrap()
- // .as_ptr() as *const i8,
- // );
- // let name: [i8; 64] = [0; 64];
- // let mut crate_mat = Material {
- // name: name,
- // kind: 0,
- // param_albedo: Vec3 {
- // x: 0.0,
- // y: 0.0,
- // z: 0.0,
- // },
- // param_metallic: 0.0,
- // param_roughness: 0.0,
- // param_ao: 0.0,
- // pbr_albedo_map: albedo_map,
- // pbr_normal_map: normal_map,
- // metal_roughness_combined: true,
- // pbr_metallic_map: TextureHandle { raw: 99999 },
- // pbr_roughness_map: roughness_map,
- // pbr_ao_map: ao_map,
- // };
- // let crate_renderent = RenderEnt {
- // mesh: addr_of_mut!(crate_mesh),
- // material: addr_of_mut!(crate_mat),
- // affine: mat4_ident(),
- // casts_shadows: true,
- // };
- // let mut render_ents: [RenderEnt; 1] = [crate_renderent];
- }
-}