coastline 0.0.4
Loading...
Searching...
No Matches
model.h File Reference

The models of the menus and splash screens: loading, animating and drawing them. More...

#include <PR/gbi.h>
#include <PR/ultratypes.h>
#include "common/ptr32.h"
#include "common/vecmath.h"
Include dependency graph for model.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ModelPart
 A part of a model: its display list, how it is drawn, and where. More...
struct  ModelKeyframe
 A key of an animation: its time, then the position of each vertex, then its normal. More...
struct  ModelAnimation
 An animation of vertices of a model, blended between its keys. More...
struct  ModelAnimationList
 The animations of a model. More...
struct  Model
 A model loaded from the cartridge, with its display lists and the animations of its parts. More...

Macros

#define MODEL_PART_LIGHT_RAMP   0x0003
 The bits of the flags of a part that pick its light from g_adwModelShadeColors.
#define MODEL_PART_TWO_SIDED   0x0004
 The flag of a part drawn from both sides.
#define MODEL_PART_TRANSLUCENT   0x0008
 The flag of a part drawn after the opaque ones.
#define MODEL_PART_FLAT   0x0080
 The flag of a part drawn with flat shading.
#define MODEL_PART_RAMPED   0x0400
 The flag of a part lit by its light ramp.
#define MODEL_ANIMATION_REPEAT   0x1
#define MODEL_ANIMATION_BOUNCE   0x2
#define MODEL_ANIMATION_REVERSING   0x4

Typedefs

typedef struct Model Model
 A model loaded from the cartridge, with its display lists and the animations of its parts.

Functions

void DrawModelList (Model *model, f32 m[4][4])
 Draw the parts of a model, the opaque ones first, under a matrix.
void DrawRotatedModel (Model *model, f32 x, f32 y, f32 z, f32 angle)
 Draw a model turned about its own axis by an angle in radians, at a 32nd of its size, stood up and placed at a position.
void DrawModelAt (Model *model, f32 x, f32 y, f32 z, f32 angle, f32 scale)
 Draw a model turned about its own axis by an angle in radians, scaled, stood up and placed at a position.
Model * DecompressModel (void *dst, u32 source)
 Load a model into a buffer and turn its offsets into pointers.
void RemapPointer (u32 *pointer, const void *lo, const void *hi, const void *base)
 Move a pointer that falls in a range of offsets to the same place from a base.
void FixupDisplayListPointers (Gfx *displayList, const void *lo, const void *hi, const void *base)
 Remap the addresses of the vertices and textures of a display list, up to its end.
void BounceModelAnimations (Model *model)
 Make every animation of a model repeat by turning back at its end.
void RelocateModelPointers (Model *model)
 Turn the offsets a model is loaded with into pointers: its animations, their vertices and keys, and the display lists of its parts.
void SetModelAnimationFlags (Model *model, s32 set, s32 clear)
 Set flags on every animation of a model, then clear others.
void LoopModelAnimations (Model *model)
 Make every animation of a model wrap to its start at its end, instead of turning back.
void AdvanceModelAnimations (Model *model)
 Advance every animation of a model by the time of the frame, blending its vertices between keyframes.
void PlayModelAnimationsOnce (Model *model)
 Make the animations of a model stop at their ends rather than repeat.
Model * DmaReadAndFixupTrackModel (void *dst, u32 romStart, u32 romEnd)
 Read a model from the cartridge and turn its offsets into pointers.

Variables

Ambient g_MenuAmbientLight
 The ambient light of the menus that draw models.
Light g_MenuDirectionalLight
 The directional light of the menus that draw models.
s32 g_dwDrawModelListNoZBuffer
 Whether DrawModelList() draws without the depth buffer.
u32 g_adwModelShadeColors [4]
 The light of the parts of a model lit by their light ramp, by its index.

Detailed Description

The models of the menus and splash screens: loading, animating and drawing them.

Macro Definition Documentation

◆ MODEL_PART_LIGHT_RAMP

#define MODEL_PART_LIGHT_RAMP   0x0003

The bits of the flags of a part that pick its light from g_adwModelShadeColors.

◆ MODEL_PART_TWO_SIDED

#define MODEL_PART_TWO_SIDED   0x0004

The flag of a part drawn from both sides.

◆ MODEL_PART_TRANSLUCENT

#define MODEL_PART_TRANSLUCENT   0x0008

The flag of a part drawn after the opaque ones.

◆ MODEL_PART_FLAT

#define MODEL_PART_FLAT   0x0080

The flag of a part drawn with flat shading.

◆ MODEL_PART_RAMPED

#define MODEL_PART_RAMPED   0x0400

The flag of a part lit by its light ramp.

◆ MODEL_ANIMATION_REPEAT

#define MODEL_ANIMATION_REPEAT   0x1

The animation starts again at its end.

◆ MODEL_ANIMATION_BOUNCE

#define MODEL_ANIMATION_BOUNCE   0x2

The animation turns back at its end.

◆ MODEL_ANIMATION_REVERSING

#define MODEL_ANIMATION_REVERSING   0x4

The animation runs backwards.

Typedef Documentation

◆ Model

typedef struct Model Model

A model loaded from the cartridge, with its display lists and the animations of its parts.

Its fields join this structure as they are reconstructed.

Function Documentation

◆ DrawModelList()

void DrawModelList ( Model * model,
f32 m[4][4] )

Draw the parts of a model, the opaque ones first, under a matrix.

Parameters
modelThe model.
mThe matrix of the model.
Ghidra address:
USA: 0x80209d70
Ghidra address:
Asia: 0x80209900
Ghidra address:
EUR: 0x80209b50
Ghidra address:
JPN: 0x80209750
Ghidra address:
BRD3D: 0x1002fb20
Ghidra address:
BRGlide: 0x1001d1b0

◆ DrawRotatedModel()

void DrawRotatedModel ( Model * model,
f32 x,
f32 y,
f32 z,
f32 angle )

Draw a model turned about its own axis by an angle in radians, at a 32nd of its size, stood up and placed at a position.

A mirrored track mirrors the turn and the scale.

Parameters
modelThe model to draw.
xThe X coordinate of the position.
yThe Y coordinate of the position.
zThe Z coordinate of the position.
angleThe turn in radians.
Ghidra address:
USA: 0x8020a524
Ghidra address:
Asia: 0x8020A0B4
Ghidra address:
EUR: 0x8020a304
Ghidra address:
JPN: 0x80209f04

◆ DrawModelAt()

void DrawModelAt ( Model * model,
f32 x,
f32 y,
f32 z,
f32 angle,
f32 scale )

Draw a model turned about its own axis by an angle in radians, scaled, stood up and placed at a position.

A mirrored track mirrors the turn and the scale.

Parameters
modelThe model to draw.
xThe X coordinate of the position.
yThe Y coordinate of the position.
zThe Z coordinate of the position.
angleThe turn in radians.
scaleThe scale.
Ghidra address:
USA: 0x8020a6a4
Ghidra address:
Asia: 0x8020A234
Ghidra address:
EUR: 0x8020a484
Ghidra address:
JPN: 0x8020a084

◆ DecompressModel()

Model * DecompressModel ( void * dst,
u32 source )

Load a model into a buffer and turn its offsets into pointers.

Parameters
dstThe destination buffer.
sourceThe archive path on Windows, or the cartridge offset on the console.
Returns
The loaded model.
Ghidra address:
USA: 0x8021de2c
Ghidra address:
Asia: 0x8021D97C
Ghidra address:
EUR: 0x8021f02c
Ghidra address:
JPN: 0x8021e8fc
Ghidra address:
BRD3D: 0x10036bd0
Ghidra address:
BRGlide: 0x10030270

◆ RemapPointer()

void RemapPointer ( u32 * pointer,
const void * lo,
const void * hi,
const void * base )

Move a pointer that falls in a range of offsets to the same place from a base.

Parameters
pointerThe pointer, as the word it is stored in.
loThe start of the range.
hiThe end of the range.
baseWhere the start of the range moves to.
Ghidra address:
USA: 0x8021d070
Ghidra address:
Asia: 0x8021CBC0
Ghidra address:
EUR: 0x8021e270
Ghidra address:
JPN: 0x8021db40
Ghidra address:
BRD3D: 0x10035060
Ghidra address:
BRGlide: 0x1002e711

◆ FixupDisplayListPointers()

void FixupDisplayListPointers ( Gfx * displayList,
const void * lo,
const void * hi,
const void * base )

Remap the addresses of the vertices and textures of a display list, up to its end.

The display lists it calls are not followed.

Parameters
displayListThe display list, or NULL.
loThe start of the range of the addresses.
hiThe end of the range.
baseWhere the start of the range moves to.
Ghidra address:
USA: 0x8021d098
Ghidra address:
Asia: 0x8021CBE8
Ghidra address:
EUR: 0x8021e298
Ghidra address:
JPN: 0x8021db68
Ghidra address:
BRD3D: 0x10035089
Ghidra address:
BRGlide: 0x1002e73a

◆ BounceModelAnimations()

void BounceModelAnimations ( Model * model)

Make every animation of a model repeat by turning back at its end.

Parameters
modelThe model.
Ghidra address:
USA: 0x8021d828
Ghidra address:
Asia: 0x8021D378
Ghidra address:
EUR: 0x8021ea28
Ghidra address:
JPN: 0x8021e2f8
Ghidra address:
BRD3D: 0x10035625
Ghidra address:
BRGlide: 0x1002ecd6

◆ RelocateModelPointers()

void RelocateModelPointers ( Model * model)

Turn the offsets a model is loaded with into pointers: its animations, their vertices and keys, and the display lists of its parts.

Parameters
modelThe model.
Ghidra address:
USA: 0x8021dc34
Ghidra address:
Asia: 0x8021D784
Ghidra address:
EUR: 0x8021ee34
Ghidra address:
JPN: 0x8021e704
Ghidra address:
BRD3D: 0x10036c00
Ghidra address:
BRGlide: 0x100302a0

◆ SetModelAnimationFlags()

void SetModelAnimationFlags ( Model * model,
s32 set,
s32 clear )

Set flags on every animation of a model, then clear others.

Parameters
modelThe model.
setThe flags to set.
clearThe flags to clear.
Ghidra address:
USA: 0x8021d6dc
Ghidra address:
Asia: 0x8021D22C
Ghidra address:
EUR: 0x8021e8dc
Ghidra address:
JPN: 0x8021e1ac
Ghidra address:
BRD3D: 0x10035585
Ghidra address:
BRGlide: 0x1002ec36

◆ LoopModelAnimations()

void LoopModelAnimations ( Model * model)

Make every animation of a model wrap to its start at its end, instead of turning back.

Parameters
modelThe model.
Ghidra address:
USA: 0x8021d804
Ghidra address:
Asia: 0x8021D354
Ghidra address:
EUR: 0x8021ea04
Ghidra address:
JPN: 0x8021e2d4
Ghidra address:
BRD3D: 0x10035610
Ghidra address:
BRGlide: 0x1002ecc1

◆ AdvanceModelAnimations()

void AdvanceModelAnimations ( Model * model)

Advance every animation of a model by the time of the frame, blending its vertices between keyframes.

Parameters
modelThe model.
Ghidra address:
USA: 0x8021d84c
Ghidra address:
Asia: 0x8021D39C
Ghidra address:
EUR: 0x8021ea4c
Ghidra address:
JPN: 0x8021e31c
Ghidra address:
BRD3D: 0x1003563a
Ghidra address:
BRGlide: 0x1002eceb

◆ PlayModelAnimationsOnce()

void PlayModelAnimationsOnce ( Model * model)

Make the animations of a model stop at their ends rather than repeat.

Parameters
modelThe model.
Ghidra address:
USA: 0x8021d7e0
Ghidra address:
Asia: 0x8021D330
Ghidra address:
EUR: 0x8021e9e0
Ghidra address:
JPN: 0x8021e2b0
Ghidra address:
BRD3D: 0x100355fb
Ghidra address:
BRGlide: 0x1002ecac

◆ DmaReadAndFixupTrackModel()

Model * DmaReadAndFixupTrackModel ( void * dst,
u32 romStart,
u32 romEnd )

Read a model from the cartridge and turn its offsets into pointers.

Parameters
dstThe memory to read it into.
romStartThe cartridge offset of the model.
romEndThe cartridge offset of its end.
Returns
The model, at dst.
Ghidra address:
USA: 0x8021ddfc
Ghidra address:
Asia: 0x8021D94C
Ghidra address:
EUR: 0x8021effc
Ghidra address:
JPN: 0x8021e8cc

Variable Documentation

◆ g_MenuAmbientLight

Ambient g_MenuAmbientLight
extern

The ambient light of the menus that draw models.

Ghidra address:
USA: 0x80271f88
Ghidra address:
Asia: 0x80271AD8
Ghidra address:
EUR: 0x80273f68
Ghidra address:
JPN: 0x80273a28

◆ g_MenuDirectionalLight

Light g_MenuDirectionalLight
extern

The directional light of the menus that draw models.

Ghidra address:
USA: 0x80271f90
Ghidra address:
Asia: 0x80271AE0
Ghidra address:
EUR: 0x80273f70
Ghidra address:
JPN: 0x80273a30

◆ g_dwDrawModelListNoZBuffer

s32 g_dwDrawModelListNoZBuffer
extern

Whether DrawModelList() draws without the depth buffer.

Ghidra address:
USA: 0x80271d98
Ghidra address:
Asia: 0x802718E8
Ghidra address:
EUR: 0x80273d78
Ghidra address:
JPN: 0x80273838
Ghidra address:
BRD3D: 0x10690a1c
Ghidra address:
BRGlide: 0x105ccbc8

◆ g_adwModelShadeColors

u32 g_adwModelShadeColors[4]
extern

The light of the parts of a model lit by their light ramp, by its index.

Ghidra address:
USA: 0x80271d9c
Ghidra address:
Asia: 0x802718EC
Ghidra address:
EUR: 0x80273d7c
Ghidra address:
JPN: 0x8027383c
Ghidra address:
BRD3D: 0x100aa5d0
Ghidra address:
BRGlide: 0x100a9930