58 lines
1.2 KiB
Rust
58 lines
1.2 KiB
Rust
use serde::Deserialize;
|
|
|
|
use crate::{camera::Camera, vec3::Vec3};
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct RawCamera {
|
|
// output
|
|
image_width: u32, // TODO: test these are now explicitly required (and that default impl does
|
|
// not make these optional)
|
|
image_height: u32,
|
|
|
|
// raytracing
|
|
#[serde(default)]
|
|
anti_alias_rate: u32,
|
|
#[serde(default)]
|
|
max_depth: u32,
|
|
|
|
// camera
|
|
#[serde(default)]
|
|
fov: f32,
|
|
#[serde(default)]
|
|
look_from: Vec3,
|
|
#[serde(default)]
|
|
look_at: Vec3,
|
|
#[serde(default)]
|
|
vup: Vec3,
|
|
}
|
|
|
|
impl Default for RawCamera {
|
|
fn default() -> Self {
|
|
Self {
|
|
image_width: 400,
|
|
image_height: 300,
|
|
anti_alias_rate: 1,
|
|
max_depth: 10,
|
|
fov: 70.,
|
|
look_from: Vec3::new(0., 0., 0.),
|
|
look_at: Vec3::new(0., 0., -1.),
|
|
vup: Vec3::new(0., 1., 0.),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<RawCamera> for Camera {
|
|
fn from(raw: RawCamera) -> Self {
|
|
Camera::new_full(
|
|
raw.image_width,
|
|
raw.image_height,
|
|
raw.anti_alias_rate,
|
|
raw.max_depth,
|
|
raw.fov,
|
|
raw.look_from,
|
|
raw.look_at,
|
|
raw.vup,
|
|
)
|
|
}
|
|
}
|