Skip to main content

Mesh2DFile

Struct Mesh2DFile 

Source
pub struct Mesh2DFile {
    pub pos_attr: Pos2DATTR,
    pub layer: u8,
    pub aspect: f32,
    pub col_attr: ColATTR,
    pub uvm_attr: UVMATTR,
    pub ind_attr: IndATTR,
    pub cus_attrs: Vec<CustomATTR>,
}
Expand description

CPU-side 2D mesh geometry — positions, UVs, colours, indices, layer, and centre.

Mesh2DFile is the 2D counterpart of Mesh3DFile. It adds:

  • A layer field for draw-order sorting.
  • An aspect ratio and Center enumeration for positioning.

§Generated primitives

FunctionDescription
quadTextured quad sized to a canvas pixel area
fullscreen_quadNDC-space quad (-1..1)
rectRectangle centred at origin
circleApproximated by a regular polygon
polygonRegular polygon (same as circle)
ringAnnulus (donut) shape

Fields§

§pos_attr: Pos2DATTR§layer: u8§aspect: f32§col_attr: ColATTR§uvm_attr: UVMATTR§ind_attr: IndATTR§cus_attrs: Vec<CustomATTR>

Implementations§

Source§

impl Mesh2DFile

Source

pub fn empty() -> Self

Creates an empty 2D mesh.

Source

pub fn set_pos_attr(&mut self, attr: Pos2DATTR)

Replaces the position attribute.

Source

pub fn set_layer(&mut self, layer: u8)

Sets the draw layer (higher values render on top).

Source

pub fn set_center(&mut self, center: Center)

Offsets all vertex positions by the centre vector.

Source

pub fn set_col_attr(&mut self, attr: ColATTR)

Replaces the colour attribute.

Source

pub fn set_uvm_attr(&mut self, attr: UVMATTR)

Replaces the UV attribute.

Source

pub fn set_ind_attr(&mut self, attr: IndATTR)

Replaces the index attribute.

Source

pub fn quad(size: &Size2D) -> Self

Creates a textured quad sized to fill the given canvas area.

The quad’s aspect ratio matches the canvas, and it is centred by default. Used for rendering sprites or UI elements where the quad should preserve the canvas’s proportions in NDC space.

§Conventions
  • Position — 2D in NDC-like space (aspect-ratio aware).
  • UVs — full [0,1]² coverage.
  • Topology — 2 triangles, 4 vertices.
Source

pub fn fullscreen_quad() -> Self

Creates a quad covering the entire NDC space (-1 to +1 on both axes).

Useful for full-screen post-processing effects.

Source

pub fn attach_custom_attr(&mut self, attr: CustomATTR)

Attaches a custom per-vertex attribute.

Source

pub fn circle(radius: f32, segments: u32) -> Self

Creates a circle approximated by a regular polygon.

The first vertex is at the centre, creating a fan topology.

Source

pub fn polygon(radius: f32, sides: u32) -> Self

Creates a regular polygon (alias for circle).

Source

pub fn ring(inner_radius: f32, outer_radius: f32, segments: u32) -> Self

Creates an annular (ring) shape with inner and outer radii.

Source

pub fn rect(width: f32, height: f32) -> Self

Creates a rectangle centred at the origin with the given dimensions.

This is a 2D quad in world-space units (not NDC). Use for billboards, 2D physics bodies, or UI elements that need precise world-space sizing.

§Conventions
  • Position — 2D world-space, centred.
  • UVs — full [0,1]² coverage.
  • Topology — 2 triangles, 4 vertices.
Source

pub fn starts_with_custom(&self) -> bool

Returns true if no built-in vertex attributes are populated.

Source

pub fn ship(&self) -> MeshHandle

Interleaves vertex attributes and uploads to the GPU.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>