Add color mapping to planes

This commit is contained in:
bijan2005 2020-11-30 11:56:55 -05:00
parent ff625f576f
commit 639518c317
8 changed files with 99 additions and 35 deletions

View file

@ -17,11 +17,11 @@ pub struct Camera {
}
impl Camera {
// Constructs a new camera from a position and viewing direction
// (assuming the camera is oriented upright).
pub fn new(pos: Point3<f32>, dir: Vector3<f32>, focal_length: f32,
// Constructs a new camera from a position and viewing direction.
pub fn new_(pos: Point3<f32>, dir: Vector3<f32>, up: Vector3<f32>, focal_length: f32,
canvas_x: f32, canvas_y: f32, image_x: u32, image_y: u32) -> Self {
let iso = Isometry3::face_towards(&pos, &(pos + dir), &Vector3::y());
let iso = Isometry3::face_towards(&pos, &(pos + dir), &up);
Camera {
matrix: iso,
focal_length: focal_length,
@ -30,6 +30,12 @@ impl Camera {
}
}
// Constructs a new camera from a position and viewing direction
// (assuming the camera is oriented upright).
pub fn new(pos: Point3<f32>, dir: Vector3<f32>, focal_length: f32,
canvas_x: f32, canvas_y: f32, image_x: u32, image_y: u32) -> Self
{ Camera::new_(pos, dir, Vector3::y(), focal_length, canvas_x, canvas_y, image_x, image_y) }
pub fn pos(&self) -> Point3<f32> { Point3::from(self.matrix.translation.vector) }
// Takes a 2D point in the image space and