[][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 Grouping>::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 decorum::N64;
use nalgebra::Point3;
use plexus::buffer::MeshBuffer3;
use plexus::index::{Flat3, HashIndexer};
use plexus::prelude::*;
use plexus::primitive;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::{Normal, Position};

type E3 = Point3<N64>;

let cube = Cube::new();
let (indices, vertices) = primitive::zip_vertices((
    cube.polygons::<Position<E3>>(),
    cube.polygons::<Normal<E3>>()
        .map_vertices(|normal| normal.into_inner()),
))
.triangulate()
.index_vertices::<Flat3, _>(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: GraphGeometry,
    H: IntoGeometry<G::Vertex>, 
[src]

type Error = GraphError

impl<P, Q, G> FromRawBuffers<Q, G> for MeshBuffer<P, G> where
    P: Grouping + Polygonal,
    P::Vertex: Copy + Integer + NumCast + Unsigned,
    Q: Into<<P as Grouping>::Item>,
    <P as Grouping>::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::generate::Position;
use plexus::primitive::sphere::UvSphere;

let sphere = UvSphere::new(8, 8);
let buffer = MeshBufferN::<usize, _>::from_raw_buffers(
    sphere.indexing_polygons::<Position>(),
    sphere.vertices::<Position<Point3<f64>>>(),
)
.unwrap();
Loading content...