Geometry

Trait Geometry 

Source
pub trait Geometry<O: Ops = StdOps> {
    // Required methods
    fn num_faces(&self) -> usize;
    fn num_vertices_of_face(&self, face: usize) -> usize;
    fn position(&self, face: usize, vert: usize) -> [f32; 3];
    fn normal(&self, face: usize, vert: usize) -> [f32; 3];
    fn tex_coord(&self, face: usize, vert: usize) -> [f32; 2];
    fn set_tangent(
        &mut self,
        tangent_space: Option<TangentSpace>,
        face: usize,
        vert: usize,
    );
}
Expand description

Provides an interface for reading vertex information from geometry, and writing back out the calculated tangent space information.

Without the std feature, there is no default implementation for Ops provided. Instead, you must also provide a type implementing Ops using an alternative math backend, such as libm.

Required Methods§

Source

fn num_faces(&self) -> usize

Returns the number of faces on the mesh to be processed. This can include unsupported face types (e.g., not triangles or quads), but they will be ignored.

Source

fn num_vertices_of_face(&self, face: usize) -> usize

Returns the number of vertices on face number face. face is a number in the range 0..get_num_faces().

Source

fn position(&self, face: usize, vert: usize) -> [f32; 3]

Returns the position of the referenced face of vertex number vert. face is a number in the range 0..get_num_faces(). vert is in the range 0..=2 for triangles and 0..=3 for quads.

Source

fn normal(&self, face: usize, vert: usize) -> [f32; 3]

Returns the normal of the referenced face of vertex number vert. face is a number in the range 0..get_num_faces(). vert is in the range 0..=2 for triangles and 0..=3 for quads.

Source

fn tex_coord(&self, face: usize, vert: usize) -> [f32; 2]

Returns the texture coordinate of the referenced face of vertex number vert. face is a number in the range 0..get_num_faces(). vert is in the range 0..=2 for triangles and 0..=3 for quads.

Source

fn set_tangent( &mut self, tangent_space: Option<TangentSpace>, face: usize, vert: usize, )

This function is used to return tangent space results to the application.

Note that unlike the original C implementation, tangent spaces are turned as an Option<TangentSpace>. This serves two purposes:

  1. TangentSpace encodes all calculated results for a particular vertex, and provides convenient getters for simplified results.
  2. An Option is provided as the internal algorithm may not produce a value for this vertex. This typically occurs in cases where a degenerate face has no neighbors to borrow a value from. Instead of silently returning a default value, this implementation explicitly provides None and leaves it up to the user to instead use the default value.

Implementors§