Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Crate psx_asset

Crate psx_asset 

Source
Expand description

Runtime parsers for PSoXide cooked-asset blobs.

Pairs with editor/crates/psxed, the host-side tool that produces these files. Format structs live in psxed-format (shared by both sides so drift is impossible).

Usage pattern:

ⓘ
// At compile time, embed the cooked blob into the MIPS binary.
static TEAPOT: &[u8] = include_bytes!("assets/teapot.psxm");

// At runtime, parse into a typed view. Zero-copy -- the view
// just borrows slices into the original byte stream.
let mesh = psx_asset::Mesh::from_bytes(TEAPOT).expect("cooked mesh");
for tri_idx in 0..mesh.face_count() {
    let (ia, ib, ic) = mesh.face(tri_idx);
    let v0 = mesh.vertex(ia);
    let v1 = mesh.vertex(ib);
    let v2 = mesh.vertex(ic);
    let (r, g, b) = mesh.face_color(tri_idx).unwrap_or((128, 128, 128));
    // project + draw …
}

Design:

  • Zero-copy: Mesh::from_bytes borrows into the caller’s byte slice. No allocation, no memcpy; the static blob stays where it was embedded.
  • no_std-clean: all parsing is manual LE decode, no std::io.
  • Bounds-checked: every accessor validates its index against the counts in the header. Malformed blobs produce None rather than panics at integer level, so consumers see errors at load time, not in the render loop.

Modules§

hma1
HMA1: per-bone local quaternion animation tracks (the HMD8 pose-palette replacement cooked by psx-anim-cook).
hmd8
HMD8: a merged model container carrying mesh, bone ranges and every clip’s composed bone palettes in one blob.
world_topology
Shared topology helpers for cooked world quads and wall shapes.

Structs§

Animation
A parsed rigid-skeletal animation backed by slices into the caller’s cooked .psxanim blob.
AnimationPoseSample
Reusable frame-pair sampler for one animation phase.
Audio
A parsed .psau SPU audio sample backed by the caller’s cooked blob.
GteJointPose
Compact joint pose that can feed GTE vector inputs directly.
JointPose
Decoded joint pose matrix.
Mesh
A parsed 3D mesh backed by slices into the caller’s cooked blob.
Model
A parsed textured 3D model backed by slices into the caller’s cooked .psxmdl blob.
ModelFace
Decoded textured model face.
ModelFaceCorner
One textured triangle corner in a cooked model face.
ModelJoint
Decoded model joint record.
ModelMaterial
Decoded model material record.
ModelPart
Decoded rigid part record.
ModelPoseBlend
Crossfade source: a second animation sample blended toward a primary pose.
ModelVertex
Decoded textured model vertex. Word alignment lets the GTE projection path load XY in one MIPS load. These are decoded records, not a view into the cooked byte format.
Texture
A parsed 2D texture backed by slices into the caller’s cooked blob. Pixel data is already packed into the halfword-nibble layout the PSX GPU reads; the CLUT (if any) is a slice of RGB555 halfwords.
World
A parsed .psxw grid-world backed by slices into the cooked blob.
WorldQuadUvs
Four PS1 UV coordinates for one world quad.
WorldSector
One decoded world sector record.
WorldSectorCollisionProbe
Minimal sector data for camera/wall collision probes.
WorldSectorFloorCollision
Minimal decoded floor triangle used by character and camera collision.
WorldSurfaceLight
Four RGB vertex colours for one world quad.
WorldWall
One decoded world wall record.

Enums§

ParseError
Errors Mesh::from_bytes can return for a malformed blob.

Constants§

NO_JOINT8
Sentinel value for ModelVertex::joint1 meaning “no secondary blend bone”. Re-exported from psxed_format::model so runtime code does not need to depend on the editor crate.
WORLD_SPLIT_NORTH_EAST_SOUTH_WEST
World split id from north-east to south-west.
WORLD_SPLIT_NORTH_WEST_SOUTH_EAST
World split id from north-west to south-east.
WORLD_WALL_SHAPE_DROP_BOTTOM_LEFT
World-wall shape with the bottom-left corner removed.
WORLD_WALL_SHAPE_DROP_BOTTOM_RIGHT
World-wall shape with the bottom-right corner removed.
WORLD_WALL_SHAPE_DROP_TOP_LEFT
World-wall shape with the top-left corner removed.
WORLD_WALL_SHAPE_DROP_TOP_RIGHT
World-wall shape with the top-right corner removed.
WORLD_WALL_SHAPE_QUAD
Full four-corner world-wall shape.