use trackpad to move camera/world

This commit is contained in:
2016-09-30 23:25:31 -07:00
parent 9323380d5c
commit 8211912b44
4 changed files with 115 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ pub type ColorFormat = gfx::format::Srgba8;
pub type DepthFormat = gfx::format::DepthStencil;
const NEAR: f32 = 0.01;
const FAR: f32 = 1000000.0;
const FAR: f32 = 1000.0;
gfx_constant_struct! {
Trans {
@@ -75,11 +75,15 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
window.encoder.clear_depth(&buffers.depth, 1.0);
// Submit eye textures
// Submit eye textures
let proj_mat = vr.projection_matrix(eye, NEAR, FAR);
let eye_mat = vr.head_to_eye_transform(eye);
let trans = Trans { matrix: *(proj_mat * eye_mat * hmd_mat).as_ref() };
use self::na::ToHomogeneous;
let view_mat = na::Similarity3::new(na::Vector3::new(0.0, 128.0 - 16.0, 0.0),
na::Vector3::new(0.0, 0.0, 0.0), 1.0).to_homogeneous();
let trans = Trans { matrix: *(proj_mat * eye_mat * hmd_mat * view_mat).as_ref() };
window.encoder.update_constant_buffer(&self.trans, &trans);
scene.render(&mut window.factory,