WIP: hacky world torus

This commit is contained in:
2016-09-25 00:41:14 -07:00
parent 8a68c1780e
commit 9323380d5c
5 changed files with 76 additions and 19 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 = 1000.0;
const FAR: f32 = 1000000.0;
gfx_constant_struct! {
Trans {
@@ -40,6 +40,10 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
-> ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
let render_size = vr.recommended_render_target_size();
let render_size = vr::Size { width: render_size.width * 220 / 100,
height: render_size.height * 220 / 100 };
let left = vr::create_eyebuffer(&mut window.factory, render_size)
.expect("create left renderbuffer");
let right = vr::create_eyebuffer(&mut window.factory, render_size)
@@ -67,7 +71,7 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
for &(eye, buffers) in [(vr::Eye::Left, &self.left),
(vr::Eye::Right, &self.right)].into_iter() {
window.encoder.clear(&buffers.target, [0.05, 0.05, 0.1, 1.0]);
window.encoder.clear(&buffers.target, [0.005, 0.005, 0.01, 1.0]);
window.encoder.clear_depth(&buffers.depth, 1.0);
@@ -75,9 +79,7 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
let proj_mat = vr.projection_matrix(eye, NEAR, FAR);
let eye_mat = vr.head_to_eye_transform(eye);
let model_mat = na::Matrix4::one();
let trans = Trans { matrix: *(proj_mat * eye_mat * hmd_mat * model_mat).as_ref() };
let trans = Trans { matrix: *(proj_mat * eye_mat * hmd_mat).as_ref() };
window.encoder.update_constant_buffer(&self.trans, &trans);
scene.render(&mut window.factory,