pub struct PolygonMesh<V = StandardVertex, A = StandardAttributes> { /* private fields */ }
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

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

Panics

Panic occurs if there is an index is out of range.

Remarks

This method does not check whether the normal is normalized or not.

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 faces of the polygon.

Returns the vector of all triangles of the polygon.

Returns the vector of all quadrangles.

Returns the vector of n-gons (n > 4).

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Creates buffer handlers of attributes and indices.

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Creates a value from an iterator. Read more

Which kind of iterator are we turning this into?

Creates an iterator from a value.

Inverts self

Returns the inverse.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Configuation deacriptor for instance.

Creates Instance from self.

Configuation deacriptor for instance.

Creates Instance from self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.