Replace bunny with dodecahedron on test image
This commit is contained in:
parent
9785e3b451
commit
d96942cd78
31
src/main.rs
31
src/main.rs
|
|
@ -7,7 +7,7 @@ use sdl2::rect::Rect;
|
|||
use sdl2::render::{Canvas, Texture};
|
||||
use sdl2::Sdl;
|
||||
|
||||
use nalgebra::{Point3, Vector3};
|
||||
use nalgebra::{convert, Point3, Rotation3, Vector3};
|
||||
|
||||
use clap::Arg;
|
||||
|
||||
|
|
@ -18,11 +18,8 @@ use std::time::Duration;
|
|||
use vanrijn::colour::{ColourRgbF, NamedColour};
|
||||
use vanrijn::image::{ClampingToneMapper, ImageRgbU8, ToneMapper};
|
||||
use vanrijn::materials::{LambertianMaterial, PhongMaterial, ReflectiveMaterial};
|
||||
use vanrijn::mesh::load_obj;
|
||||
use vanrijn::partial_render_scene;
|
||||
use vanrijn::raycasting::{
|
||||
Aggregate, BoundingVolumeHierarchy, Plane, Primitive, Sphere, Transform,
|
||||
};
|
||||
use vanrijn::raycasting::{Aggregate, Plane, Primitive, Sphere, Transform};
|
||||
use vanrijn::scene::Scene;
|
||||
use vanrijn::util::polyhedra::generate_dodecahedron;
|
||||
use vanrijn::util::{Tile, TileIterator};
|
||||
|
|
@ -119,20 +116,32 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
image_height as u32,
|
||||
)?;
|
||||
|
||||
let model_file_path =
|
||||
/*let model_file_path =
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("test_data/stanford_bunny.obj");
|
||||
println!("Loading object...");
|
||||
let model_object = load_obj(
|
||||
&model_file_path,
|
||||
Arc::new(ReflectiveMaterial {
|
||||
colour: ColourRgbF::from_named(NamedColour::Yellow),
|
||||
diffuse_strength: 0.01,
|
||||
diffuse_strength: 0.05,
|
||||
reflection_strength: 0.9,
|
||||
}),
|
||||
)?;
|
||||
println!("Building BVH...");
|
||||
)?;*/
|
||||
let model_object: Vec<_> = generate_dodecahedron(
|
||||
Point3::new(0.25, 1.5, 2.5),
|
||||
1.0,
|
||||
Arc::new(LambertianMaterial {
|
||||
colour: ColourRgbF::from_named(NamedColour::Green),
|
||||
diffuse_strength: 0.1,
|
||||
}),
|
||||
)
|
||||
.iter()
|
||||
.map(|elem| elem.transform(&convert(Rotation3::from_euler_angles(0.0, 0.0, 1.0))))
|
||||
.map(|elem| Box::new(elem.clone()) as Box<dyn Primitive<f64>>)
|
||||
.collect();
|
||||
/*println!("Building BVH...");
|
||||
let model_bvh: Box<dyn Aggregate<_>> = Box::new(BoundingVolumeHierarchy::build(model_object));
|
||||
println!("Constructing Scene...");
|
||||
println!("Constructing Scene...");*/
|
||||
|
||||
let scene = Scene {
|
||||
camera_location: Point3::new(-2.0, 1.0, -5.0),
|
||||
|
|
@ -174,7 +183,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
}),
|
||||
)),
|
||||
]) as Box<dyn Aggregate<f64>>,
|
||||
model_bvh,
|
||||
Box::new(model_object),
|
||||
],
|
||||
};
|
||||
println!("Done.");
|
||||
|
|
|
|||
Loading…
Reference in New Issue