Tools for preprocessing data files from Quake to make them suitable for use on PS1 hardware
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

60 lines
1.9 KiB

#ifndef __PS1BSP_H__
#define __PS1BSP_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
unsigned char w, h; // These may be necessary for scaling UVs, especially since we use a mix of mip0 and mip1 textures
int tpage; // Texture page in PS1 VRAM (precalculated when generating the texture atlas)
short uoffs, voffs; // Texture coordinate offset within the texture page
unsigned short nextframe; // If non-zero, the texture is animated and this points to the next texture in the sequence
} ps1bsp_texture_t;
// This matches the SVECTOR data type, using the extra padding to store vertex color data.
// The full range and precision required cannot be stored in just shorts, so we make use of a floating origin stored in the BSP leafs.
// With this the higher-order bits of each vertex position are calculated into the model-view matrix, giving good precision for polygons near the camera.
typedef struct
{
short x;
short y;
short z;
unsigned char baseLight, finalLight; // Used for gouraud shading based on static lightmap data
} ps1bsp_vertex_t;
// Instead of edges as in the original BSP format, we store triangles for easy consumption by the PS1
typedef struct
{
unsigned short vertex0;
unsigned short vertex1;
unsigned short vertex2;
} ps1bsp_triangle_t;
// Pre-parsed and encoded entity data (this runs the risk of becoming too bloated)
typedef struct
{
unsigned short classtype; // Hash of the original classname
short angle[3]; // Can store both mangle (all axes) and just angle (Z-axis rotation only)
int origin[3]; // In 12-bit fixed point coordinates
unsigned int spawnflags;
unsigned short message_id; // Index into a pool of pre-defined messages
} ps1bsp_entity_t;
typedef struct
{
unsigned short length;
char message[];
} ps1bsp_message_t;
typedef struct
{
// TODO: add floating origin position, so face vertices can be moved relative to the camera position
} ps1bsp_leaf_t;
#ifdef __cplusplus
}
#endif
#endif // __PS1BSP_H__