4 extern crate gfx_device_gl;
8 use graphics::{Line, Rectangle, Polygon, Ellipse, DrawState, Transformed};
10 const BLACK: [f32; 4] = [0.0, 0.0, 0.0, 1.0];
11 const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0];
13 //fn rand_color() -> [f32; 4] {
29 pub fn view_space<G: graphics::Graphics>(s: &Space,
31 c: graphics::Context, gl: &mut G) {
32 let (xctr, zctr) = ((wsize.w - wsize.side_w) / 2.0, (wsize.h - wsize.header_h) / 2.0);
33 let (xcur, ycur, zcur) = (s.row_size_before_current(Axis::X) as f64,
34 (s.row_size_before_current(Axis::Y) / 2) as f64,
35 s.row_size_before_current(Axis::Z) as f64);
36 let (wshift, hshift) = (xctr - (xcur + ycur) + wsize.side_w,
37 zctr - (zcur + ycur) + wsize.header_h);
38 let mut wy = (s.row_size(Axis::Y) / 3) as f64;
39 for iy in (0..s.faces[0].len()).rev() {
40 let ysize = (s.size[Space::axis_idx(Axis::Y)][iy] / 3) as f64;
42 for ix in 0..s.faces.len() {
43 let xsize = s.size[Space::axis_idx(Axis::X)][ix] as f64;
45 for iz in 0..s.faces[0][0].len() {
46 let zsize = s.size[Space::axis_idx(Axis::Z)][iz] as f64;
47 match s.faces[ix][iy][iz] {
51 if let Some((r, g, b)) = ss[Space::ori_idx(Ori::Back)] {
52 Rectangle::new([r, g, b, 0.6])
53 .draw([0.0, 0.0, xsize, zsize],
54 &DrawState::default(),
55 c.transform.trans(x, z),
57 Rectangle::new_border(BLACK, 1.0)
58 .draw([0.0, 0.0, xsize, zsize],
59 &DrawState::default(),
60 c.transform.trans(x, z),
63 if let Some((r, g, b)) = ss[Space::ori_idx(Ori::Top)] {
64 Polygon::new([r, g, b, 0.6])
67 [x + xsize - ysize, z - ysize],
68 [x - ysize, z - ysize]],
69 &DrawState::default(),
75 &DrawState::default(),
80 x + xsize - ysize, z - ysize],
81 &DrawState::default(),
85 .draw([x + xsize - ysize, z - ysize,
86 x - ysize, z - ysize],
87 &DrawState::default(),
91 .draw([x - ysize, z - ysize,
93 &DrawState::default(),
97 if let Some((r, g, b)) = ss[Space::ori_idx(Ori::Side)] {
98 Polygon::new([r, g, b, 0.6])
99 .draw(&[[x, z + zsize],
101 [x - ysize, z - ysize],
102 [x - ysize, z + zsize - ysize]],
103 &DrawState::default(),
106 Line::new(BLACK, 1.0)
109 &DrawState::default(),
112 Line::new(BLACK, 1.0)
114 x - ysize, z - ysize],
115 &DrawState::default(),
118 Line::new(BLACK, 1.0)
119 .draw([x - ysize, z - ysize,
120 x - ysize, z + zsize - ysize],
121 &DrawState::default(),
124 Line::new(BLACK, 1.0)
125 .draw([x - ysize, z + zsize - ysize,
127 &DrawState::default(),
131 if (ix, iy, iz) == s.current_node_coord() {
133 .draw([-3.0, -3.0, 7.0, 7.0],
134 &DrawState::default(),
135 c.transform.trans(x, z),
138 Pos::E((_, a)) => match a {
139 Axis::X => Line::new(RED, 1.0)
140 .draw([x, z, x + xsize, z],
141 &DrawState::default(),
144 Axis::Y => Line::new(RED, 1.0)
145 .draw([x, z, x - ysize, z - ysize],
146 &DrawState::default(),
149 Axis::Z => Line::new(RED, 1.0)
150 .draw([x, z, x, z + zsize],
151 &DrawState::default(),
155 Pos::F((_, o)) => match o {
156 Ori::Back => Rectangle::new_border(RED, 1.0)
157 .draw([0.0, 0.0, xsize, zsize],
158 &DrawState::default(),
159 c.transform.trans(x, z),
165 &DrawState::default(),
170 x + xsize - ysize, z - ysize],
171 &DrawState::default(),
175 .draw([x + xsize - ysize, z - ysize,
176 x - ysize, z - ysize],
177 &DrawState::default(),
181 .draw([x - ysize, z - ysize,
183 &DrawState::default(),
191 &DrawState::default(),
196 x - ysize, z - ysize],
197 &DrawState::default(),
201 .draw([x - ysize, z - ysize,
202 x - ysize, z + zsize - ysize],
203 &DrawState::default(),
207 .draw([x - ysize, z + zsize - ysize,
209 &DrawState::default(),