1use std::{fs::File, io::Write};
2
3use rmesh::{write_rmesh, ComplexMesh, Header, RMeshError, Vertex, ROOM_SCALE};
4
5fn main() -> Result<(), RMeshError> {
6 let mut args = std::env::args();
7 let _ = args.next();
8
9 let min_x = -1.0 / ROOM_SCALE;
10 let min_y = -1.0 / ROOM_SCALE;
11 let min_z = -1.0 / ROOM_SCALE;
12 let max_x = 1.0 / ROOM_SCALE;
13 let max_y = 1.0 / ROOM_SCALE;
14 let max_z = 1.0 / ROOM_SCALE;
15
16 let vertices = vec![
17 Vertex {
19 position: [min_x, min_y, max_z],
20 ..Default::default()
21 },
22 Vertex {
23 position: [max_x, min_y, max_z],
24 ..Default::default()
25 },
26 Vertex {
27 position: [max_x, max_y, max_z],
28 ..Default::default()
29 },
30 Vertex {
31 position: [min_x, max_y, max_z],
32 ..Default::default()
33 },
34 Vertex {
36 position: [min_x, max_y, min_z],
37 ..Default::default()
38 },
39 Vertex {
40 position: [max_x, max_y, min_z],
41 ..Default::default()
42 },
43 Vertex {
44 position: [max_x, min_y, min_z],
45 ..Default::default()
46 },
47 Vertex {
48 position: [min_x, min_y, min_z],
49 ..Default::default()
50 },
51 Vertex {
53 position: [max_x, min_y, min_z],
54 ..Default::default()
55 },
56 Vertex {
57 position: [max_x, max_y, min_z],
58 ..Default::default()
59 },
60 Vertex {
61 position: [max_x, max_y, max_z],
62 ..Default::default()
63 },
64 Vertex {
65 position: [max_x, min_y, max_z],
66 ..Default::default()
67 },
68 Vertex {
70 position: [min_x, min_y, max_z],
71 ..Default::default()
72 },
73 Vertex {
74 position: [min_x, max_y, max_z],
75 ..Default::default()
76 },
77 Vertex {
78 position: [min_x, max_y, min_z],
79 ..Default::default()
80 },
81 Vertex {
82 position: [min_x, min_y, min_z],
83 ..Default::default()
84 },
85 Vertex {
87 position: [max_x, max_y, min_z],
88 ..Default::default()
89 },
90 Vertex {
91 position: [min_x, max_y, min_z],
92 ..Default::default()
93 },
94 Vertex {
95 position: [min_x, max_y, max_z],
96 ..Default::default()
97 },
98 Vertex {
99 position: [max_x, max_y, max_z],
100 ..Default::default()
101 },
102 Vertex {
104 position: [max_x, min_y, max_z],
105 ..Default::default()
106 },
107 Vertex {
108 position: [min_x, min_y, max_z],
109 ..Default::default()
110 },
111 Vertex {
112 position: [min_x, min_y, min_z],
113 ..Default::default()
114 },
115 Vertex {
116 position: [max_x, min_y, min_z],
117 ..Default::default()
118 },
119 ];
120
121 let header = Header {
122 meshes: vec![ComplexMesh {
123 vertices,
124 triangles: vec![
125 [0, 1, 2],
126 [2, 3, 0], [4, 5, 6],
128 [6, 7, 4], [8, 9, 10],
130 [10, 11, 8], [12, 13, 14],
132 [14, 15, 12], [16, 17, 18],
134 [18, 19, 16], [20, 21, 22],
136 [22, 23, 20], ],
138 ..Default::default()
139 }],
140 ..Default::default()
141 };
142 let rmesh = write_rmesh(&header)?;
143 let mut file = File::create(args.next().expect("No output location provided")).unwrap();
144 file.write_all(&rmesh).unwrap();
145 Ok(())
146}