Realize the triangle struct doesn't work and completely refactor it
This commit is contained in:
parent
822941d561
commit
cddec468de
6 changed files with 107 additions and 71 deletions
|
|
@ -20,21 +20,21 @@ impl Camera {
|
|||
|
||||
// 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, aspect_ratio: f32, canvas_x: f32, image_x: u32) -> Self {
|
||||
focal_length: f32, aspect_ratio: f32, canvas_y: f32, image_y: u32) -> Self {
|
||||
let iso = Isometry3::face_towards(&pos, &(pos + dir), &up);
|
||||
Camera {
|
||||
matrix: iso,
|
||||
focal_length: focal_length,
|
||||
canvas_size: Vector2::new(canvas_x, canvas_x * aspect_ratio),
|
||||
image_size: Vector2::new(image_x, (image_x as f32 * aspect_ratio) as u32)
|
||||
canvas_size: Vector2::new(canvas_y * aspect_ratio, canvas_y),
|
||||
image_size: Vector2::new((image_y as f32 * aspect_ratio) as u32, image_y)
|
||||
}
|
||||
}
|
||||
|
||||
// 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, aspect_ratio: f32, canvas_x: f32, image_x: u32) -> Self
|
||||
{ Camera::new_(pos, dir, Vector3::y(), focal_length, aspect_ratio, canvas_x, image_x) }
|
||||
focal_length: f32, aspect_ratio: f32, canvas_y: f32, image_y: u32) -> Self
|
||||
{ Camera::new_(pos, dir, Vector3::y(), focal_length, aspect_ratio, canvas_y, image_y) }
|
||||
|
||||
pub fn pos(&self) -> Point3<f32> { Point3::from(self.matrix.translation.vector) }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue