Struct truck_rendimpl::polymesh::PolygonMesh [−][src]
pub struct PolygonMesh<V = StandardVertex, A = StandardAttributes> { /* fields omitted */ }Expand description
Polygon mesh
The polygon data is held in a method compliant with wavefront obj. Position, uv (texture) coordinates, and normal vectors are held in separate arrays, and each face vertex accesses those values by an indices triple.
Implementations
pub fn expands<T>(
&self,
contraction: impl Fn(<A as Attributes<V>>::Output) -> T
) -> PolygonMesh<usize, Vec<T, Global>> where
T: Copy,
pub fn expands<T>(
&self,
contraction: impl Fn(<A as Attributes<V>>::Output) -> T
) -> PolygonMesh<usize, Vec<T, Global>> where
T: Copy,
Contract attributes and expand polygon.
Examples
use truck_polymesh::*;
let polygon = PolygonMesh::new(
StandardAttributes {
positions: vec![
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
Point3::new(1.0, 1.0, 0.0),
],
normals: vec![
Vector3::new(0.0, 0.0, 1.0),
Vector3::new(0.0, 0.0, -1.0),
],
..Default::default()
},
Faces::from_iter(&[
&[(0, None, Some(0)), (1, None, Some(0)), (2, None, Some(0))],
&[(3, None, Some(1)), (1, None, Some(1)), (2, None, Some(1))],
])
);
let expands = polygon.expands(|attr| (attr.position, attr.normal.unwrap()));
assert_eq!(
expands,
PolygonMesh::<usize, Vec<(Point3, Vector3)>>::new(
vec![
(Point3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 1.0)),
(Point3::new(1.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 1.0)),
(Point3::new(0.0, 1.0, 0.0), Vector3::new(0.0, 0.0, 1.0)),
(Point3::new(1.0, 1.0, 0.0), Vector3::new(0.0, 0.0, -1.0)),
(Point3::new(1.0, 0.0, 0.0), Vector3::new(0.0, 0.0, -1.0)),
(Point3::new(0.0, 1.0, 0.0), Vector3::new(0.0, 0.0, -1.0)),
],
Faces::from_iter(&[[0, 1, 2], [3, 4, 5]]),
)
);complete constructor
Errors
Returns Error::OutOfRange if there is an index is out of range.
Remarks
This method does not check whether the normal is normalized or not.
constructor without boundary check
constructor, boundary check is acrivated only in debug mode.
Returns attributes
Returns the vector of all triangles of the polygon.
Returns the vector of all quadrangles.
Returns the iterator of the slice.
By the internal optimization, this iterator does not runs in the simple order
in which they are registered, but runs order: triangle, square, and the others.
cf: Faces::face_iter
Returns the iterator of the slice.
By the internal optimization, this iterator does not runs in the simple order
in which they are registered, but runs order: triangle, square, and the others.
cf: Faces::face_iter
Creates an editor that performs boundary checking on dropped.
Creates an editor that does NOT perform boundary checking on dropped.
Creates an editor that performs boundary checking on dropped ONLY in debug build.
Returns polygonmesh merged self and mesh.
Creates the bounding box of the polygon mesh.
Returns the vector of all positions.
Returns the mutable slice of all positions.
Adds a position.
Extend positions by iterator.
Returns the vector of all uv (texture) coordinates.
Returns the mutable slice of all uv (texture) coordinates.
Adds a uv (texture) coordinate.
Extend uv (texture) coordinates by iterator.
Returns the vector of all normals.
Returns the mutable slice of all normals.
Extend normals by iterator
Trait Implementations
fn buffers(
&self,
vertex_usage: BufferUsages,
index_usage: BufferUsages,
device: &Device
) -> (BufferHandler, BufferHandler)
fn buffers(
&self,
vertex_usage: BufferUsages,
index_usage: BufferUsages,
device: &Device
) -> (BufferHandler, BufferHandler)
Creates buffer handlers of attributes and indices.
Returns the “default value” for a type. Read more
impl<'de, V, A> Deserialize<'de> for PolygonMesh<V, A> where
V: Deserialize<'de>,
A: Deserialize<'de>,
impl<'de, V, A> Deserialize<'de> for PolygonMesh<V, A> where
V: Deserialize<'de>,
A: Deserialize<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<PolygonMesh<V, A>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<PolygonMesh<V, A>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn from_iter<I>(iter: I) -> PolygonMesh<StandardVertex, StandardAttributes> where
I: IntoIterator<Item = STLFace>,
pub fn from_iter<I>(iter: I) -> PolygonMesh<StandardVertex, StandardAttributes> where
I: IntoIterator<Item = STLFace>,
Creates a value from an iterator. Read more
type IntoIter = PolygonMeshSTLFaceIterator<'a>
type IntoIter = PolygonMeshSTLFaceIterator<'a>
Which kind of iterator are we turning this into?
pub fn into_iter(
self
) -> <&'a PolygonMesh<StandardVertex, StandardAttributes> as IntoSTLIterator>::IntoIter
pub fn into_iter(
self
) -> <&'a PolygonMesh<StandardVertex, StandardAttributes> as IntoSTLIterator>::IntoIter
Creates an iterator from a value.
Returns the inverse.
impl<V, A> PartialEq<PolygonMesh<V, A>> for PolygonMesh<V, A> where
V: PartialEq<V>,
A: PartialEq<A>,
impl<V, A> PartialEq<PolygonMesh<V, A>> for PolygonMesh<V, A> where
V: PartialEq<V>,
A: PartialEq<A>,
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
type State = PolygonState
type State = PolygonState
Configuation deacriptor for instance.
fn to_instance(
&self,
handler: &DeviceHandler,
shaders: &PolygonShaders,
state: &PolygonState
) -> PolygonInstance
fn to_instance(
&self,
handler: &DeviceHandler,
shaders: &PolygonShaders,
state: &PolygonState
) -> PolygonInstance
Creates Instance from self.
type State = WireFrameState
type State = WireFrameState
Configuation deacriptor for instance.
Creates Instance from self.
Auto Trait Implementations
impl<V, A> RefUnwindSafe for PolygonMesh<V, A> where
A: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, A> Send for PolygonMesh<V, A> where
A: Send,
V: Send,
impl<V, A> Sync for PolygonMesh<V, A> where
A: Sync,
V: Sync,
impl<V, A> Unpin for PolygonMesh<V, A> where
A: Unpin,
V: Unpin,
impl<V, A> UnwindSafe for PolygonMesh<V, A> where
A: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more