Added Assembly and Scene types.
This is in preparation for real scene data, as parsed from real psy files. Exciting!
This commit is contained in:
parent
147b22b861
commit
25f8e0782a
45
src/assembly.rs
Normal file
45
src/assembly.rs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use math::Matrix4x4;
|
||||||
|
use bvh::BVH;
|
||||||
|
use surface::Surface;
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Assembly {
|
||||||
|
// Instance list
|
||||||
|
instances: Vec<Instance>,
|
||||||
|
xforms: Vec<Matrix4x4>,
|
||||||
|
|
||||||
|
// Object list
|
||||||
|
objects: Vec<Object>,
|
||||||
|
object_map: HashMap<String, usize>, // map Name -> Index
|
||||||
|
|
||||||
|
// Assembly list
|
||||||
|
assemblies: Vec<Assembly>,
|
||||||
|
assembly_map: HashMap<String, usize>, // map Name -> Index
|
||||||
|
|
||||||
|
// Object accel
|
||||||
|
object_accel: BVH,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Object {
|
||||||
|
Surface(Box<Surface>),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
enum Instance {
|
||||||
|
Object {
|
||||||
|
data_index: usize,
|
||||||
|
transform_indices: (usize, usize),
|
||||||
|
shader_index: usize,
|
||||||
|
},
|
||||||
|
|
||||||
|
Assembly {
|
||||||
|
data_index: usize,
|
||||||
|
transform_indices: (usize, usize),
|
||||||
|
},
|
||||||
|
}
|
|
@ -14,6 +14,8 @@ mod image;
|
||||||
mod triangle;
|
mod triangle;
|
||||||
mod surface;
|
mod surface;
|
||||||
mod bvh;
|
mod bvh;
|
||||||
|
mod scene;
|
||||||
|
mod assembly;
|
||||||
mod halton;
|
mod halton;
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
11
src/scene.rs
Normal file
11
src/scene.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
use camera::Camera;
|
||||||
|
use assembly::Assembly;
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Scene {
|
||||||
|
name: String,
|
||||||
|
background_color: (f32, f32, f32),
|
||||||
|
camera: Camera,
|
||||||
|
root: Assembly,
|
||||||
|
}
|
|
@ -1,11 +1,14 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
pub mod triangle_mesh;
|
pub mod triangle_mesh;
|
||||||
|
|
||||||
use ray::Ray;
|
use ray::Ray;
|
||||||
use math::{Point, Normal, Matrix4x4};
|
use math::{Point, Normal, Matrix4x4};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum SurfaceIntersection {
|
pub enum SurfaceIntersection {
|
||||||
Miss,
|
Miss,
|
||||||
Occlude,
|
Occlude,
|
||||||
|
@ -18,6 +21,6 @@ pub enum SurfaceIntersection {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Surface {
|
pub trait Surface: Debug {
|
||||||
fn intersect_rays(&self, rays: &mut [Ray], isects: &mut [SurfaceIntersection]);
|
fn intersect_rays(&self, rays: &mut [Ray], isects: &mut [SurfaceIntersection]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use bvh::BVH;
|
||||||
|
|
||||||
use super::{Surface, SurfaceIntersection};
|
use super::{Surface, SurfaceIntersection};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct TriangleMesh {
|
pub struct TriangleMesh {
|
||||||
time_samples: usize,
|
time_samples: usize,
|
||||||
geo: Vec<(Point, Point, Point)>,
|
geo: Vec<(Point, Point, Point)>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user