pub struct Model {
pub visual: Box<Visual>,
pub render_sets_data: Vec<RenderSetData>,
}Fields§
§visual: Box<Visual>Description of the visual components of the model.
render_sets_data: Vec<RenderSetData>Decoded data for each render set.
Implementations§
Source§impl Model
impl Model
Sourcepub fn get_render_set(
&self,
index: usize,
) -> Option<(&RenderSet, &RenderSetData)>
pub fn get_render_set( &self, index: usize, ) -> Option<(&RenderSet, &RenderSetData)>
Shortcut method to get a render set metadata together with its data.
Examples found in repository?
examples/model.rs (line 22)
8fn main() {
9
10 let path_raw = env::var("WGT_MODEL_PATH").unwrap();
11 let path = Path::new(&path_raw);
12 let mut visual_file = File::open(path.with_extension("visual_processed")).unwrap();
13 let primitives_file = File::open(path.with_extension("primitives_processed")).unwrap();
14
15 let model = model::from_readers(visual_file, primitives_file).unwrap();
16
17 // println!("{model:#?}");
18
19 let mut obj_file = File::create("./test.obj").unwrap();
20 let mut mtl_file = File::create("./test.mtl").unwrap();
21
22 let (rs, rsd) = model.get_render_set(0).unwrap();
23 let (vertices, primitives) = rsd.get_group(0).unwrap();
24
25 let mat = &rs.geometry.primitive_groups[0].material;
26 println!("properties: {:?}", mat.properties);
27 println!("fx: {:?}", mat.fx);
28
29 writeln!(obj_file, "mtllib test.mtl").unwrap();
30 writeln!(obj_file, "usemtl TankMaterial").unwrap();
31 for v in vertices {
32 writeln!(obj_file, "v {} {} {}", v.position.x, v.position.y, v.position.z).unwrap();
33 }
34 for v in vertices {
35 writeln!(obj_file, "vt {} {}", v.uv.x, v.uv.y).unwrap();
36 }
37 for v in vertices {
38 writeln!(obj_file, "vn {} {} {}", v.normal.x, v.normal.y, v.normal.z).unwrap();
39 }
40
41 for p in primitives {
42 writeln!(obj_file, "f {a}/{a}/{a} {b}/{b}/{b} {c}/{c}/{c}", a = p.a + 1, b = p.b + 1, c = p.c + 1).unwrap();
43 }
44
45 writeln!(mtl_file, "newmtl TankMaterial").unwrap();
46 writeln!(mtl_file, "map_Ka RenaultFT_hull_01_AM.png").unwrap();
47 writeln!(mtl_file, "map_Kd RenaultFT_hull_01_AM.png").unwrap();
48 writeln!(mtl_file, "map_Bump RenaultFT_hull_01_ANM.png").unwrap();
49 writeln!(mtl_file, "map_Ks RenaultFT_hull_01_GMM.png").unwrap();
50
51
52}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnwindSafe for Model
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more