Struct glium_shapes::cuboid::CuboidBuilder
[−]
[src]
pub struct CuboidBuilder { /* fields omitted */ }
Responsible for building and returning a Cuboid
object.
By default, the cuboid is defined as a unit-cube with its centre-of-mass located at the origin. This can be overriden using the transformation methods on this object.
The resultant geometry is constructed to suit OpenGL defaults - assuming a right-handed coordinate system, front-facing polygons are defined in counter-clock-wise order. Vertex normals point in the direction of their respective face (such that the shape appears faceted when lit). Vertex texture coordinates define a planar-projection on each face.
Methods
impl CuboidBuilder
[src]
fn new() -> CuboidBuilder
Create a new CuboidBuilder
object.
fn scale(self, x: f32, y: f32, z: f32) -> Self
Apply a scaling transformation to the shape.
The scale
, translate
, and rotate
functions accumulate, and are
not commutative. The transformation functions are intended to provide
flexibility in model-space. For per-instance world-space transformations,
one should prefer to share as few shapes as possible across multiple
instances, and instead rely on uniform constants in the shader and/or
instanced drawing.
fn translate(self, x: f32, y: f32, z: f32) -> Self
Apply a translation transformation to the shape.
The scale
, translate
, and rotate
functions accumulate, and are
not commutative. The transformation functions are intended to provide
flexibility in model-space. For per-instance world-space transformations,
one should prefer to share as few shapes as possible across multiple
instances, and instead rely on uniform constants in the shader and/or
instanced drawing.
fn rotate_x(self, radians: f32) -> Self
Apply a rotation transformation to the shape about the x-axis.
The scale
, translate
, and rotate
functions accumulate, and are
not commutative. The transformation functions are intended to provide
flexibility in model-space. For per-instance world-space transformations,
one should prefer to share as few shapes as possible across multiple
instances, and instead rely on uniform constants in the shader and/or
instanced drawing.
fn rotate_y(self, radians: f32) -> Self
Apply a rotation transformation to the shape about the y-axis.
The scale
, translate
, and rotate
functions accumulate, and are
not commutative. The transformation functions are intended to provide
flexibility in model-space. For per-instance world-space transformations,
one should prefer to share as few shapes as possible across multiple
instances, and instead rely on uniform constants in the shader and/or
instanced drawing.
fn rotate_z(self, radians: f32) -> Self
Apply a rotation transformation to the shape about the z-axis.
The scale
, translate
, and rotate
functions accumulate, and are
not commutative. The transformation functions are intended to provide
flexibility in model-space. For per-instance world-space transformations,
one should prefer to share as few shapes as possible across multiple
instances, and instead rely on uniform constants in the shader and/or
instanced drawing.
fn build<F>(self, display: &F) -> Result<Cuboid, ShapeCreationError> where F: Facade
Build a new Cuboid
object.
fn build_vertices(&self) -> Result<Vec<Vertex>, ShapeCreationError>
Build the shape vertices and return them in a vector.
Useful if you wish to do other things with the vertices besides constructing
a Cuboid
object (e.g. unit testing, further processing, etc).