Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
model_mesh.c File Reference

The first object of FIGHTSTG.PRO, the models and their meshes. More...

#include "battle/battle_mode.h"
#include "engine/gte.h"
Include dependency graph for model_mesh.c:

Go to the source code of this file.

Functions

void FIGHTSTG_blendBone (Model *model, ModelBone *bone)
 Blends a bone's position, rotation and scale from the saved pose (FIGHTSTG_saveBlendPose) towards their first keys at or after the model's frame, by its blend; when either scale has a 0, the key's is taken as it is.
 
void FIGHTSTG_poseBone (Model *model, ModelBone *bone, s32 frame)
 Sets a bone's position, rotation and scale to their keys at FRAME, interpolated between the keys around it.
 
void FIGHTSTG_poseBones (Model *model, Mesh **children)
 Moves the root bone by the model's move along its rotation, then poses (FIGHTSTG_poseBone) or blends (FIGHTSTG_blendBone) each other bone.
 
void FIGHTSTG_saveBlendPose (Model *model)
 Saves each bone's pose as the one a blend starts from.
 
void FIGHTSTG_setMotion (Model *model, s32 motion, s32 restart)
 Model.setMotion: lays out the motion's keyframes.
 
void FIGHTSTG_stepMotion (Model *model)
 Steps a model's motion by the frames gone by, blending into a new pose where a keyframe has 0x8000, and starts the idle motion when it ends.
 
void FIGHTSTG_updateModel (Model *model, Mesh **children)
 The model's task: loads its textures and makes its meshes and face, then each frame follows its control's motion, steps and poses it, places the root at the control's position, builds each bone's matrices (a bone scaled to 48 or less is hidden) and queues its meshes on the control's layers; frees the bones when killed.
 
void FIGHTSTG_setModelColor (Model *model, s32 mode, CVECTOR *color)
 Model.setColor: sets the color mode, and the color unless COLOR is NULL, of the meshes of each bone but the root (once for each of the control's enabled layers)
 
void FIGHTSTG_setBoneNoBoundsCheck (Model *model, s32 bone, s32 value)
 Model.setBoneNoBoundsCheck: sets bone's Mesh noBoundsCheck when either of the control's layers is enabled and bone isn't 0.
 
s32 FIGHTSTG_isMotionDone (Model *model)
 Model.isMotionDone.
 
Model * FIGHTSTG_createModel (s32 file, s32 motionFile, Vec2 texPos, ModelControl *control, s32 hasIdle)
 Creates a model (registered as BATTLE_TASK_MODEL) from the bone list in FILE: each bone's parent, mesh file and keys file, with the file's high half; HASIDLE makes its motions go back to its idle motion.
 
Model * FIGHTSTG_createIdlingModel (s32 file, s32 motionFile, Vec2 texPos, ModelControl *control)
 A model whose motions go back to its idle motion (FIGHTSTG_createModel): the fighters'.
 
Model * FIGHTSTG_createPlainModel (s32 file, s32 motionFile, Vec2 texPos, ModelControl *control)
 A model whose motions just end (FIGHTSTG_createModel)
 
void FIGHTSTG_lightMesh (Mesh *mesh)
 The colors of a Mesh's normals under the lights, through its matrix.
 
void FIGHTSTG_projectMesh (Mesh *mesh, Layer *layer)
 The screen positions of a Mesh's vertices and their depths in the layer's ordering table.
 
void FIGHTSTG_addMeshPolyGT (MeshDrawState *state)
 Adds the polygon in state as a gouraud-shaded textured triangle or quad; the colors, points and UVs are copied a word or a halfword at a time.
 
void FIGHTSTG_addMeshPolyFT (MeshDrawState *state)
 The same as a flat-shaded textured triangle or quad.
 
s32 FIGHTSTG_isMeshOnScreen (Mesh *mesh, Layer *layer)
 Whether a Mesh may be on screen: the screen positions of the 9 points of its bounds against the layer's clip, 64 pixels bigger each way; noBoundsCheck skips the check.
 
static void setMeshTexture (MeshDrawState *state)
 Sets the texture page, the CLUT and the UV offset from a command's bytes.
 
static void drawMeshPolygons (MeshDrawState *state)
 Draws a run of polygons: adds each one that faces the camera to the ordering table, then steps past its indices and UVs.
 
void FIGHTSTG_drawMesh (void *arg, Layer *layer)
 A layer callback that draws a Mesh: walks its command bytes (see MeshDrawState), setting its texture (setMeshTexture), and adds each polygon that faces the camera to the layer's ordering table (drawMeshPolygons).
 
static u_long linkTag (u_long tag, u_long addr)
 A primitive tag's word with its address replaced: the top byte of tag and the low 24 bits of addr.
 
void FIGHTSTG_drawMeshWireframe (Mesh *mesh, Layer *layer)
 Draws a Mesh as wireframe: each polygon of its command runs as a green LINE_F4 through its screen points, with a LINE_F2 to close a quad.
 
void FIGHTSTG_queueMeshDraw (Mesh *mesh, s32 layerId, MATRIX *matrix)
 Mesh.draw: has the layer draw the Mesh (FIGHTSTG_drawMesh) with MATRIX.
 
void FIGHTSTG_queueMeshWireframe (Mesh *mesh, s32 layerId, MATRIX *matrix)
 Mesh.drawWireframe: has the layer draw the Mesh as wireframe (FIGHTSTG_drawMeshWireframe) with MATRIX.
 
void FIGHTSTG_updateMesh (Mesh *mesh)
 The Mesh's task: frees its screen positions, depths and colors when killed.
 
Mesh * FIGHTSTG_createMesh (void *archive, Vec2 texPos)
 Creates a Mesh from an archive: its vertices (entry 0), normals (1), commands (2) and bounds (5)
 

Variables

s32 FIGHTSTG_unused0 = 0
 the variables that end the file: zeros after camera_task.c's data, which the objects after this one read; the three unused words are read and written by nothing in either version
 
s32 FIGHTSTG_partnerIdleMotion = 0
 the partner's idle motion while stage 0x1D is up
 
s32 FIGHTSTG_unused1 = 0
 
CameraView FIGHTSTG_fighterView = { 0 }
 the view FIGHTSTG_getFighterView makes
 
s32 FIGHTSTG_unused2 = 0
 
RECT FIGHTSTG_fighterCameraRect = { 0 }
 FIGHTSTG_updatePartnerView's layer.
 
DR_MOVE FIGHTSTG_cursorBarMoves [4] = { { 0 } }
 FIGHTSTG_drawCursorBar draws its bar with them.
 
u_long FIGHTSTG_cursorBarOt [2] = { 0 }
 and their ordering table
 
BattleEvent FIGHTSTG_newEvent = { 0 }
 what FIGHTSTG_pushEvent is given
 

Detailed Description

The first object of FIGHTSTG.PRO, the models and their meshes.

FIGHTSTG.PRO was seven objects: each one's jump tables are aligned to 8 from the start of its own rodata, and they are 4 bytes past a multiple of 8 from 0x80082464 (USA) to 0x80082480, from 0x800825B4 to 0x800825D0 and from 0x8008267C on. Where each object's code starts is only known to be between the function with the last jump table of the object before and the one with its first; the last object (camera_task.c) differs between the versions. The second object is stage.c; the third to the sixth are cut into modules, in their link order (entrance.c to fader.c, lights.c and face.c, battle_script.c and first_tech.c, item.c to interp.c), each with its own rodata and data; a cut is only where each jump table keeps its place. Each object's or module's data is in its own file, in address order; the zeros that end the file, after the last object's data, are here.

Definition in file model_mesh.c.

Function Documentation

◆ FIGHTSTG_blendBone()

void FIGHTSTG_blendBone ( Model *  model,
ModelBone *  bone 
)

Blends a bone's position, rotation and scale from the saved pose (FIGHTSTG_saveBlendPose) towards their first keys at or after the model's frame, by its blend; when either scale has a 0, the key's is taken as it is.

Definition at line 23 of file model_mesh.c.

Referenced by FIGHTSTG_poseBones().

Here is the caller graph for this function:

◆ FIGHTSTG_poseBone()

void FIGHTSTG_poseBone ( Model *  model,
ModelBone *  bone,
s32  frame 
)

Sets a bone's position, rotation and scale to their keys at FRAME, interpolated between the keys around it.

Definition at line 83 of file model_mesh.c.

Referenced by FIGHTSTG_poseBones(), and FIGHTSTG_stepMotion().

Here is the caller graph for this function:

◆ FIGHTSTG_poseBones()

void FIGHTSTG_poseBones ( Model *  model,
Mesh **  children 
)

Moves the root bone by the model's move along its rotation, then poses (FIGHTSTG_poseBone) or blends (FIGHTSTG_blendBone) each other bone.

Definition at line 143 of file model_mesh.c.

Referenced by FIGHTSTG_updateModel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_saveBlendPose()

void FIGHTSTG_saveBlendPose ( Model *  model)

Saves each bone's pose as the one a blend starts from.

Definition at line 173 of file model_mesh.c.

Referenced by FIGHTSTG_stepMotion().

Here is the caller graph for this function:

◆ FIGHTSTG_setMotion()

void FIGHTSTG_setMotion ( Model *  model,
s32  motion,
s32  restart 
)

Model.setMotion: lays out the motion's keyframes.

Definition at line 185 of file model_mesh.c.

Referenced by FIGHTSTG_createModel(), FIGHTSTG_stepMotion(), and FIGHTSTG_updateModel().

Here is the caller graph for this function:

◆ FIGHTSTG_stepMotion()

void FIGHTSTG_stepMotion ( Model *  model)

Steps a model's motion by the frames gone by, blending into a new pose where a keyframe has 0x8000, and starts the idle motion when it ends.

Definition at line 242 of file model_mesh.c.

Referenced by FIGHTSTG_updateModel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_updateModel()

void FIGHTSTG_updateModel ( Model *  model,
Mesh **  children 
)

The model's task: loads its textures and makes its meshes and face, then each frame follows its control's motion, steps and poses it, places the root at the control's position, builds each bone's matrices (a bone scaled to 48 or less is hidden) and queues its meshes on the control's layers; frees the bones when killed.

Definition at line 296 of file model_mesh.c.

Referenced by FIGHTSTG_createModel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_setModelColor()

void FIGHTSTG_setModelColor ( Model *  model,
s32  mode,
CVECTOR *  color 
)

Model.setColor: sets the color mode, and the color unless COLOR is NULL, of the meshes of each bone but the root (once for each of the control's enabled layers)

Definition at line 410 of file model_mesh.c.

Referenced by FIGHTSTG_createModel().

Here is the caller graph for this function:

◆ FIGHTSTG_setBoneNoBoundsCheck()

void FIGHTSTG_setBoneNoBoundsCheck ( Model *  model,
s32  bone,
s32  value 
)

Model.setBoneNoBoundsCheck: sets bone's Mesh noBoundsCheck when either of the control's layers is enabled and bone isn't 0.

The match depends on the pointer to the bone's slot, which children[bone + 1] computes with the addu's operands the other way round.

Definition at line 433 of file model_mesh.c.

Referenced by FIGHTSTG_createModel().

Here is the caller graph for this function:

◆ FIGHTSTG_isMotionDone()

s32 FIGHTSTG_isMotionDone ( Model *  model)

Model.isMotionDone.

Definition at line 445 of file model_mesh.c.

Referenced by FIGHTSTG_createModel().

Here is the caller graph for this function:

◆ FIGHTSTG_createModel()

Model * FIGHTSTG_createModel ( s32  file,
s32  motionFile,
Vec2  texPos,
ModelControl *  control,
s32  hasIdle 
)

Creates a model (registered as BATTLE_TASK_MODEL) from the bone list in FILE: each bone's parent, mesh file and keys file, with the file's high half; HASIDLE makes its motions go back to its idle motion.

< a model (FIGHTSTG_updateModel)

Definition at line 452 of file model_mesh.c.

Referenced by FIGHTSTG_createIdlingModel(), and FIGHTSTG_createPlainModel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_createIdlingModel()

Model * FIGHTSTG_createIdlingModel ( s32  file,
s32  motionFile,
Vec2  texPos,
ModelControl *  control 
)

A model whose motions go back to its idle motion (FIGHTSTG_createModel): the fighters'.

Definition at line 497 of file model_mesh.c.

Referenced by FIGHTSTG_addFighterModel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_createPlainModel()

Model * FIGHTSTG_createPlainModel ( s32  file,
s32  motionFile,
Vec2  texPos,
ModelControl *  control 
)

A model whose motions just end (FIGHTSTG_createModel)

Definition at line 502 of file model_mesh.c.

Referenced by FIGHTSTG_updateEffectModel(), and FIGHTSTG_updateStage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_lightMesh()

void FIGHTSTG_lightMesh ( Mesh *  mesh)

The colors of a Mesh's normals under the lights, through its matrix.

Definition at line 507 of file model_mesh.c.

Referenced by FIGHTSTG_drawMesh().

Here is the caller graph for this function:

◆ FIGHTSTG_projectMesh()

void FIGHTSTG_projectMesh ( Mesh *  mesh,
Layer *  layer 
)

The screen positions of a Mesh's vertices and their depths in the layer's ordering table.

Definition at line 541 of file model_mesh.c.

Referenced by FIGHTSTG_drawMesh(), and FIGHTSTG_drawMeshWireframe().

Here is the caller graph for this function:

◆ FIGHTSTG_addMeshPolyGT()

void FIGHTSTG_addMeshPolyGT ( MeshDrawState *  state)

Adds the polygon in state as a gouraud-shaded textured triangle or quad; the colors, points and UVs are copied a word or a halfword at a time.

Definition at line 580 of file model_mesh.c.

Referenced by drawMeshPolygons().

Here is the caller graph for this function:

◆ FIGHTSTG_addMeshPolyFT()

void FIGHTSTG_addMeshPolyFT ( MeshDrawState *  state)

The same as a flat-shaded textured triangle or quad.

Definition at line 615 of file model_mesh.c.

Referenced by drawMeshPolygons().

Here is the caller graph for this function:

◆ FIGHTSTG_isMeshOnScreen()

s32 FIGHTSTG_isMeshOnScreen ( Mesh *  mesh,
Layer *  layer 
)

Whether a Mesh may be on screen: the screen positions of the 9 points of its bounds against the layer's clip, 64 pixels bigger each way; noBoundsCheck skips the check.

The match depends on the + 128s kept in w and h, which gcc otherwise folds into the - 64s.

Definition at line 648 of file model_mesh.c.

Referenced by FIGHTSTG_drawMesh(), and FIGHTSTG_drawMeshWireframe().

Here is the caller graph for this function:

◆ setMeshTexture()

static void setMeshTexture ( MeshDrawState *  state)
inlinestatic

Sets the texture page, the CLUT and the UV offset from a command's bytes.

Definition at line 695 of file model_mesh.c.

Referenced by FIGHTSTG_drawMesh().

Here is the caller graph for this function:

◆ drawMeshPolygons()

static void drawMeshPolygons ( MeshDrawState *  state)
inlinestatic

Draws a run of polygons: adds each one that faces the camera to the ordering table, then steps past its indices and UVs.

Definition at line 714 of file model_mesh.c.

Referenced by FIGHTSTG_drawMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_drawMesh()

void FIGHTSTG_drawMesh ( void *  arg,
Layer *  layer 
)

A layer callback that draws a Mesh: walks its command bytes (see MeshDrawState), setting its texture (setMeshTexture), and adds each polygon that faces the camera to the layer's ordering table (drawMeshPolygons).

The match depends on the mesh coming in as a void *, on the ?: for q and on each polygon's checks and drawing being a do-while (0) with breaks (both in drawMeshPolygons).

Definition at line 815 of file model_mesh.c.

Referenced by FIGHTSTG_queueMeshDraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linkTag()

static u_long linkTag ( u_long  tag,
u_long  addr 
)
inlinestatic

A primitive tag's word with its address replaced: the top byte of tag and the low 24 bits of addr.

The match depends on word being set twice: as one expression, sched1 moves the tag's mask after the address's, which swaps their registers.

Definition at line 900 of file model_mesh.c.

Referenced by FIGHTSTG_drawMeshWireframe().

Here is the caller graph for this function:

◆ FIGHTSTG_drawMeshWireframe()

void FIGHTSTG_drawMeshWireframe ( Mesh *  mesh,
Layer *  layer 
)

Draws a Mesh as wireframe: each polygon of its command runs as a green LINE_F4 through its screen points, with a LINE_F2 to close a quad.

Each addPrim is written out with linkTag.

Definition at line 909 of file model_mesh.c.

Referenced by FIGHTSTG_queueMeshWireframe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_queueMeshDraw()

void FIGHTSTG_queueMeshDraw ( Mesh *  mesh,
s32  layerId,
MATRIX *  matrix 
)

Mesh.draw: has the layer draw the Mesh (FIGHTSTG_drawMesh) with MATRIX.

Definition at line 1022 of file model_mesh.c.

Referenced by FIGHTSTG_createMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_queueMeshWireframe()

void FIGHTSTG_queueMeshWireframe ( Mesh *  mesh,
s32  layerId,
MATRIX *  matrix 
)

Mesh.drawWireframe: has the layer draw the Mesh as wireframe (FIGHTSTG_drawMeshWireframe) with MATRIX.

Definition at line 1031 of file model_mesh.c.

Referenced by FIGHTSTG_createMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FIGHTSTG_updateMesh()

void FIGHTSTG_updateMesh ( Mesh *  mesh)

The Mesh's task: frees its screen positions, depths and colors when killed.

Definition at line 1039 of file model_mesh.c.

Referenced by FIGHTSTG_createMesh().

Here is the caller graph for this function:

◆ FIGHTSTG_createMesh()

Mesh * FIGHTSTG_createMesh ( void *  archive,
Vec2  texPos 
)

Creates a Mesh from an archive: its vertices (entry 0), normals (1), commands (2) and bounds (5)

Definition at line 1061 of file model_mesh.c.

Referenced by FIGHTSTG_updateModel().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ FIGHTSTG_unused0

s32 FIGHTSTG_unused0 = 0

the variables that end the file: zeros after camera_task.c's data, which the objects after this one read; the three unused words are read and written by nothing in either version

Definition at line 1078 of file model_mesh.c.

◆ FIGHTSTG_partnerIdleMotion

s32 FIGHTSTG_partnerIdleMotion = 0

the partner's idle motion while stage 0x1D is up

Definition at line 1079 of file model_mesh.c.

Referenced by FIGHTSTG_runScriptStage().

◆ FIGHTSTG_unused1

s32 FIGHTSTG_unused1 = 0

Definition at line 1080 of file model_mesh.c.

◆ FIGHTSTG_fighterView

CameraView FIGHTSTG_fighterView = { 0 }

the view FIGHTSTG_getFighterView makes

Definition at line 1081 of file model_mesh.c.

Referenced by FIGHTSTG_getEnemyView(), FIGHTSTG_getFighterView(), FIGHTSTG_runScriptCamera(), FIGHTSTG_updateCameraTurn(), startChange(), and swapInNewDigimon().

◆ FIGHTSTG_unused2

s32 FIGHTSTG_unused2 = 0

Definition at line 1082 of file model_mesh.c.

◆ FIGHTSTG_fighterCameraRect

RECT FIGHTSTG_fighterCameraRect = { 0 }

FIGHTSTG_updatePartnerView's layer.

Shared between the overlay's objects.

Definition at line 1083 of file model_mesh.c.

Referenced by FIGHTSTG_updatePartnerView().

◆ FIGHTSTG_cursorBarMoves

DR_MOVE FIGHTSTG_cursorBarMoves[4] = { { 0 } }

FIGHTSTG_drawCursorBar draws its bar with them.

FIGHTSTG_drawCursorBar's bar.

Definition at line 1084 of file model_mesh.c.

Referenced by FIGHTSTG_drawCursorBar().

◆ FIGHTSTG_cursorBarOt

u_long FIGHTSTG_cursorBarOt[2] = { 0 }

and their ordering table

their OT

Definition at line 1085 of file model_mesh.c.

Referenced by FIGHTSTG_drawCursorBar().

◆ FIGHTSTG_newEvent