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
impl MeshGeometry
Sourcepub fn new(
gx: u32,
gy: u32,
tex_w: u32,
tex_h: u32,
) -> Result<Self, RenderError>
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).
Sourcepub fn ang(&self) -> &[f32]
pub fn ang(&self) -> &[f32]
m_vertinfo[n].ang of each vertex (-pi..pi as atan2f, centre vertex 0).
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Number of vertices, (gx + 1) * (gy + 1).
Sourcepub fn index(&self, x: u32, y: u32) -> usize
pub fn index(&self, x: u32, y: u32) -> usize
Index of the vertex at column x, row y (row 0 = bottom of the screen).
Sourcepub fn pv_x(&self, n: usize) -> f32
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.
Sourcepub fn pv_y(&self, n: usize) -> f32
pub fn pv_y(&self, n: usize) -> f32
Preset-space y (0 = top .. 1 = bottom): m_verts[n].y*-0.5*aspectY + 0.5.
Sourcepub fn projectm_vertex(&self, x: u32, y: u32) -> ([f32; 2], f32, f32)
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).