///
/// Transforms the entire mesh by applying the `transformation` to each vertex position.
///
/// # Examples
///
/// ```
/// # use tri_mesh::prelude::*;
/// #
/// # fn main() -> Result<(), Box<tri_mesh::mesh_builder::Error>> {
///     let mut mesh = MeshBuilder::new().cube().build()?;
/// #   let first_vertex_id = mesh.vertex_iter().next().unwrap();
/// #   let vertex_position_before = mesh.vertex_position(first_vertex_id);
///     mesh.apply_transformation(Mat4::from_translation(vec3(2.5, -1.0, 0.0)));
/// #   let vertex_position_after = mesh.vertex_position(first_vertex_id);
/// #   assert_eq!(vertex_position_before + vec3(2.5, -1.0, 0.0), vertex_position_after);
/// #   mesh.is_valid().unwrap();
/// #   Ok(())
/// # }
/// ```
///
Transforms the entire mesh by applying the `transformation` to each vertex position.
Transforms the entire mesh by applying the ` transformation ` to each vertex position .
pub fn apply_transformation(&mut self, transformation: Mat4)
    {
        for vertex_id in self.vertex_iter() {
            let p = self.vertex_position(vertex_id);
            let p_new = (transformation * p.extend(1.0)).truncate();
            self.move_vertex_to(vertex_id, p_new);
        }
    }
pub fn apply_transformation ( & mut self , transformation : Mat4 ) { for vertex_id in self . vertex_iter ( ) { let p = self . vertex_position ( vertex_id ) ; let p_new = ( transformation * p . extend ( 1.0 ) ) . truncate ( ) ; self . move_vertex_to ( vertex_id , p_new ) ; } }
Transforms the entire mesh by applying the `transformation` to each vertex position.
Transforms the entire mesh by applying the ` transformation ` to each vertex position .
&mut self
transformation
Mat4
examples
None
use tri_mesh::prelude::*;
None
fn main() -> result<(), box<tri_mesh::mesh_builder::error>> {
let mut mesh = MeshBuilder::new().cube().build()?.
let mut mesh = MeshBuilder :: new () . cube () . build () ? .
let first_vertex_id = mesh.vertex_iter().next().unwrap();
None
let vertex_position_before = mesh.vertex_position(first_vertex_id);
None
let vertex_position_after = mesh.vertex_position(first_vertex_id);
None
assert_eq!(vertex_position_before + vec3(2.5, -1.0, 0.0), vertex_position_after);
None
mesh.is_valid().unwrap();
None
ok(())
None
}
None