pub struct RenderSetData {
pub vertices: Vec<Vertex>,
pub primitives: Vec<Primitive>,
pub groups: Vec<Group>,
}Fields§
§vertices: Vec<Vertex>All vertices for the model. To access correct vertices, use correct method of the model to get access to them.
primitives: Vec<Primitive>Indices of the model, linking all vertices.
groups: Vec<Group>Groups of indices.
Implementations§
Source§impl RenderSetData
impl RenderSetData
Sourcepub fn get_group(&self, index: usize) -> Option<(&[Vertex], &[Primitive])>
pub fn get_group(&self, index: usize) -> Option<(&[Vertex], &[Primitive])>
Get a specific primitive group. Only its vertices and primitives are returned.
Examples found in repository?
examples/model.rs (line 23)
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 RenderSetData
impl RefUnwindSafe for RenderSetData
impl Send for RenderSetData
impl Sync for RenderSetData
impl Unpin for RenderSetData
impl UnwindSafe for RenderSetData
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