RenderSetData

Struct RenderSetData 

Source
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

Source

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§

Source§

impl Debug for RenderSetData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V