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§
Sourcefn num_faces(&self) -> usize
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.
Sourcefn num_vertices_of_face(&self, face: usize) -> usize
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()
.
Sourcefn position(&self, face: usize, vert: usize) -> [f32; 3]
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.
Sourcefn normal(&self, face: usize, vert: usize) -> [f32; 3]
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.
Sourcefn tex_coord(&self, face: usize, vert: usize) -> [f32; 2]
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.
Sourcefn set_tangent(
&mut self,
tangent_space: Option<TangentSpace>,
face: usize,
vert: usize,
)
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:
TangentSpace
encodes all calculated results for a particular vertex, and provides convenient getters for simplified results.- 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 providesNone
and leaves it up to the user to instead use the default value.