pub struct TriangleMesh {
pub positions: Vec<Vec3>,
pub indices: Vec<u32>,
pub face_normals: Vec<Vec3>,
}Expand description
An indexed triangle mesh in the node’s local coordinates.
Positions are f64; see crate::math for why.
Fields§
§positions: Vec<Vec3>Vertex positions, from points.
indices: Vec<u32>Three indices into positions per triangle, from
faceVertexIndices. Every index is in range.
face_normals: Vec<Vec3>One unit normal per triangle, (b - a) × (c - a) normalised, so
face_normals.len() == indices.len() / 3. Degenerate triangles get
a zero vector. Renderers that want flat shading duplicate vertices
per face and use these.
Implementations§
Source§impl TriangleMesh
impl TriangleMesh
Sourcepub fn from_attribute(value: &Value) -> Result<Self, DecodeError>
pub fn from_attribute(value: &Value) -> Result<Self, DecodeError>
Decodes the value of a ATTRIBUTE (usd::usdgeom::mesh)
attribute.
use openbim_ifcx_geometry::mesh::TriangleMesh;
let value = serde_json::json!({
"points": [[0, 0, 0], [1, 0, 0], [0, 1, 0]],
"faceVertexIndices": [0, 1, 2]
});
let mesh = TriangleMesh::from_attribute(&value)?;
assert_eq!(mesh.triangle_count(), 1);
assert_eq!(mesh.face_normals[0], [0.0, 0.0, 1.0]);Sourcepub fn new(positions: Vec<Vec3>, indices: Vec<u32>) -> Result<Self, DecodeError>
pub fn new(positions: Vec<Vec3>, indices: Vec<u32>) -> Result<Self, DecodeError>
Builds a mesh from positions and triangle indices, checking the indices and computing face normals.
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Number of triangles.
Trait Implementations§
Source§impl Clone for TriangleMesh
impl Clone for TriangleMesh
Source§fn clone(&self) -> TriangleMesh
fn clone(&self) -> TriangleMesh
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TriangleMesh
impl Debug for TriangleMesh
Source§impl PartialEq for TriangleMesh
impl PartialEq for TriangleMesh
impl StructuralPartialEq for TriangleMesh
Auto Trait Implementations§
impl Freeze for TriangleMesh
impl RefUnwindSafe for TriangleMesh
impl Send for TriangleMesh
impl Sync for TriangleMesh
impl Unpin for TriangleMesh
impl UnwindSafe for TriangleMesh
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