aboutsummaryrefslogtreecommitdiff
path: root/src/camera.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/camera.rs')
-rw-r--r--src/camera.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/camera.rs b/src/camera.rs
index 204b9f8..c620b24 100644
--- a/src/camera.rs
+++ b/src/camera.rs
@@ -1,8 +1,6 @@
-use cgmath::Matrix3;
-use cgmath::Rad;
use cgmath::Vector3;
use cgmath::prelude::*;
-use std::{cmp::{max, min}, f32::consts::PI, fmt};
+use std::fmt;
type Vector = Vector3<f32>;
@@ -29,12 +27,15 @@ pub struct Camera {
pub time: f32,
pub position: Vector,
pub direction: Vector,
+ pub up: Vector,
pub light: Vector,
pub angle: f32,
pub distance: f32,
pub brightness: f32,
pub aspect_ratio: f32,
pub buffer: Buffer,
+ pub speed: f32,
+ pub turn_rate: f32,
}
fn softmin(left: f32, right: f32, k: f32) -> f32 {
@@ -97,8 +98,8 @@ impl Camera {
let palette = "$@B%8&WM#oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\"^`'. ";
let (screen_width, screen_height) = self.screen();
- let h_step = Matrix3::from_angle_z(Rad::turn_div_4()) * self.direction * screen_width / WIDTH as f32;
- let v_step = Vector { x: 0.0, y: 0.0, z: -screen_height / HEIGHT as f32 };
+ let h_step = self.up.cross(self.direction) * screen_width / WIDTH as f32;
+ let v_step = -self.up * screen_height / HEIGHT as f32;
// println!("Steps: h{}, v{}", h_step, v_step);
// Initialize with a corner