PMD (High-Speed Modeling Data)
Modeling data for libgs that holds ready drawing packets for fast processing.
| Extension | .PMD |
|---|---|
| ID | 0x00000042 |
Overview
The PMD format is used for modeling data supported by the extended graphics library (libgs). PMD has a narrower range of functions than TMD, but this smaller scope enables faster processing. PMD handles only triangular and rectangular polygons. The data contains the areas in which packets are created, and polygons that have the same attributes are handled as groups.1
File Structure
A PMD file consists of a table of 3D objects along with their PRIMITIVE and VERTEX descriptions. VERTEX groups exist only when vertices are shared, so VERT POINT is 0 for a file of independent vertices. The fields are as follows:1
| Field | Contents |
|---|---|
| ID | 32-bit word with the version of the PMD file. The current version is 0x00000042. |
| PRIM POINT | 32-bit offset of the PRIMITIVE Gp section from the start of the file |
| VERT POINT | 32-bit offset of the VERTEX Gp section from the start of the file. 0 for independent vertices. |
| OBJ TABLE | The array of objects |
| PRIMITIVE Gp | Groups of polygons that have the same attributes |
| VERTEX Gp | Array of vertex coordinates, present only for shared vertices |
Coordinate Values
Coordinate values in a PMD file follow the 3D coordinate space of the 3D graphics library. The positive X axis points right, the positive Y axis points down and the positive Z axis points into the depth, and each coordinate is a signed 16-bit integer from -32768 to +32767.2
Vertices are stored as floating point values in the RSD format, so conversion from RSD to PMD converts and scales them as needed. The scale used is recorded in the object structure. However, the current version of libgs ignores the scale value.2
OBJ TABLE
The OBJ TABLE holds the pointers to the primitive groups of each object, because a single object is composed of primitive groups. NOBJ gives the number of objects. Each object then has an NPTR field followed by its pointers from POINTER 0 to POINTER (nptr-1).2
| Field | Contents |
|---|---|
| NOBJ | Number of objects in the OBJ TABLE |
| NPTR | Number of pointers in one object |
| POINTER | Pointer to a primitive group |
PRIMITIVE Group
A PRIMITIVE Gp is a group of graphics packets for the primitives of an object, and a single packet contains one primitive. PMD primitives differ from the drawing primitives handled by libgpu. When libgs functions apply the perspective transformation, they are converted to drawing primitives.2
Each primitive group opens with one word that holds TYPE and NPACKET. The packet data follows:3
| Bits | Field | Contents |
|---|---|---|
| 0..15 | NPACKET | Number of packets |
| 16..31 | TYPE | Packet type |
The TYPE bits are laid out as follows:3
| Bit no. | When 0 | When 1 |
|---|---|---|
| 16 | Triangle | Quadrilateral |
| 17 | Flat | Gouraud |
| 18 | Texture-On | Texture-Off |
| 19 | Independent vertex | Shared vertex |
| 20 | Light source calculation Off | Light source calculation On |
| 21 | Back clip | No back clip |
| 22..31 | Reserved for system | Reserved for system |
The packet data structure changes with the value of TYPE. However, bits 20 and 21 have no effect on it. Each structure holds a set of two drawing primitives for a double buffer, and the contents of both must be initialized in advance.3
Packet Data
The packet data structure for each TYPE value is shown below. In each structure pkt[] is the corresponding drawing primitive packet. With independent vertices v1 to v4 are the vertex coordinates, and with shared vertices vp1 to vp4 are offsets from the start of the row of shared vertices.345
| TYPE | Primitive | Structure | Members |
|---|---|---|---|
| 00 | Triangle, flat, texture on, independent vertex | _poly_ft3 | POLY_FT3 pkt[2]; SVECTOR v1, v2, v3 |
| 01 | Quadrangle, flat, texture on, independent vertex | _poly_ft4 | POLY_FT4 pkt[2]; SVECTOR v1, v2, v3, v4 |
| 02 | Triangle, Gouraud, texture on, independent vertex | _poly_gt3 | POLY_GT3 pkt[2]; SVECTOR v1, v2, v3 |
| 03 | Quadrangle, Gouraud, texture on, independent vertex | _poly_gt4 | POLY_GT4 pkt[2]; SVECTOR v1, v2, v3, v4 |
| 04 | Triangle, flat, texture off, independent vertex | _poly_f3 | POLY_F3 pkt[2]; SVECTOR v1, v2, v3 |
| 05 | Quadrangle, flat, texture off, independent vertex | _poly_f4 | POLY_F4 pkt[2]; SVECTOR v1, v2, v3, v4 |
| 06 | Triangle, Gouraud, texture off, independent vertex | _poly_g3 | POLY_G3 pkt[2]; SVECTOR v1, v2, v3 |
| 07 | Quadrangle, Gouraud, texture off, independent vertex | _poly_g4 | POLY_G4 pkt[2]; SVECTOR v1, v2, v3, v4 |
| 08 | Triangle, flat, texture on, shared vertex | _poly_ft3c | POLY_FT3 pkt[2]; long vp1, vp2, vp3 |
| 09 | Quadrangle, flat, texture on, shared vertex | _poly_ft4c | POLY_FT4 pkt[2]; long vp1, vp2, vp3, vp4 |
| 0a | Triangle, Gouraud, texture on, shared vertex | _poly_gt3c | POLY_GT3 pkt[2]; long vp1, vp2, vp3 |
| 0b | Quadrangle, Gouraud, texture on, shared vertex | _poly_gt4c | POLY_GT4 pkt[2]; long vp1, vp2, vp3, vp4 |
| 0c | Triangle, flat, texture off, shared vertex | _poly_f3c | POLY_F3 pkt[2]; long vp1, vp2, vp3 |
| 0d | Quadrangle, flat, texture off, shared vertex | _poly_f4c | POLY_F4 pkt[2]; long vp1, vp2, vp3, vp4 |
| 0e | Triangle, Gouraud, texture off, shared vertex | _poly_g3c | POLY_G3 pkt[2]; long vp1, vp2, vp3 |
| 0f | Quadrangle, Gouraud, texture off, shared vertex | _poly_g4c | POLY_G4 pkt[2]; long vp1, vp2, vp3, vp4 |
VERTEX
The VERTEX group is an array of SVECTOR structures for shared vertices. VX, VY and VZ are the X, Y and Z coordinates of the vertex as 16-bit integers:5
| Word | Upper 16 bits | Lower 16 bits |
|---|---|---|
| 0 | VY | VX |
| 1 | VZ |
References
-
^ a b Sony Computer Entertainment Inc. File Formats. November 1998. Page 2-35, Figure 77.
-
^ a b c d Sony Computer Entertainment Inc. File Formats. November 1998. Page 2-36, Figure 78.
-
^ a b c d Sony Computer Entertainment Inc. File Formats. November 1998. Page 2-37, Figure 79 and Table 2-2.
-
^ Sony Computer Entertainment Inc. File Formats. November 1998. Page 2-38.
-
^ a b Sony Computer Entertainment Inc. File Formats. November 1998. Page 2-39, Figure 80.