Struct block_mesh::geometry::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
sourceimpl OrientedBlockFace
impl OrientedBlockFace
pub const fn new(n_sign: i32, permutation: AxisPermutation) -> Self
sourcepub fn canonical(normal: SignedAxis) -> Self
pub fn canonical(normal: SignedAxis) -> Self
A cube face, using axes with an even permutation.
pub fn signed_normal(&self) -> IVec3
sourcepub fn quad_corners(&self, quad: &UnorientedQuad) -> [UVec3; 4]
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.
pub fn quad_mesh_positions(
&self,
quad: &UnorientedQuad,
voxel_size: f32
) -> [[f32; 3]; 4]
pub fn quad_mesh_normals(&self) -> [[f32; 3]; 4]
sourcepub fn quad_mesh_indices(&self, start: u32) -> [u32; 6]
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.
sourcepub fn tex_coords(
&self,
u_flip_face: Axis,
flip_v: bool,
quad: &UnorientedQuad
) -> [[f32; 2]; 4]
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
sourceimpl Clone for OrientedBlockFace
impl Clone for OrientedBlockFace
sourcefn clone(&self) -> OrientedBlockFace
fn clone(&self) -> OrientedBlockFace
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for OrientedBlockFace
impl Debug for OrientedBlockFace
sourceimpl PartialEq<OrientedBlockFace> for OrientedBlockFace
impl PartialEq<OrientedBlockFace> for OrientedBlockFace
sourcefn eq(&self, other: &OrientedBlockFace) -> bool
fn eq(&self, other: &OrientedBlockFace) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &OrientedBlockFace) -> bool
fn ne(&self, other: &OrientedBlockFace) -> bool
This method tests for !=
.
impl Copy for OrientedBlockFace
impl Eq for OrientedBlockFace
impl StructuralEq for OrientedBlockFace
impl StructuralPartialEq for OrientedBlockFace
Auto Trait Implementations
impl RefUnwindSafe for OrientedBlockFace
impl Send for OrientedBlockFace
impl Sync for OrientedBlockFace
impl Unpin for OrientedBlockFace
impl UnwindSafe for OrientedBlockFace
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more