From c31e7cb1ec52e9a2b1c70f117e3eddd55343a59b Mon Sep 17 00:00:00 2001 From: numzero Date: Sun, 22 Sep 2024 16:13:43 +0300 Subject: [PATCH] Tripod! --- src/bin/wireframe/main.rs | 24 ++++++++++++++++++------ src/bin/wireframe/ray.v.glsl | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/bin/wireframe/main.rs b/src/bin/wireframe/main.rs index 4be379a..1cacea3 100644 --- a/src/bin/wireframe/main.rs +++ b/src/bin/wireframe/main.rs @@ -60,23 +60,35 @@ fn main() { let indices = glium::index::NoIndices(glium::index::PrimitiveType::LineLoop); let shape = vec![ Vertex { - position: [-1., 0., 4.], + position: [0., 0., 0.], }, Vertex { - position: [0., -1., 4.], + position: [1., 0., 0.], }, Vertex { - position: [1., 0., 4.], + position: [0., 0., 0.], }, Vertex { - position: [0., 1., 4.], + position: [0., 1., 0.], + }, + Vertex { + position: [0., 0., 0.], + }, + Vertex { + position: [0., 0., 1.], }, ]; let vertex_buffer = VertexBuffer::new(&display, &shape).unwrap(); + let rot = Quat::from_euler( + glam::EulerRot::YXZ, + std::f32::consts::FRAC_PI_4, + std::f32::consts::FRAC_PI_6, + 0., + ); let mut cur_pos = vec2(0., 0.); - let mut cam_pos = DragCtl::new(Vec3::ZERO); - let mut cam_rot = DragCtl::new(Quat::IDENTITY); + let mut cam_pos = DragCtl::new(rot * vec3(0., 0., 4.)); + let mut cam_rot = DragCtl::new(rot.inverse()); #[allow(deprecated)] event_loop diff --git a/src/bin/wireframe/ray.v.glsl b/src/bin/wireframe/ray.v.glsl index 947c66a..c51e18d 100644 --- a/src/bin/wireframe/ray.v.glsl +++ b/src/bin/wireframe/ray.v.glsl @@ -8,6 +8,6 @@ in vec3 position; out vec3 vertex_color; void main() { - vertex_color = color; + vertex_color = position; gl_Position = mvp * vec4(position, 1.0); }