-
Notifications
You must be signed in to change notification settings - Fork 1
/
cylinder.rs
49 lines (43 loc) · 1.17 KB
/
cylinder.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use glam::DVec3;
use raytracer::{
camera::Camera,
material::Material,
shapes::{
cylinder::Cylinder, rounded_box::RoundedBox,
sphere::Sphere, Shapes,
},
};
use std::io;
fn main() -> io::Result<()> {
let mut world: Vec<Shapes> = vec![];
let material_ground = Material::Lambertian {
albedo: DVec3::new(0.8, 0.8, 0.0),
};
let material_center = Material::Lambertian {
albedo: DVec3::new(0., 0., 1.),
};
world.push(Shapes::Sphere(Sphere {
center: DVec3::new(0.0, -100.5, -1.0),
radius: 100.0,
material: material_ground,
}));
world.push(Shapes::Cylinder(Cylinder {
start: DVec3::new(0.1, 0.1, -1.),
end: DVec3::new(0.1, -0.1, -1.),
radius: 10.,
material: material_center,
}));
let camera = Camera::init()
.image_width(600)
.aspect_ratio(16.0 / 9.0)
.look_from(DVec3::new(1., 1., 10.))
.look_at(DVec3::NEG_Z)
.vup(DVec3::Y)
// .focus_dist(10.0)
// .defocus_angle(0.0)
.samples_per_pixel(100)
.max_depth(50)
.build();
camera.render_to_disk("cylinder", world)?;
Ok(())
}