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:
Nathan Vegdahl 2016-03-08 21:57:51 -08:00
parent 147b22b861
commit 25f8e0782a
5 changed files with 63 additions and 1 deletions

45
src/assembly.rs Normal file
View 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),
},
}

View File

@ -14,6 +14,8 @@ mod image;
mod triangle;
mod surface;
mod bvh;
mod scene;
mod assembly;
mod halton;
use std::mem;

11
src/scene.rs Normal file
View 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,
}

View File

@ -1,11 +1,14 @@
#![allow(dead_code)]
use std::fmt::Debug;
pub mod triangle_mesh;
use ray::Ray;
use math::{Point, Normal, Matrix4x4};
#[derive(Debug)]
pub enum SurfaceIntersection {
Miss,
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]);
}

View File

@ -9,6 +9,7 @@ use bvh::BVH;
use super::{Surface, SurfaceIntersection};
#[derive(Debug)]
pub struct TriangleMesh {
time_samples: usize,
geo: Vec<(Point, Point, Point)>,