Skip to main content

MeshGeometry

Struct MeshGeometry 

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

Static mesh data: vertex positions and MD2’s rad/ang per-vertex attributes.

The grid has an even number of cells (>= 2) per axis; MeshGeometry::new enforces that, which is why the fields are private.

Implementations§

Source§

impl MeshGeometry

Source

pub fn new( gx: u32, gy: u32, tex_w: u32, tex_h: u32, ) -> Result<Self, RenderError>

Build the mesh of gx x gy cells for a tex_w x tex_h image.

Fails with RenderError::Invalid unless both cell counts are even and at least 2 (MD2 builds the grid from four quadrants).

Source

pub fn gx(&self) -> u32

Number of cells (not vertices) in x.

Source

pub fn gy(&self) -> u32

Number of cells (not vertices) in y.

Source

pub fn aspect_x(&self) -> f32

m_fAspectX (computed from the texture size).

Source

pub fn aspect_y(&self) -> f32

m_fAspectY (computed from the texture size).

Source

pub fn x(&self) -> &[f32]

Clip-space x of each vertex (m_verts[n].x).

Source

pub fn y(&self) -> &[f32]

Clip-space y of each vertex (m_verts[n].y).

Source

pub fn rad(&self) -> &[f32]

m_vertinfo[n].rad of each vertex.

Source

pub fn ang(&self) -> &[f32]

m_vertinfo[n].ang of each vertex (-pi..pi as atan2f, centre vertex 0).

Source

pub fn vertex_count(&self) -> usize

Number of vertices, (gx + 1) * (gy + 1).

Source

pub fn index(&self, x: u32, y: u32) -> usize

Index of the vertex at column x, row y (row 0 = bottom of the screen).

Source

pub fn pv_x(&self, n: usize) -> f32

Preset-space x (0 = left .. 1 = right) of vertex n, as per-pixel code sees it: m_verts[n].x*0.5*aspectX + 0.5.

Source

pub fn pv_y(&self, n: usize) -> f32

Preset-space y (0 = top .. 1 = bottom): m_verts[n].y*-0.5*aspectY + 0.5.

Source

pub fn projectm_vertex(&self, x: u32, y: u32) -> ([f32; 2], f32, f32)

projectM’s own vertex data (PerPixelMesh::InitializeMesh) for the vertex at column x, lactea row y (row 0 = bottom). projectM’s mesh row 0 is the top of the image, so its y is row_pm / gy * 2 - 1 with row_pm = gy - y (float rounding differs from -self.y[n]); rad = hypotf(x*ax, y*ay), ang = atan2f(y*ay, x*ax) (0 at the centre vertex). Returns (pos, rad, ang).

Trait Implementations§

Source§

impl Clone for MeshGeometry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MeshGeometry

Source§

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

Formats the value using the given formatter. 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<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> 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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,