OrientedBlockFace

Struct OrientedBlockFace 

Source
pub struct OrientedBlockFace { /* private fields */ }
Expand description

Metadata that’s used to aid in the geometric calculations for one of the 6 possible cube faces.

Implementations§

Source§

impl OrientedBlockFace

Source

pub const fn new(n_sign: i32, permutation: AxisPermutation) -> Self

Source

pub fn canonical(normal: SignedAxis) -> Self

A cube face, using axes with an even permutation.

Source

pub fn signed_normal(&self) -> IVec3

Source

pub fn quad_corners(&self, quad: &UnorientedQuad) -> [UVec3; 4]

Returns the 4 corners of the quad in this order:

        2 ----> 3
          ^
    ^       \
    |         \
 +V |   0 ----> 1
    |
     -------->
       +U

(+N pointing out of the screen)

Note that this is natural when UV coordinates have (0,0) at the bottom left, but when (0,0) is at the top left, V must be flipped.

Source

pub fn quad_mesh_positions( &self, quad: &UnorientedQuad, voxel_size: f32, ) -> [[f32; 3]; 4]

Source

pub fn quad_mesh_normals(&self) -> [[f32; 3]; 4]

Source

pub fn quad_mesh_indices(&self, start: u32) -> [u32; 6]

Returns the 6 vertex indices for the quad in order to make two triangles in a mesh. Winding order depends on both the sign of the surface normal and the permutation of the UVs.

Front faces will be wound counterclockwise, and back faces clockwise, as per convention.

Source

pub fn tex_coords( &self, u_flip_face: Axis, flip_v: bool, quad: &UnorientedQuad, ) -> [[f32; 2]; 4]

Returns the UV coordinates of the 4 corners of the quad. Returns vertices in the same order as OrientedBlockFace::quad_corners.

u_flip_face should correspond to the field on QuadCoordinateConfig. See the docs there for more info.

This is just one way of assigning UVs to voxel quads. It assumes that each material has a single tile texture with wrapping coordinates, and each voxel face should show the entire texture. It also assumes a particular orientation for the texture. This should be sufficient for minecraft-style meshing.

If you need to use a texture atlas, you must calculate your own coordinates from the Quad.

Trait Implementations§

Source§

impl Clone for OrientedBlockFace

Source§

fn clone(&self) -> OrientedBlockFace

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OrientedBlockFace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for OrientedBlockFace

Source§

fn eq(&self, other: &OrientedBlockFace) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for OrientedBlockFace

Source§

impl Eq for OrientedBlockFace

Source§

impl StructuralPartialEq for OrientedBlockFace

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.