@@ -5,6 +5,7 @@ mod icon;
5
5
mod intersect;
6
6
mod octree;
7
7
mod palette;
8
+ mod rampify;
8
9
mod simplify;
9
10
mod voxelize;
10
11
@@ -23,7 +24,7 @@ use std::{
23
24
use voxelize:: voxelize;
24
25
25
26
const WINDOW_WIDTH : f32 = 600. ;
26
- const WINDOW_HEIGHT : f32 = 380 .;
27
+ const WINDOW_HEIGHT : f32 = 420 .;
27
28
28
29
const OBJ_ICON : & [ u8 ; 10987 ] = include_bytes ! ( "../res/obj_icon.png" ) ;
29
30
@@ -36,6 +37,7 @@ struct Obj2Brs {
36
37
save_owner_id : String ,
37
38
save_owner_name : String ,
38
39
raise : bool ,
40
+ rampify : bool ,
39
41
save_name : String ,
40
42
scale : f32 ,
41
43
simplify : bool ,
@@ -57,15 +59,16 @@ impl Default for Obj2Brs {
57
59
save_owner_id : "d66c4ad5-59fc-4a9b-80b8-08dedc25bff9" . into ( ) ,
58
60
save_owner_name : "obj2brs" . into ( ) ,
59
61
raise : true ,
62
+ rampify : false ,
60
63
save_name : "test" . into ( ) ,
61
64
scale : 1.0 ,
62
- simplify : true ,
65
+ simplify : false ,
63
66
}
64
67
}
65
68
}
66
69
67
70
impl App for Obj2Brs {
68
- fn update ( & mut self , ctx : & egui:: CtxRef , _frame : & mut eframe:: epi:: Frame < ' _ > ) {
71
+ fn update ( & mut self , ctx : & egui:: CtxRef , _frame : & eframe:: epi:: Frame ) {
69
72
let input_file_valid = Path :: new ( & self . input_file_path ) . exists ( ) ;
70
73
let output_dir_valid = Path :: new ( & self . output_directory ) . is_dir ( ) ;
71
74
let uuid_valid = Uuid :: parse_str ( & self . save_owner_id ) . is_ok ( ) ;
@@ -147,9 +150,10 @@ impl Obj2Brs {
147
150
}
148
151
149
152
fn options ( & mut self , ui : & mut Ui , uuid_valid : bool ) {
153
+
150
154
ui. label ( "Lossy Conversion" )
151
155
. on_hover_text ( "Whether or not to merge similar bricks to create a less detailed model" ) ;
152
- ui. add ( Checkbox :: new ( & mut self . simplify , "Simplify (reduces brickcount)" ) ) ;
156
+ ui. add_enabled ( ! self . rampify , Checkbox :: new ( & mut self . simplify , "Simplify (reduces brickcount)" ) ) ;
153
157
ui. end_row ( ) ;
154
158
155
159
ui. label ( "Raise Underground" )
@@ -159,7 +163,12 @@ impl Obj2Brs {
159
163
160
164
ui. label ( "Match to Colorset" )
161
165
. on_hover_text ( "Modify the color of the model to match the default color palette in Brickadia" ) ;
162
- ui. add ( Checkbox :: new ( & mut self . match_brickadia_colorset , "Use Default Palette" ) ) ;
166
+ ui. add_enabled ( !self . rampify , Checkbox :: new ( & mut self . match_brickadia_colorset , "Use Default Palette" ) ) ;
167
+ ui. end_row ( ) ;
168
+
169
+ ui. label ( "Rampify" )
170
+ . on_hover_text ( "Creates a Lego-World like rampification of the model, uses default colorset" ) ;
171
+ ui. add ( Checkbox :: new ( & mut self . rampify , "Run the result through Wrapperup's plate-rampifier" ) ) ;
163
172
ui. end_row ( ) ;
164
173
165
174
ui. label ( "Scale" )
@@ -187,7 +196,7 @@ impl Obj2Brs {
187
196
ui. end_row ( ) ;
188
197
}
189
198
190
- fn do_conversion ( & self ) {
199
+ fn do_conversion ( & mut self ) {
191
200
println ! ( "{:?}" , self ) ;
192
201
let mut octree = match generate_octree ( self ) {
193
202
Ok ( tree) => tree,
@@ -201,7 +210,7 @@ impl Obj2Brs {
201
210
202
211
write_brs_data (
203
212
& mut octree,
204
- & self ,
213
+ self ,
205
214
) ;
206
215
}
207
216
}
@@ -273,8 +282,17 @@ fn generate_octree(opt: &Obj2Brs) -> Result<octree::VoxelTree<Vector4<u8>>, Stri
273
282
274
283
fn write_brs_data (
275
284
octree : & mut octree:: VoxelTree < Vector4 < u8 > > ,
276
- opts : & Obj2Brs ,
285
+ opts : & mut Obj2Brs ,
277
286
) {
287
+ let mut max_merge = 200 ;
288
+
289
+ if opts. rampify {
290
+ opts. simplify = false ;
291
+ opts. match_brickadia_colorset = true ;
292
+ opts. bricktype = BrickType :: Default ;
293
+ max_merge = 1 ;
294
+ }
295
+
278
296
let owner = brs:: save:: User {
279
297
name : opts. save_owner_name . clone ( ) ,
280
298
id : opts. save_owner_id . parse ( ) . unwrap ( ) ,
@@ -287,7 +305,13 @@ fn write_brs_data(
287
305
..Default :: default ( )
288
306
} ,
289
307
header2 : brs:: save:: Header2 {
290
- brick_assets : vec ! [ "PB_DefaultMicroBrick" . into( ) , "PB_DefaultBrick" . into( ) ] ,
308
+ brick_assets :
309
+ vec ! [
310
+ "PB_DefaultMicroBrick" . into( ) ,
311
+ "PB_DefaultBrick" . into( ) ,
312
+ "PB_DefaultRamp" . into( ) ,
313
+ "PB_DefaultWedge" . into( ) ,
314
+ ] ,
291
315
brick_owners : vec ! [ brs:: save:: BrickOwner :: from_user_bricks( owner. clone( ) , 1 ) ] ,
292
316
colors : palette:: DEFAULT_PALETTE . to_vec ( ) ,
293
317
..Default :: default ( )
@@ -297,9 +321,9 @@ fn write_brs_data(
297
321
298
322
println ! ( "Simplifying..." ) ;
299
323
if opts. simplify {
300
- simplify_lossy ( octree, & mut write_data, opts. bricktype , opts. match_brickadia_colorset ) ;
324
+ simplify_lossy ( octree, & mut write_data, opts. bricktype , opts. match_brickadia_colorset , max_merge ) ;
301
325
} else {
302
- simplify_lossless ( octree, & mut write_data, opts. bricktype , opts. match_brickadia_colorset ) ;
326
+ simplify_lossless ( octree, & mut write_data, opts. bricktype , opts. match_brickadia_colorset , max_merge ) ;
303
327
}
304
328
305
329
if opts. raise {
@@ -321,6 +345,10 @@ fn write_brs_data(
321
345
}
322
346
}
323
347
348
+ if opts. rampify {
349
+ rampify:: rampify ( & mut write_data) ;
350
+ }
351
+
324
352
// Write file
325
353
println ! ( "Writing {} bricks..." , write_data. bricks. len( ) ) ;
326
354
0 commit comments