pub struct Mesh<'a> { /* private fields */ }Expand description
A parsed 3D mesh backed by slices into the caller’s cooked blob.
Cheap to construct (just bounds-checks the header + computes
sub-slice offsets). Cheap to pass around – table &[u8] slices,
an index stride, a flags u16, and the counts.
Implementations§
Source§impl<'a> Mesh<'a>
impl<'a> Mesh<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ParseError>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ParseError>
Parse a cooked .psxm blob. Returns a Mesh view that
borrows into bytes.
Sourcepub fn vertex_count(&self) -> u16
pub fn vertex_count(&self) -> u16
Vertex count.
Sourcepub fn vert_count(&self) -> u16
👎Deprecated: renamed to vertex_count
pub fn vert_count(&self) -> u16
renamed to vertex_count
Renamed to Self::vertex_count.
Sourcepub fn face_count(&self) -> u16
pub fn face_count(&self) -> u16
Triangle count.
Sourcepub fn has_face_colors(&self) -> bool
pub fn has_face_colors(&self) -> bool
Does the blob carry a face-colour table?
Sourcepub fn has_normals(&self) -> bool
pub fn has_normals(&self) -> bool
Does the blob carry per-vertex normals? Required for any GTE- or CPU-lit rendering path.
Sourcepub fn vertex(&self, i: u16) -> Vec3I16
pub fn vertex(&self, i: u16) -> Vec3I16
Decode vertex i as a Q3.12 Vec3I16. Returns
Vec3I16::ZERO if the index is out of range – keeps
the render path branch-free, callers who care can
check against Self::vertex_count first.
Sourcepub fn face(&self, i: u16) -> (u16, u16, u16)
pub fn face(&self, i: u16) -> (u16, u16, u16)
Triangle i’s three vertex indices. Returns (0, 0, 0)
for an out-of-range index.
Sourcepub fn face_color(&self, i: u16) -> Option<(u8, u8, u8)>
pub fn face_color(&self, i: u16) -> Option<(u8, u8, u8)>
Triangle i’s flat colour, or None if the blob doesn’t
carry a face-colour table.
Sourcepub fn vertex_normal(&self, i: u16) -> Option<Vec3I16>
pub fn vertex_normal(&self, i: u16) -> Option<Vec3I16>
Per-vertex Q3.12 normal. Returns None if the blob lacks
a normal table (HAS_NORMALS flag clear) or i is out of
range. Components are unit-length-ish (Q3.12 quantisation
introduces sub-ULP error but the GTE lighting path is
tolerant).
Trait Implementations§
impl<'a> Copy for Mesh<'a>
Auto Trait Implementations§
impl<'a> Freeze for Mesh<'a>
impl<'a> RefUnwindSafe for Mesh<'a>
impl<'a> Send for Mesh<'a>
impl<'a> Sync for Mesh<'a>
impl<'a> Unpin for Mesh<'a>
impl<'a> UnsafeUnpin for Mesh<'a>
impl<'a> UnwindSafe for Mesh<'a>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)