[][src]Trait plexus::FromRawBuffers

pub trait FromRawBuffers<N, G>: Sized {
    type Error: Debug;
    fn from_raw_buffers<I, J>(
        indices: I,
        vertices: J
    ) -> Result<Self, Self::Error>
    where
        I: IntoIterator<Item = N>,
        J: IntoIterator<Item = G>
; }

Associated Types

type Error: Debug

Loading content...

Required methods

fn from_raw_buffers<I, J>(indices: I, vertices: J) -> Result<Self, Self::Error> where
    I: IntoIterator<Item = N>,
    J: IntoIterator<Item = G>, 

Loading content...

Implementors

impl<A, N, M, G> FromRawBuffers<M, G> for MeshBuffer<Flat<A, N>, G> where
    A: NonZero + Unsigned,
    N: Copy + Integer + NumCast + Unsigned,
    M: Copy + Integer + NumCast + Unsigned,
    <Flat<A, N> as IndexBuffer>::Item: ToPrimitive
[src]

type Error = BufferError

fn from_raw_buffers<I, J>(indices: I, vertices: J) -> Result<Self, BufferError> where
    I: IntoIterator<Item = M>,
    J: IntoIterator<Item = G>, 
[src]

Creates a flat MeshBuffer from raw index and vertex buffers.

Errors

Returns an error if the index data is out of bounds within the vertex buffer or if the number of indices disagrees with the arity of the index buffer.

Examples

use plexus::buffer::MeshBuffer3;
use plexus::prelude::*;
use plexus::primitive;
use plexus::primitive::cube::Cube;
use plexus::primitive::index::HashIndexer;

let cube = Cube::new();
let (indices, vertices) = primitive::zip_vertices((
    cube.polygons_with_position(),
    cube.polygons_with_normal(),
    cube.polygons_with_uv_map(),
))
.flat_index_vertices(HashIndexer::default());
let buffer = MeshBuffer3::<usize, _>::from_raw_buffers(indices, vertices).unwrap();

impl<P, G, H> FromRawBuffers<P, H> for MeshGraph<G> where
    P: IntoVertices + Polygonal,
    P::Vertex: Integer + ToPrimitive + Unsigned,
    G: Geometry,
    H: IntoGeometry<G::Vertex>, 
[src]

type Error = GraphError

impl<P, Q, G> FromRawBuffers<Q, G> for MeshBuffer<Structured<P>, G> where
    P: Polygonal,
    P::Vertex: Copy + Integer + NumCast + Unsigned,
    Q: Into<<Structured<P> as IndexBuffer>::Item>,
    Structured<P>: IndexBuffer,
    <Structured<P> as IndexBuffer>::Item: Copy + IntoVertices + Topological<Vertex = P::Vertex>, 
[src]

type Error = BufferError

fn from_raw_buffers<I, J>(indices: I, vertices: J) -> Result<Self, BufferError> where
    I: IntoIterator<Item = Q>,
    J: IntoIterator<Item = G>, 
[src]

Creates a structured MeshBuffer from raw index and vertex buffers.

Errors

Returns an error if the index data is out of bounds within the vertex buffer.

Examples

use nalgebra::Point3;
use plexus::buffer::MeshBufferN;
use plexus::prelude::*;
use plexus::primitive::sphere::UvSphere;

let sphere = UvSphere::new(8, 8);
let buffer = MeshBufferN::<usize, _>::from_raw_buffers(
    sphere.indices_for_position(),
    sphere
        .vertices_with_position()
        .map(|position| -> Point3<f32> { position.into() }),
)
.unwrap();
Loading content...