mouselook

This commit is contained in:
2016-12-26 12:46:59 -08:00
committed by Jared Burce
parent f40786931e
commit 5e18d452cb
3 changed files with 17 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ use std::time::SystemTime;
use gfx::{self, texture};
use gfx::traits::FactoryExt;
use na;
use piston::input::{Button, ButtonArgs, ButtonState, Input, Key};
use piston::input::{Button, ButtonArgs, ButtonState, Input, Key, Motion};
const PI: f32 = ::std::f32::consts::PI;
const TWO_PI_CIRC: f32 = 2.0 * PI / 256.0;
@@ -134,6 +134,7 @@ pub struct WorldScene<D: gfx::Device,
start_time: SystemTime,
treadmills: (f32, f32),
mouselook: na::Matrix4<f32>,
pads: BTreeMap<u32, (TrackMode, Option<vr::ControllerState>)>,
_worldmap: model::World,
@@ -171,6 +172,7 @@ impl<D: gfx::Device, F: gfx::Factory<D::Resources>> WorldScene<D, F> {
slice: slice,
start_time: SystemTime::now(),
treadmills: (0.0, 0.0),
mouselook: na::Matrix4::identity(),
pads: BTreeMap::new(),
_worldmap: worldmap,
@@ -277,6 +279,14 @@ impl<D: gfx::Device,
_ => ()
}
}
// mouselook
Piston(Input::Move(Motion::MouseCursor(x, y))) => {
self.mouselook = (
na::Rotation3::new(na::Vector3::<f32>::new(y as f32 / 300.0, 0.0, 0.0)) *
na::Rotation3::new(na::Vector3::<f32>::new(0.0, x as f32 / 300.0, 0.0))
).to_homogeneous();
},
_ => ()
}
}
@@ -371,6 +381,10 @@ impl<D: gfx::Device,
&normal,
).to_homogeneous()
}
fn mouselook(&self) -> na::Matrix4<f32> {
self.mouselook
}
}
fn get_data_model() -> model::World {