diff --git a/docs/TODO_phase3.md b/docs/TODO_phase3.md index c9b31a5fc9..93a5605cb8 100644 --- a/docs/TODO_phase3.md +++ b/docs/TODO_phase3.md @@ -45,7 +45,7 @@ - basic structure with actions, react, stepping is same. SimQueue, lookahead, can goto? differs. - handle map borders - - manually mark them? + - manually mark polygon, not a bbox, as the border - be able to start/end trips there - start to model demand data with manually selecting a source/dest area @@ -54,3 +54,4 @@ - macro to insert a call at the beginning of a fxn - macro to apply a macro to all fxns in an impl - then i can manually edit a few places when I want to gather data + - https://en.wikipedia.org/wiki/File:A_Call_Graph_generated_by_pycallgraph.png diff --git a/docs/design/gui.md b/docs/design/gui.md index a2f74cd35b..fb3bd4c560 100644 --- a/docs/design/gui.md +++ b/docs/design/gui.md @@ -180,3 +180,11 @@ One UI plugin at a time: - alright, atfer the current cleanup with short-circuiting... express as a more abstract monadish thing? or since there are side effects sometimes and inconsistent arguments and such, maybe not? - consistently mutate a plugin or return a copy - the Optionals might be annoying. + +## OpenGL camera transforms + +- https://crates.io/crates/cgmath +- https://www.nalgebra.org/cg_recipes/ +- https://docs.rs/euclid/0.19.0/euclid/struct.TypedTransform2D.html +- https://www.reddit.com/r/rust/comments/6sukcw/is_it_possible_to_to_create_an_ortho_view_in_glium/ has a direct example of affine transformation +- https://www.reddit.com/r/gamedev/comments/4mn9ly/3d_matrix_transformation_question_rotating/ diff --git a/docs/halloween.md b/docs/halloween.md new file mode 100644 index 0000000000..27ef1fe6cb --- /dev/null +++ b/docs/halloween.md @@ -0,0 +1,10 @@ +# Halloween visual demo + +- cars with headlights +- pumpkins +- fences / bushes / features in houses (maybe fences around parcel boundaries?) or triangulation on a block with buildings +- buildings as rooms in a hotel +- silent hill soundtrack +- deformed buildings pulsing on front path springs +- lighting? +- fog effects diff --git a/tmp_gfx/src/main.rs b/tmp_gfx/src/main.rs index d0e290f3de..bf80907566 100644 --- a/tmp_gfx/src/main.rs +++ b/tmp_gfx/src/main.rs @@ -27,10 +27,12 @@ gfx_defines!{ fn main() { let mut events_loop = glutin::EventsLoop::new(); + let (initial_width, initial_height) = (700.0, 700.0); + let glutin_builder = glutin::WindowBuilder::new() - .with_dimensions(LogicalSize::new(700.0, 700.0)) + .with_dimensions(LogicalSize::new(initial_width, initial_height)) .with_decorations(true) - .with_title("Simple tessellation".to_string()); + .with_title("gfx playground".to_string()); let context = glutin::ContextBuilder::new().with_vsync(true); @@ -51,26 +53,35 @@ fn main() { // The geometry! let vertices = vec![ + // 0 = Top-left GpuFillVertex { - position: [-1.0, -1.0], - }, - GpuFillVertex { - position: [1.0, -1.0], - }, - GpuFillVertex { - position: [-1.0, 1.0], + position: [-1.0, 0.7], }, + // 1 = Top-right GpuFillVertex { position: [1.0, 1.0], }, + // 2 = Bottom-left + GpuFillVertex { + position: [-1.0, -1.0], + }, + // 3 = Bottom-right + GpuFillVertex { + position: [1.0, -1.0], + }, ]; - let indices: Vec = vec![0, 1, 2, 2, 3, 0]; + let indices: Vec = vec![0, 1, 2, 1, 2, 3]; let (vbo, ibo) = factory.create_vertex_buffer_with_slice(&vertices, &indices[..]); let mut cmd_queue: gfx::Encoder<_, _> = factory.create_command_buffer().into(); + let mut cam = Camera { + center_x: initial_width / 2.0, + center_y: initial_height / 2.0, + zoom: 1.0, + }; loop { - if !update_inputs(&mut events_loop) { + if !handle_input(&mut events_loop, &mut cam) { break; } @@ -93,12 +104,19 @@ fn main() { } } -fn update_inputs(event_loop: &mut glutin::EventsLoop) -> bool { +struct Camera { + // Center on some point + center_x: f64, + center_y: f64, + zoom: f64, +} + +fn handle_input(event_loop: &mut glutin::EventsLoop, cam: &mut Camera) -> bool { use glutin::ElementState::Pressed; use glutin::Event; use glutin::VirtualKeyCode; - let mut status = true; + let mut keep_running = true; event_loop.poll_events(|event| match event { Event::WindowEvent { @@ -106,7 +124,7 @@ fn update_inputs(event_loop: &mut glutin::EventsLoop) -> bool { .. } => { println!("Window Closed!"); - status = false; + keep_running = false; } Event::WindowEvent { event: @@ -122,16 +140,30 @@ fn update_inputs(event_loop: &mut glutin::EventsLoop) -> bool { .. } => match key { VirtualKeyCode::Escape => { - status = false; + keep_running = false; } - _key => {} + VirtualKeyCode::Left => { + cam.center_x -= 1.0; + } + VirtualKeyCode::Right => { + cam.center_x += 1.0; + } + VirtualKeyCode::Up => { + cam.center_y += 1.0; + } + VirtualKeyCode::Down => { + cam.center_y -= 1.0; + } + _ => {} }, _ => {} }); - status + keep_running } +// Coordinate system is math-like -- Y increases up. + static VERTEX_SHADER: &'static str = " #version 140 @@ -140,7 +172,7 @@ static VERTEX_SHADER: &'static str = " void main() { gl_Position = vec4(a_position, 0.0, 1.0); - gl_Position.y *= -1.0; + // gl_Position.y *= -1.0; v_color = vec4(1.0, 0.0, 0.0, 0.5); } ";