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
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§
Source§impl Clone for OrientedBlockFace
impl Clone for OrientedBlockFace
Source§fn clone(&self) -> OrientedBlockFace
fn clone(&self) -> OrientedBlockFace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more