pub struct TriMesh {
pub vertices: Vec<f32>,
pub indices: Vec<i32>,
pub vert_count: usize,
pub tri_count: usize,
}Expand description
A simple triangle mesh
Fields§
§vertices: Vec<f32>Flat array of [x, y, z] coordinates
indices: Vec<i32>Triangle indices, 3 per triangle
vert_count: usize§tri_count: usizeImplementations§
Source§impl TriMesh
impl TriMesh
Sourcepub fn from_obj<P: AsRef<Path>>(path: P) -> Result<Self, MeshError>
pub fn from_obj<P: AsRef<Path>>(path: P) -> Result<Self, MeshError>
Loads a mesh from an OBJ file
This method is only available when the std feature is enabled.
Sourcepub fn from_obj_str(content: &str) -> Result<Self, MeshError>
pub fn from_obj_str(content: &str) -> Result<Self, MeshError>
Parses OBJ content from a string
This method is WASM-compatible and can parse OBJ data that has been loaded into memory through other means (e.g., fetch API in browser).
§Example
use landmark_common::TriMesh;
let obj_content = r#"
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 0.5 1.0 0.0
f 1 2 3
"#;
let mesh = TriMesh::from_obj_str(obj_content).unwrap();
assert_eq!(mesh.vert_count, 3);
assert_eq!(mesh.tri_count, 1);Sourcepub fn calculate_bounds(&self) -> (Vec3, Vec3)
pub fn calculate_bounds(&self) -> (Vec3, Vec3)
Calculates the axis-aligned bounding box of the mesh
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TriMesh
impl RefUnwindSafe for TriMesh
impl Send for TriMesh
impl Sync for TriMesh
impl Unpin for TriMesh
impl UnsafeUnpin for TriMesh
impl UnwindSafe for TriMesh
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