Struct hexx::mesh::MeshInfo

source ·
pub struct MeshInfo {
    pub vertices: Vec<Vec3>,
    pub normals: Vec<Vec3>,
    pub uvs: Vec<Vec2>,
    pub indices: Vec<u16>,
}
Expand description

Hexagonal mesh information.

§Usage

Use:

The mesh info has some customization options:


let layout = HexLayout::default();
// Build the mesh info
let info: MeshInfo = ColumnMeshBuilder::new(&layout, 2.0).build();
// Customize the generated mesh
let info = info
    .rotated(Quat::IDENTITY)
    .with_offset(Vec3::new(12.0, 34.2, -43.54));

§Merging

MeshInfo can be merged with other meshes using Self::merge_with. Don’t forget to offset the meshes in the mesh builder using:

Otherwise you might end up with meshes at the same coordinates

Fields§

§vertices: Vec<Vec3>

All vertices positions information (Vertex_Position attribute)

§normals: Vec<Vec3>

Normals for each vertex (You might need to swap y and z) (Vertex_Normal attribute)

§uvs: Vec<Vec2>

UV coordinates of each vertex (Vertex_Uv attribute)

§indices: Vec<u16>

Vertex indices for triangles

Implementations§

source§

impl MeshInfo

source

pub fn rotated(self, rotation: Quat) -> Self

Returns a new MeshInfo but with vertex positions and normals rotated

source

pub fn with_offset(self, offset: Vec3) -> Self

Returns a new MeshInfo but with offset applied to vertex positions

source

pub fn merge_with(&mut self, rhs: Self)

Merges rhs into self. All vertices, normals and uvs are appended to self and indices are offsetted to maintain triangle data.

§Note

This method doesn’t merge vertices or tries to remove invisible faces.

§Panics

Will panic if there are more vertices than u16::MAX

source

pub fn hexagonal_plane(layout: &HexLayout, hex: Hex) -> Self

👎Deprecated since 0.13.0: Use PlaneMeshBuilder instead

Computes mesh data for an hexagonal plane facing Vec3::Y with 6 vertices and 4 triangles

§Note

Prefer using PlaneMeshBuilder for additional customization like:

  • UV options
  • Offsets
  • rotation
  • etc
source

pub fn cheap_hexagonal_column( layout: &HexLayout, hex: Hex, column_height: f32 ) -> Self

Computes cheap mesh data for an hexagonal column facing Vec3::Y without the bottom face.

This mesh has only 12 vertices, as no vertex is duplicated. As a consequence the normals will behave strangely and the UV mapping will be extremely simplistic and stretched on the sides.

Use this mesh if you don’t care about lighting and texturing, like for convex hull collision shapes.

Prefer using ColumnMeshBuilder in most cases

Trait Implementations§

source§

impl Clone for MeshInfo

source§

fn clone(&self) -> MeshInfo

Returns a copy 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 MeshInfo

source§

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

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

impl Default for MeshInfo

source§

fn default() -> MeshInfo

Returns the “default value” for a type. Read more

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> 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,

§

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>,

§

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>,

§

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.