Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
model.h File Reference

Go to the source code of this file.

Data Structures

union  ModelNodePropertyData
 
struct  ModelBoundingBox
 
struct  ModelNodeProperty
 
struct  ModelGroupData
 
struct  ModelDisplayData
 
struct  ModelNode
 
struct  Model
 
struct  ModelTransformGroup
 
struct  ModelIDList
 
struct  ModelLocalVertexCopy
 
struct  ModelTreeInfo
 
struct  TextureHandle
 
struct  ModelBlueprint
 
struct  ShapeFileHeader
 
struct  ShapeFile
 

Macros

#define SHAPE_SIZE_LIMIT   0x8000
 

Typedefs

typedef ModelModelList[256]
 
typedef ModelTransformGroupModelTransformGroupList[4]
 
typedef ModelLocalVertexCopyModelLocalVertexCopyList[16]
 
typedef void(* ModelCustomGfxBuilderFunc) (s32 index)
 
typedef Gfx * ModelCustomGfxList[32]
 
typedef ModelCustomGfxBuilderFunc ModelCustomGfxBuilderList[32]
 
typedef ModelTreeInfo ModelTreeInfoList[0x200]
 

Enumerations

enum  ModelPropertyKeys {
  MODEL_PROP_KEY_RENDER_MODE = 0x5C , MODEL_PROP_KEY_CAMERA_DATA = 0x5D , MODEL_PROP_KEY_TEXTURE_NAME = 0x5E , MODEL_PROP_KEY_SPECIAL = 0x5F ,
  MODEL_PROP_KEY_GROUP_INFO = 0x60 , MODEL_PROP_KEY_BOUNDING_BOX = 0x61 , MODEL_PROP_KEY_62 = 0x62
}
 
enum  ShapeTypes { SHAPE_TYPE_MODEL = 2 , SHAPE_TYPE_GROUP = 5 , SHAPE_TYPE_ROOT = 7 , SHAPE_TYPE_SPECIAL_GROUP = 10 }
 
enum  GroupTypes { GROUP_TYPE_0 = 0 , GROUP_TYPE_1 = 1 }
 
enum  ExtraTileTypes {
  EXTRA_TILE_NONE = 0 , EXTRA_TILE_MIPMAPS = 1 , EXTRA_TILE_AUX_SAME_AS_MAIN = 2 , EXTRA_TILE_AUX_INDEPENDENT = 3 ,
  EXTRA_TILE_4 = 4
}
 

Functions

void mdl_set_depth_tint_params (u8 primR, u8 primG, u8 primB, u8 primA, u8 fogR, u8 fogG, u8 fogB, s32 fogStart, s32 fogEnd)
 
void mdl_set_remap_tint_params (u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB)
 
void mdl_get_remap_tint_params (u8 *primR, u8 *primG, u8 *primB, u8 *envR, u8 *envG, u8 *envB)
 
void init_model_data (void)
 
void update_model_animator (s32)
 
void update_model_animator_with_transform (s32 animatorID, Mtx *mtx)
 
void set_mdl_custom_gfx_set (Model *, s32, u32)
 
ModelNodePropertyget_model_property (ModelNode *node, ModelPropertyKeys key)
 
void load_texture_variants (u32 romOffset, s32 textureID, s32 baseOffset, s32 size)
 
s32 step_model_animator (ModelAnimator *animator)
 
AnimatorNodeget_animator_node_for_tree_index (ModelAnimator *animator, s32 treeIndex)
 
AnimatorNodeget_animator_node_with_id (ModelAnimator *animator, s32 id)
 
void animator_update_model_transforms (ModelAnimator *animator, Mtx *rootTransform)
 
void render_animated_model (s32 animatorID, Mtx *rootTransform)
 
void animator_node_update_model_transform (ModelAnimator *animator, f32(*flipMtx)[4], AnimatorNode *node, Mtx *rootTransform)
 
void init_worker_list (void)
 
ModelAnimatorget_animator_by_index (s32 animModelID)
 
void reset_animator_list (void)
 
void delete_model_animator_node (AnimatorNode *node)
 
void delete_model_animator_nodes (ModelAnimator *animator)
 
void delete_model_animator (ModelAnimator *animator)
 
void render_animated_model_with_vertices (s32 animatorID, Mtx *rootTransform, s32 segment, void *baseAddr)
 
void appendGfx_animator (ModelAnimator *animator)
 
ModelAnimatorset_animator_render_callback (s32 animModelID, void *callbackArg, void(*callbackFunc)(void *))
 
void reload_mesh_animator_tree (ModelAnimator *animator)
 
s32 step_mesh_animator (ModelAnimator *animator)
 
void set_custom_gfx_builders (s32 customGfxIndex, ModelCustomGfxBuilderFunc pre, ModelCustomGfxBuilderFunc post)
 
void mdl_make_local_vertex_copy (s32 arg0, u16 treeIdx, s32)
 
void play_model_animation_starting_from (s32 index, s16 *animPos, s32 framesToSkip)
 
void mdl_set_shroud_tint_params (u8 r, u8 g, u8 b, u8 a)
 

Variables

ModelTreeInfoListgCurrentModelTreeNodeInfo
 
ModelListgCurrentModels
 

Data Structure Documentation

◆ ModelNodePropertyData

union ModelNodePropertyData
Data Fields
s32 s
f32 f
void * p

◆ ModelBoundingBox

struct ModelBoundingBox
Data Fields
s32 key
s32 halfSizeX
f32 minX
char unk_0C[0x04]
s32 halfSizeY
f32 minY
char unk_18[0x04]
s32 halfSizeZ
f32 minZ
char unk_24[0x8]
f32 maxX
char unk_30[0x8]
f32 maxY
char unk_3C[0x8]
f32 maxZ

◆ ModelNodeProperty

struct ModelNodeProperty
Data Fields
s32 key
s32 dataType
ModelNodePropertyData data

◆ ModelGroupData

struct ModelGroupData
Data Fields
Mtx * transformMatrix
Lightsn * lightingGroup
s32 numLights
s32 numChildren
struct ModelNode ** childList

◆ ModelDisplayData

struct ModelDisplayData
Data Fields
Gfx * displayList
char unk_04[0x4]

◆ ModelNode

struct ModelNode
Data Fields
s32 type
ModelDisplayData * displayData
s32 numProperties
ModelNodeProperty * propertyList
struct ModelGroupData * groupData

◆ Model

struct Model
Data Fields
u16 flags
u16 modelID
Mtx * bakedMtx
ModelNode * modelNode
ModelGroupData * groupData
Mtx * finalMtx
char unk_14[4]
Mtx savedMtx
Matrix4f userTransformMtx
Vec3f center
u8 texPannerID
u8 customGfxIndex
s8 renderMode
u8 matrixFreshness
u8 textureID
s8 textureVariation
char unk_AA[6]

◆ ModelTransformGroup

struct ModelTransformGroup
Data Fields
u16 flags
u16 groupModelID
Mtx * bakedMtx
ModelNode * baseModelNode
Mtx * finalMtx
Mtx savedMtx
Matrix4f userTransformMtx
Vec3f center
u8 minChildModelIndex
u8 maxChildModelIndex
u8 renderMode
u8 matrixFreshness

◆ ModelIDList

struct ModelIDList
Data Fields
u16 count
u16 list[]

◆ ModelLocalVertexCopy

struct ModelLocalVertexCopy
Data Fields
s32 numVertices
Vtx * minVertexAddr
Gfx * gfxCopy[2]
Vtx * vtxCopy[2]
s32 selector

◆ ModelTreeInfo

struct ModelTreeInfo
Data Fields
u8 modelIndex
u8 treeDepth
u8 textureID
char unk_03

◆ TextureHandle

struct TextureHandle
Data Fields
Gfx * gfx
TextureHeader header
u8 * raster
u16 * palette
u8 * auxRaster
u16 * auxPalette

◆ ModelBlueprint

struct ModelBlueprint
Data Fields
s16 flags
char unk_02[0x2]
ModelNode * mdlNode
ModelGroupData * groupData
Mtx * mtx

◆ ShapeFileHeader

struct ShapeFileHeader
Data Fields
ModelNode * root
Vtx_t * vertexTable
char ** modelNames
char ** colliderNames
char ** zoneNames
unsigned char pad_14[0xC]

◆ ShapeFile

struct ShapeFile
Data Fields
ShapeFileHeader header
u8 data[0x8000 - sizeof(ShapeFileHeader)]

Macro Definition Documentation

◆ SHAPE_SIZE_LIMIT

#define SHAPE_SIZE_LIMIT   0x8000

Definition at line 171 of file model.h.

Typedef Documentation

◆ ModelList

typedef Model* ModelList[256]

Definition at line 94 of file model.h.

◆ ModelTransformGroupList

typedef ModelTransformGroup* ModelTransformGroupList[4]

Definition at line 95 of file model.h.

◆ ModelLocalVertexCopyList

typedef ModelLocalVertexCopy* ModelLocalVertexCopyList[16]

Definition at line 110 of file model.h.

◆ ModelCustomGfxBuilderFunc

typedef void(* ModelCustomGfxBuilderFunc) (s32 index)

Definition at line 136 of file model.h.

◆ ModelCustomGfxList

typedef Gfx* ModelCustomGfxList[32]

Definition at line 138 of file model.h.

◆ ModelCustomGfxBuilderList

typedef ModelCustomGfxBuilderFunc ModelCustomGfxBuilderList[32]

Definition at line 139 of file model.h.

◆ ModelTreeInfoList

typedef ModelTreeInfo ModelTreeInfoList[0x200]

Definition at line 187 of file model.h.

Enumeration Type Documentation

◆ ModelPropertyKeys

Enumerator
MODEL_PROP_KEY_RENDER_MODE 
MODEL_PROP_KEY_CAMERA_DATA 
MODEL_PROP_KEY_TEXTURE_NAME 
MODEL_PROP_KEY_SPECIAL 
MODEL_PROP_KEY_GROUP_INFO 
MODEL_PROP_KEY_BOUNDING_BOX 
MODEL_PROP_KEY_62 

Definition at line 141 of file model.h.

141 {
148 MODEL_PROP_KEY_62 = 0x62,
ModelPropertyKeys
Definition model.h:141
@ MODEL_PROP_KEY_CAMERA_DATA
Definition model.h:143
@ MODEL_PROP_KEY_BOUNDING_BOX
Definition model.h:147
@ MODEL_PROP_KEY_SPECIAL
Definition model.h:145
@ MODEL_PROP_KEY_62
Definition model.h:148
@ MODEL_PROP_KEY_GROUP_INFO
Definition model.h:146
@ MODEL_PROP_KEY_TEXTURE_NAME
Definition model.h:144
@ MODEL_PROP_KEY_RENDER_MODE
Definition model.h:142

◆ ShapeTypes

enum ShapeTypes
Enumerator
SHAPE_TYPE_MODEL 
SHAPE_TYPE_GROUP 
SHAPE_TYPE_ROOT 
SHAPE_TYPE_SPECIAL_GROUP 

Definition at line 151 of file model.h.

151 {
154 SHAPE_TYPE_ROOT = 7,
156} ShapeTypes;
ShapeTypes
Definition model.h:151
@ SHAPE_TYPE_SPECIAL_GROUP
Definition model.h:155
@ SHAPE_TYPE_ROOT
Definition model.h:154
@ SHAPE_TYPE_MODEL
Definition model.h:152
@ SHAPE_TYPE_GROUP
Definition model.h:153

◆ GroupTypes

enum GroupTypes
Enumerator
GROUP_TYPE_0 
GROUP_TYPE_1 

Definition at line 158 of file model.h.

158 {
159 GROUP_TYPE_0 = 0,
160 GROUP_TYPE_1 = 1,
161} GroupTypes;
GroupTypes
Definition model.h:158
@ GROUP_TYPE_1
Definition model.h:160
@ GROUP_TYPE_0
Definition model.h:159

◆ ExtraTileTypes

Enumerator
EXTRA_TILE_NONE 
EXTRA_TILE_MIPMAPS 
EXTRA_TILE_AUX_SAME_AS_MAIN 
EXTRA_TILE_AUX_INDEPENDENT 
EXTRA_TILE_4 

Definition at line 163 of file model.h.

163 {
164 EXTRA_TILE_NONE = 0, // texture contains only a single tile
165 EXTRA_TILE_MIPMAPS = 1, // texture contais mipmaps
166 EXTRA_TILE_AUX_SAME_AS_MAIN = 2, // texture contains main and aux images with identical fmt and size
167 EXTRA_TILE_AUX_INDEPENDENT = 3, // texture contains main and aux images with independent fmt and size
168 EXTRA_TILE_4 = 4, // only use-case may be a mistake? unused and mostly unimplemented
ExtraTileTypes
Definition model.h:163
@ EXTRA_TILE_AUX_INDEPENDENT
Definition model.h:167
@ EXTRA_TILE_NONE
Definition model.h:164
@ EXTRA_TILE_MIPMAPS
Definition model.h:165
@ EXTRA_TILE_AUX_SAME_AS_MAIN
Definition model.h:166
@ EXTRA_TILE_4
Definition model.h:168

Function Documentation

◆ mdl_set_depth_tint_params()

void mdl_set_depth_tint_params ( u8 primR,
u8 primG,
u8 primB,
u8 primA,
u8 fogR,
u8 fogG,
u8 fogB,
s32 fogStart,
s32 fogEnd )

Definition at line 3920 of file model.c.

3920 {
3921 DepthTintBaseR = primR;
3922 DepthTintBaseG = primG;
3923 DepthTintBaseB = primB;
3924 DepthTintBaseA = primA;
3925 DepthTintColR = fogR;
3926 DepthTintColG = fogG;
3927 DepthTintColB = fogB;
3928 DepthTintStart = fogStart;
3929 DepthTintEnd = fogEnd;
3930}
s32 DepthTintEnd
Definition model.c:582
u8 DepthTintBaseR
Definition model.c:573
u8 DepthTintBaseG
Definition model.c:574
u8 DepthTintColR
Definition model.c:577
s32 DepthTintStart
Definition model.c:581
u8 DepthTintBaseA
Definition model.c:576
u8 DepthTintColG
Definition model.c:578
u8 DepthTintColB
Definition model.c:579
u8 DepthTintBaseB
Definition model.c:575

◆ mdl_set_remap_tint_params()

void mdl_set_remap_tint_params ( u8 primR,
u8 primG,
u8 primB,
u8 envR,
u8 envG,
u8 envB )

Definition at line 3945 of file model.c.

3945 {
3946 RemapTintMaxR = maxR;
3947 RemapTintMaxG = maxG;
3948 RemapTintMaxB = maxB;
3949 RemapTintMinR = minR;
3950 RemapTintMinG = minG;
3951 RemapTintMinB = minB;
3952}
u8 RemapTintMinG
Definition model.c:588
u8 RemapTintMaxR
Definition model.c:584
u8 RemapTintMaxG
Definition model.c:585
u8 RemapTintMinB
Definition model.c:589
u8 RemapTintMaxB
Definition model.c:586
u8 RemapTintMinR
Definition model.c:587

◆ mdl_get_remap_tint_params()

void mdl_get_remap_tint_params ( u8 * primR,
u8 * primG,
u8 * primB,
u8 * envR,
u8 * envG,
u8 * envB )

Definition at line 3954 of file model.c.

3954 {
3955 *primR = RemapTintMaxR;
3956 *primG = RemapTintMaxG;
3957 *primB = RemapTintMaxB;
3958 *envR = RemapTintMinR;
3959 *envG = RemapTintMinG;
3960 *envB = RemapTintMinB;
3961}

Referenced by appendGfx_background_texture().

◆ init_model_data()

void init_model_data ( void )

Definition at line 2431 of file model.c.

2431 {
2442 } else {
2452 }
2453}
@ CONTEXT_WORLD
Definition enums.h:3529
ModelCustomGfxList * gCurrentCustomModelGfxPtr
Definition model.c:1310
BSS s8 bBackgroundTintMode
Definition model.c:1335
BSS ModelTreeInfoList wModelTreeNodeInfo
Definition model.c:1331
ModelNode ** gCurrentModelTreeRoot
Definition model.c:1308
BSS s8 wBackgroundTintMode
Definition model.c:1334
BSS ModelNode * bModelTreeRoot
Definition model.c:1330
BSS ModelTransformGroupList bTransformGroups
Definition model.c:1318
BSS ModelTreeInfoList bModelTreeNodeInfo
Definition model.c:1332
BSS ModelLocalVertexCopyList bModelLocalVtxBuffers
Definition model.c:1326
BSS FogSettings bFogSettings
Definition model.c:1338
BSS ModelNode * wModelTreeRoot
Definition model.c:1329
u8 * gBackgroundTintModePtr
Definition model.c:105
BSS ModelList wModelList
Definition model.c:1314
BSS ModelCustomGfxBuilderList bCustomModelGfxBuilders
Definition model.c:1324
ModelCustomGfxBuilderList * gCurrentCustomModelGfxBuildersPtr
Definition model.c:1307
ModelTransformGroupList * gCurrentTransformGroups
Definition model.c:1309
BSS FogSettings * gFogSettings
Definition model.c:1339
ModelTreeInfoList * gCurrentModelTreeNodeInfo
Definition model.c:107
BSS ModelCustomGfxList bCustomModelGfx
Definition model.c:1321
BSS FogSettings wFogSettings
Definition model.c:1337
BSS ModelLocalVertexCopyList wModelLocalVtxBuffers
Definition model.c:1325
ModelList * gCurrentModels
Definition model.c:106
BSS ModelCustomGfxBuilderList wCustomModelGfxBuilders
Definition model.c:1323
BSS ModelList bModelList
Definition model.c:1315
BSS ModelTransformGroupList wTransformGroups
Definition model.c:1317
BSS ModelLocalVertexCopyList * gCurrentModelLocalVtxBuffers
Definition model.c:1327
BSS ModelCustomGfxList wCustomModelGfx
Definition model.c:1320
GameStatus * gGameStatusPtr
Definition main_loop.c:32

Referenced by state_step_end_battle(), and state_step_unpause().

◆ update_model_animator()

void update_model_animator ( s32 animatorID)

Definition at line 482 of file animator.c.

482 {
483 ModelAnimator* animator;
484 s32 temp;
485 s32 i;
486
487 if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
488 return;
489 }
490
491 animatorID &= ~BATTLE_ID_BIT;
492 animator = (*gCurrentAnimMeshListPtr)[animatorID];
493
494 if (animator == NULL || animator->flags == 0) {
495 return;
496 }
497
499 return;
500 }
501
502 animator->flags &= ~MODEL_ANIMATOR_FLAG_UPDATE_PENDING;
503 animator->nextUpdateTime -= animator->timeScale;
504
505 temp = 0;
506 if (animator->nextUpdateTime <= 0.0f) {
507 if (!(animator->flags & MODEL_ANIMATOR_FLAG_MESH)) {
508 do {
509 temp = step_model_animator(animator);
510 } while (temp > 0);
511 } else {
512 animator->nextUpdateTime = 1.0f;
514 do {
515 temp = step_mesh_animator(animator);
516 } while (temp > 0);
517 }
518 }
519 if (temp == -1) {
520 return;
521 }
522
523 animator_update_model_transforms(animator, NULL);
524
525 for (i = 0; i < ARRAY_COUNT(D_801533C0); i++) {
526 if (D_801533C0[i].ttl >= 0) {
527 D_801533C0[i].ttl--;
528 if (D_801533C0[i].ttl == 0) {
529 D_801533C0[i].ttl = -1;
531 }
532 }
533 }
534
535 for (i = 0; i < ARRAY_COUNT(D_801536C0); i++) {
536 if (D_801536C0[i].ttl >= 0) {
537 D_801536C0[i].ttl--;
538 if (D_801536C0[i].ttl == 0) {
539 D_801536C0[i].ttl = -1;
541 }
542 }
543 }
544}
BSS AnimatedMeshVertexCopyList D_801536C0
Definition animator.c:15
void reload_mesh_animator_tree(ModelAnimator *animator)
Definition animator.c:1258
s32 step_mesh_animator(ModelAnimator *animator)
Definition animator.c:1274
s32 step_model_animator(ModelAnimator *animator)
Definition animator.c:610
BSS AnimatedMeshVertexCopyList D_801533C0
Definition animator.c:14
void animator_update_model_transforms(ModelAnimator *animator, Mtx *rootTransform)
Definition animator.c:710
@ MODEL_ANIMATOR_FLAG_MESH
Definition enums.h:4926
@ MODEL_ANIMATOR_FLAG_FREEZE_ANIMATION
Definition enums.h:4929
s32 general_heap_free(void *data)
Definition heap.c:18
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define BATTLE_ID_BIT
Definition macros.h:144

Referenced by load_split_entity_data(), play_model_animation_starting_from(), update_entities(), and update_shadows().

◆ update_model_animator_with_transform()

void update_model_animator_with_transform ( s32 animatorID,
Mtx * mtx )

Definition at line 546 of file animator.c.

546 {
547 ModelAnimator* animator;
548 s32 temp;
549 s32 i;
550
551 if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
552 return;
553 }
554
555 animatorID &= ~BATTLE_ID_BIT;
556 animator = (*gCurrentAnimMeshListPtr)[animatorID];
557
558 if (animator == NULL || animator->flags == 0) {
559 return;
560 }
561
563 return;
564 }
565
566 animator->flags &= ~MODEL_ANIMATOR_FLAG_UPDATE_PENDING;
567 animator->nextUpdateTime -= animator->timeScale;
568
569 temp = 0;
570 if (animator->nextUpdateTime <= 0.0f) {
571 if (!(animator->flags & MODEL_ANIMATOR_FLAG_MESH)) {
572 do {
573 temp = step_model_animator(animator);
574 } while (temp > 0);
575 } else {
576 animator->nextUpdateTime = 1.0f;
578 do {
579 temp = step_mesh_animator(animator);
580 } while (temp > 0);
581 }
582 }
583 if (temp == -1) {
584 return;
585 }
586
588
589 for (i = 0; i < ARRAY_COUNT(D_801533C0); i++) {
590 if (D_801533C0[i].ttl >= 0) {
591 D_801533C0[i].ttl--;
592 if (D_801533C0[i].ttl == 0) {
593 D_801533C0[i].ttl = -1;
595 }
596 }
597 }
598
599 for (i = 0; i < ARRAY_COUNT(D_801536C0); i++) {
600 if (D_801536C0[i].ttl >= 0) {
601 D_801536C0[i].ttl--;
602 if (D_801536C0[i].ttl == 0) {
603 D_801536C0[i].ttl = -1;
605 }
606 }
607 }
608}

Referenced by update_animated_models().

◆ set_mdl_custom_gfx_set()

void set_mdl_custom_gfx_set ( Model * model,
s32 customGfxIndex,
u32 tintType )

Definition at line 3832 of file model.c.

3832 {
3833 if (customGfxIndex == -1) {
3834 customGfxIndex = model->customGfxIndex & 0xF;
3835 }
3836
3837 if (tintType == -1) {
3838 tintType = model->customGfxIndex >> 4;
3839 }
3840
3841 model->customGfxIndex = (customGfxIndex & 0xF) + ((tintType & 0xF) << 4);
3842}
u8 customGfxIndex
Definition model.h:71

Referenced by mdl_set_all_tint_type().

◆ get_model_property()

ModelNodeProperty * get_model_property ( ModelNode * node,
ModelPropertyKeys key )

Definition at line 2285 of file model.c.

2285 {
2286 s32 numProperties = node->numProperties;
2287 ModelNodeProperty* propertyList = node->propertyList;
2288 s32 i;
2289
2290 for (i = 0; i < numProperties; i++, propertyList++) {
2291 if (propertyList->key == key) {
2292 return propertyList;
2293 }
2294 }
2295 return NULL;
2296}
ModelNodeProperty * propertyList
Definition model.h:55
s32 numProperties
Definition model.h:54

Referenced by appendGfx_model(), func_80117D00(), func_8011B1D8(), get_model_center_and_size(), load_model_transforms(), load_next_model_textures(), mdl_calculate_model_sizes(), mdl_create_model(), mdl_make_transform_group(), mdl_update_transform_matrices(), and render_transform_group_node().

◆ load_texture_variants()

void load_texture_variants ( u32 romOffset,
s32 textureID,
s32 baseOffset,
s32 size )

Definition at line 2173 of file model.c.

2173 {
2174 u32 offset;
2175 TextureHeader iterTextureHeader;
2176 TextureHeader* header;
2177 TextureHandle* textureHandle;
2178 u32 rasterSize;
2179 s32 paletteSize;
2180 u32 auxRasterSize;
2181 u32 auxPaletteSize;
2182 s32 mainSize;
2183 s32 currentTextureID = textureID;
2184
2185 for (offset = romOffset; offset < baseOffset + size;) {
2186 dma_copy((u8*)offset, (u8*)offset + sizeof(iterTextureHeader), &iterTextureHeader);
2187 header = &iterTextureHeader;
2188
2189 if (strcmp(header->name, "end_of_textures") == 0) {
2190 return;
2191 }
2192
2193 if (!header->isVariant) {
2194 // done reading variants
2195 break;
2196 }
2197
2198 rasterSize = header->mainW * header->mainH;
2199
2200 // compute mipmaps size
2201 if (header->mainBitDepth == G_IM_SIZ_4b) {
2202 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2203 s32 d = 2;
2204 while (header->mainW / d >= 16 && header->mainH / d > 0) {
2205 rasterSize += header->mainW / d * header->mainH / d;
2206 d *= 2;
2207 }
2208 }
2209 rasterSize /= 2;
2210 } else if (header->mainBitDepth == G_IM_SIZ_8b) {
2211 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2212 s32 d = 2;
2213 while (header->mainW / d >= 8 && header->mainH / d > 0) {
2214 rasterSize += header->mainW / d * header->mainH / d;
2215 d *= 2;
2216 }
2217 }
2218 } else if (header->mainBitDepth == G_IM_SIZ_16b) {
2219 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2220 s32 d = 2;
2221 while (header->mainW / d >= 4 && header->mainH / d > 0) {
2222 rasterSize += header->mainW / d * header->mainH / d;
2223 d *= 2;
2224 }
2225 }
2226 rasterSize *= 2;
2227 } else if (header->mainBitDepth == G_IM_SIZ_32b) {
2228 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2229 s32 d = 2;
2230 while (header->mainW / d >= 2 && header->mainH / d > 0) {
2231 rasterSize += header->mainW / d * header->mainH / d;
2232 d *= 2;
2233 }
2234 }
2235 rasterSize *= 4;
2236 }
2237
2238 // compute palette size
2239 if (header->mainFmt == G_IM_FMT_CI) {
2240 paletteSize = 0x20;
2241 if (header->mainBitDepth == G_IM_SIZ_8b) {
2242 paletteSize = 0x200;
2243 }
2244 } else {
2245 paletteSize = 0;
2246 }
2247
2248 // compute aux tile size
2249 if (header->extraTiles == EXTRA_TILE_AUX_INDEPENDENT) {
2250 auxRasterSize = header->auxW * header->auxH;
2251 if (header->auxBitDepth == G_IM_SIZ_4b) {
2252 auxRasterSize /= 2;
2253 } else if (header->auxBitDepth == G_IM_SIZ_8b) {
2254 } else if (header->auxBitDepth == G_IM_SIZ_16b) {
2255 auxRasterSize *= 2;
2256 } else {
2257 if (header->auxBitDepth == G_IM_SIZ_32b) {
2258 auxRasterSize *= 4;
2259 }
2260 }
2261 if (header->auxFmt == G_IM_FMT_CI) {
2262 auxPaletteSize = 0x20;
2263 if (header->auxBitDepth == G_IM_SIZ_8b) {
2264 auxPaletteSize = 0x200;
2265 }
2266 } else {
2267 auxPaletteSize = 0;
2268 }
2269 } else {
2270 auxPaletteSize = 0;
2271 auxRasterSize = 0;
2272 }
2273
2274 textureID++;
2275 currentTextureID = textureID;
2276 textureHandle = &TextureHandles[currentTextureID];
2277 load_texture_impl(offset + sizeof(*header), textureHandle, header, rasterSize, paletteSize, auxRasterSize, auxPaletteSize);
2278
2279 mainSize = rasterSize + paletteSize + sizeof(*header);
2280 offset += mainSize;
2281 offset += auxRasterSize + auxPaletteSize;
2282 }
2283}
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:444
TextureHandle TextureHandles[128]
Definition model.c:1355
void load_texture_impl(u32 romOffset, TextureHandle *handle, TextureHeader *header, s32 mainSize, s32 mainPalSize, s32 auxSize, s32 auxPalSize)
Definition model.c:2009

Referenced by load_texture_by_name().

◆ step_model_animator()

s32 step_model_animator ( ModelAnimator * animator)

Definition at line 610 of file animator.c.

610 {
611 s16* args = animator->animReadPos;
612 AnimatorNode* node;
613 f32 x, y, z;
614 s32 flags;
615 s32 nodeId;
616
617 switch (*args++) {
618 case AS_END:
619 return -1;
621 animator->renderMode = *args++;
622 animator->animReadPos = args;
623 return 1;
624 case AS_WAIT:
625 animator->nextUpdateTime = *args++;
626 animator->animReadPos = args;
627 break;
628 case AS_END_LOOP:
629 animator->animReadPos = animator->savedReadPos;
630 return 1;
631 case AS_LOOP:
632 animator->animReadPos = animator->savedReadPos = args;
633 return 1;
634 case AS_SET_FLAGS:
635 flags = *args++;
636 animator->animReadPos = args;
637 animator->flags |= flags & 0xFFFF;
638 return 1;
640 node = get_animator_child_with_id(animator, animator->staticNodeIDs[*args++ - 1]);
641 flags = *args++;
642 node->flags |= flags;
643 animator->animReadPos = args;
644 return 1;
646 node = get_animator_child_with_id(animator, animator->staticNodeIDs[*args++ - 1]);
647 flags = *args++;
648 node->flags &= ~flags;
649 animator->animReadPos = args;
650 return 1;
651 case AS_OP_19:
653 animator->animReadPos = args;
654 return 1;
655 case AS_SET_ROTATION:
656 nodeId = animator->staticNodeIDs[*args++ - 1];
657 x = (f32)*args++ * 180.0 / 32767.0;
658 y = (f32)*args++ * 180.0 / 32767.0;
659 z = (f32)*args++ * 180.0 / 32767.0;
660 animator->animReadPos = args;
661
662 node = get_animator_child_with_id(animator, nodeId);
663 ASSERT(node != NULL);
664 node->rot.x = x;
665 node->rot.y = y;
666 node->rot.z = z;
667 return 1;
668 case AS_ADD_ROTATION:
669 nodeId = animator->staticNodeIDs[*args++ - 1];
670 x = (f32)*args++ * 180.0 / 32767.0;
671 y = (f32)*args++ * 180.0 / 32767.0;
672 z = (f32)*args++ * 180.0 / 32767.0;
673 animator->animReadPos = args;
674
675 node = get_animator_child_with_id(animator, nodeId);
676 ASSERT(node != NULL);
677 node->rot.x += x;
678 node->rot.y += y;
679 node->rot.z += z;
680 return 1;
681 case AS_SET_POS:
682 nodeId = animator->staticNodeIDs[*args++ - 1];
683 x = *args++;
684 y = *args++;
685 z = *args++;
686 animator->animReadPos = args;
687 node = get_animator_child_with_id(animator, nodeId);
688 ASSERT(node != NULL);
689 node->pos.x = x;
690 node->pos.y = y;
691 node->pos.z = z;
692 return 1;
693 case AS_SET_SCALE:
694 nodeId = animator->staticNodeIDs[*args++ - 1];
695 x = (f32)*args++ * 180.0 / 32767.0;
696 y = (f32)*args++ * 180.0 / 32767.0;
697 z = (f32)*args++ * 180.0 / 32767.0;
698 animator->animReadPos = args;
699
700 node = get_animator_child_with_id(animator, nodeId);
701 ASSERT(node != NULL);
702 node->scale.x = x;
703 node->scale.y = y;
704 node->scale.z = z;
705 return 1;
706 }
707 return 0;
708}
@ AS_CLEAR_NODE_FLAGS
@ AS_SET_FLAGS
@ AS_SET_NODE_FLAGS
@ AS_SET_POS
@ AS_SET_RENDER_MODE
@ AS_END_LOOP
@ AS_SET_ROTATION
@ AS_ADD_ROTATION
@ AS_END
@ AS_SET_SCALE
@ AS_OP_19
@ AS_WAIT
@ AS_LOOP
AnimatorNode * get_animator_child_with_id(ModelAnimator *animator, s32 id)
Definition animator.c:149
s8 flags
Definition demo_api.c:15
#define ASSERT(condition)
@ MODEL_ANIMATOR_FLAG_NO_FLIP
Definition enums.h:4928
u8 staticNodeIDs[0x7A]

Referenced by update_model_animator(), and update_model_animator_with_transform().

◆ get_animator_node_for_tree_index()

AnimatorNode * get_animator_node_for_tree_index ( ModelAnimator * animator,
s32 treeIndex )

Definition at line 1024 of file animator.c.

1024 {
1025 return get_animator_child_with_id(animator, animator->staticNodeIDs[arg1 - 1]);
1026}

◆ get_animator_node_with_id()

AnimatorNode * get_animator_node_with_id ( ModelAnimator * animator,
s32 id )

Definition at line 1028 of file animator.c.

1028 {
1029 return get_animator_child_for_model(animator->rootNode, id);
1030}
AnimatorNode * get_animator_child_for_model(AnimatorNode *node, s32 modelId)
Definition animator.c:175
AnimatorNode * rootNode

◆ animator_update_model_transforms()

void animator_update_model_transforms ( ModelAnimator * animator,
Mtx * rootTransform )

Definition at line 710 of file animator.c.

710 {
711 Matrix4f flipMtx;
712
713 if (animator->rootNode != NULL) {
716 animator_make_mirrorZ(flipMtx);
717 break;
719 animator_make_mirrorY(flipMtx);
720 break;
722 animator_make_mirrorX(flipMtx);
723 break;
724 default:
725 animator_make_identity(flipMtx);
726 break;
727 }
728 animator_node_update_model_transform(animator, flipMtx, animator->rootNode, rootTransform);
729 }
730}
void animator_node_update_model_transform(ModelAnimator *animator, f32(*flipMtx)[4], AnimatorNode *node, Mtx *rootTransform)
Definition animator.c:732
void animator_make_identity(Matrix4f mtx)
Definition animator.c:122
void animator_make_mirrorX(Matrix4f mtx)
Definition animator.c:114
void animator_make_mirrorY(Matrix4f mtx)
Definition animator.c:106
void animator_make_mirrorZ(Matrix4f mtx)
Definition animator.c:98
f32 Matrix4f[4][4]
@ MODEL_ANIMATOR_FLAG_FLIP_Y
Definition enums.h:4920
@ MODEL_ANIMATOR_FLAG_FLIP_X
Definition enums.h:4921
@ MODEL_ANIMATOR_FLAG_FLIP_Z
Definition enums.h:4919

Referenced by update_model_animator(), and update_model_animator_with_transform().

◆ render_animated_model()

void render_animated_model ( s32 animatorID,
Mtx * rootTransform )

Definition at line 765 of file animator.c.

765 {
766 ModelAnimator* animator;
767 RenderTask rt;
768 RenderTask* rtPtr = &rt;
769
770 if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
771 return;
772 }
773
774 animatorID &= ~BATTLE_ID_BIT;
775 animator = (*gCurrentAnimMeshListPtr)[animatorID];
776
777 if (animator == NULL || animator->flags == 0) {
778 return;
779 }
780
782 && animator->flags & (1 << gCurrentCamID)
783 && !(animator->flags & MODEL_ANIMATOR_FLAG_HIDDEN)
784 ) {
785 animator->mtx = *rootTransform;
786 animator->baseAddr = NULL;
787 rtPtr->appendGfxArg = animator;
788 rtPtr->appendGfx = (void (*)(void*))appendGfx_animator;
789 rtPtr->dist = 0;
790 rtPtr->renderMode = animator->renderMode;
791 queue_render_task(rtPtr);
792 }
793}
void appendGfx_animator(ModelAnimator *animator)
Definition animator.c:826
#define queue_render_task
@ MODEL_ANIMATOR_FLAG_HIDDEN
Definition enums.h:4918
@ MODEL_ANIMATOR_FLAG_UPDATE_PENDING
Definition enums.h:4917
void * appendGfxArg
void(* appendGfx)(void *)
s16 gCurrentCamID
Definition cam_main.c:13

Referenced by render_animated_models(), render_entities(), and render_shadows().

◆ animator_node_update_model_transform()

void animator_node_update_model_transform ( ModelAnimator * animator,
f32(*) flipMtx[4],
AnimatorNode * node,
Mtx * rootTransform )

Definition at line 732 of file animator.c.

733 {
734 Matrix4f sp10;
735 s32 i;
736
737 guRotateRPYF(gAnimRotMtx, clamp_angle(node->rot.x), clamp_angle(node->rot.y), clamp_angle(node->rot.z));
738 guScaleF(gAnimScaleMtx, node->scale.x, node->scale.y, node->scale.z);
739 guTranslateF(gAnimTranslateMtx, node->basePos.x + node->pos.x, node->basePos.y + node->pos.y, node->basePos.z + node->pos.z);
742
743 if (!(animator->flags & MODEL_ANIMATOR_FLAG_NO_FLIP)) {
744 guMtxCatF(sp10, flipMtx, sp10);
745 }
746
747 copy_matrix(sp10, node->mtx);
748
751
752 copy_matrix(sp10, model->userTransformMtx);
753 guMtxL2F(sp10, rootTransform);
754 guMtxCatF(model->userTransformMtx, sp10, model->userTransformMtx);
756 }
757
758 for (i = 0; i < ARRAY_COUNT(node->children); i++) {
759 if (node->children[i] != NULL) {
760 animator_node_update_model_transform(animator, sp10, node->children[i], rootTransform);
761 }
762 }
763}
BSS Matrix4f gAnimRotScaleMtx
Definition animator.c:30
BSS Matrix4f gAnimTranslateMtx
Definition animator.c:29
BSS Matrix4f gAnimRotMtx
Definition animator.c:27
BSS Matrix4f gAnimScaleMtx
Definition animator.c:28
union AnimatorNode::@29 fcData
struct AnimatorNode * children[32]
#define guTranslateF
#define guMtxCatF
#define clamp_angle
#define guScaleF
@ MODEL_FLAG_MATRIX_DIRTY
Definition enums.h:4369
@ MODEL_ANIMATOR_FLAG_HAS_MODEL
Definition enums.h:4923
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3397
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3315
void copy_matrix(Matrix4f src, Matrix4f dest)
Definition 43F0.c:439
u16 flags
Definition model.h:60
Matrix4f userTransformMtx
Definition model.h:68
Definition model.h:59

Referenced by animator_node_update_model_transform(), and animator_update_model_transforms().

◆ init_worker_list()

void init_worker_list ( void )

Definition at line 24 of file worker.c.

24 {
27 } else {
29 }
30}
BSS WorkerList gWorldWorkerList
Definition worker.c:3
BSS WorkerList * gCurrentWorkerListPtr
Definition worker.c:5
BSS WorkerList gBattleWorkerList
Definition worker.c:4

Referenced by state_step_end_battle(), and state_step_unpause().

◆ get_animator_by_index()

ModelAnimator * get_animator_by_index ( s32 animModelID)

Definition at line 1041 of file animator.c.

1041 {
1042 return (*gCurrentAnimMeshListPtr)[animModelID & ~BATTLE_ID_BIT];
1043}
BSS AnimatedMeshList * gCurrentAnimMeshListPtr
Definition animator.c:18

Referenced by delete_entity(), delete_entity_and_unload_data(), entity_ItemlessBlock_init(), and entity_PinkFlower_init().

◆ reset_animator_list()

void reset_animator_list ( void )

Definition at line 252 of file animator.c.

252 {
255 } else {
257 }
258
259 gAnimModelFogR = 10;
260 gAnimModelFogG = 10;
261 gAnimModelFogB = 10;
262 gAnimModelFogA = 10;
263 gAnimModelFogStart = 800;
264 gAnimCount = 0;
266 gAnimModelFogEnd = 1000;
267}
BSS s32 gAnimModelFogR
Definition animator.c:20
BSS s32 gAnimModelFogG
Definition animator.c:21
BSS AnimatedMeshList D_801539C0
Definition animator.c:16
BSS AnimatedMeshList D_80153A00
Definition animator.c:17
s32 gAnimCount
Definition animator.c:12
BSS s32 gAnimModelFogEnd
Definition animator.c:25
BSS s32 gAnimModelFogA
Definition animator.c:23
BSS s32 gAnimModelFogStart
Definition animator.c:24
BSS s32 gAnimModelFogB
Definition animator.c:22
BSS s32 gAnimModelFogEnabled
Definition animator.c:19

Referenced by state_step_end_battle(), and state_step_unpause().

◆ delete_model_animator_node()

void delete_model_animator_node ( AnimatorNode * node)

Definition at line 269 of file animator.c.

269 {
270 s32 i;
271
272 node->flags = 0;
273
274 for (i = 0; i < ARRAY_COUNT(node->children); i++) {
275 if (node->children[i] != NULL) {
277 node->children[i] = NULL;
278 }
279 }
280
281 heap_free(node);
282}
void delete_model_animator_node(AnimatorNode *node)
Definition animator.c:269
s32 heap_free(void *ptr)
Definition heap.c:42

Referenced by delete_model_animator(), delete_model_animator_node(), and delete_model_animator_nodes().

◆ delete_model_animator_nodes()

void delete_model_animator_nodes ( ModelAnimator * animator)

Definition at line 284 of file animator.c.

284 {
285 s32 i;
286
287 animator->nextUniqueID = 0;
288 for (i = 0; i < ARRAY_COUNT(animator->nodeCache); i++) {
289 animator->nodeCache[i] = NULL;
290 }
291 if (animator->rootNode != NULL) {
293 animator->rootNode = NULL;
294 }
295}
AnimatorNode * nodeCache[0x7A]

Referenced by reload_mesh_animator_tree().

◆ delete_model_animator()

void delete_model_animator ( ModelAnimator * animator)

Definition at line 297 of file animator.c.

297 {
298 s32 i;
299
300 animator->nextUniqueID = 0;
301
302 if (animator->rootNode != NULL) {
304 animator->rootNode = NULL;
305
306 for (i = 0; i < ARRAY_COUNT(*gCurrentAnimMeshListPtr); i++) {
307 if ((*gCurrentAnimMeshListPtr)[i] == animator) {
308 (*gCurrentAnimMeshListPtr)[i] = NULL;
309 break;
310 }
311 }
312
313 heap_free(animator);
314 gAnimCount--;
315 }
316}

Referenced by delete_entity(), and delete_entity_and_unload_data().

◆ render_animated_model_with_vertices()

void render_animated_model_with_vertices ( s32 animatorID,
Mtx * rootTransform,
s32 segment,
void * baseAddr )

Definition at line 795 of file animator.c.

795 {
796 ModelAnimator* animator;
797 RenderTask rt;
798 RenderTask* rtPtr = &rt;
799
800 if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
801 return;
802 }
803
804 animatorID &= ~BATTLE_ID_BIT;
805 animator = (*gCurrentAnimMeshListPtr)[animatorID];
806
807 if (animator == NULL || animator->flags == 0) {
808 return;
809 }
810
812 && animator->flags & (1 << gCurrentCamID)
813 && !(animator->flags & MODEL_ANIMATOR_FLAG_HIDDEN)
814 ) {
815 animator->mtx = *rootTransform;
816 gAnimVtxSegment = segment;
817 animator->baseAddr = baseAddr;
818 rtPtr->appendGfxArg = animator;
819 rtPtr->appendGfx = (void (*)(void*))appendGfx_animator;
820 rtPtr->dist = 0;
821 rtPtr->renderMode = animator->renderMode;
822 queue_render_task(rtPtr);
823 }
824}
BSS s32 gAnimVtxSegment
Definition animator.c:26

Referenced by render_entities(), and render_shadows().

◆ appendGfx_animator()

void appendGfx_animator ( ModelAnimator * animator)

Definition at line 826 of file animator.c.

826 {
827 Matrix4f sp10;
828
829 if (animator->baseAddr != NULL) {
830 gSPSegment(gMainGfxPos++, gAnimVtxSegment, VIRTUAL_TO_PHYSICAL(animator->baseAddr));
831 }
832
834 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
835
836 //TODO find better match
837 switch (gAnimModelFogEnabled != 0) {
838 case FALSE:
839 switch (animator->renderMode) {
841 gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_OPA);
842 break;
844 gSPDisplayList(gMainGfxPos++, Gfx_RM1_DECAL_OPA);
845 break;
847 gSPDisplayList(gMainGfxPos++, Gfx_RM1_INTERSECTING_OPA);
848 break;
850 gSPDisplayList(gMainGfxPos++, Gfx_RM1_ALPHATEST);
851 break;
853 gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_XLU);
854 break;
856 gSPDisplayList(gMainGfxPos++, Gfx_RM1_DECAL_XLU);
857 break;
859 gSPDisplayList(gMainGfxPos++, Gfx_RM1_INTERSECTING_XLU);
860 break;
861 }
862 break;
863 case TRUE:
864 switch (animator->renderMode) {
866 gSPDisplayList(gMainGfxPos++, Gfx_RM3_SURFACE_OPA);
867 break;
869 gSPDisplayList(gMainGfxPos++, Gfx_RM3_DECAL_OPA);
870 break;
872 gSPDisplayList(gMainGfxPos++, Gfx_RM3_INTERSECTING_OPA);
873 break;
875 gSPDisplayList(gMainGfxPos++, Gfx_RM3_ALPHATEST);
876 break;
878 gSPDisplayList(gMainGfxPos++, Gfx_RM3_SURFACE_XLU);
879 break;
881 gSPDisplayList(gMainGfxPos++, Gfx_RM3_DECAL_XLU);
882 break;
884 gSPDisplayList(gMainGfxPos++, Gfx_RM3_INTERSECTING_XLU);
885 break;
886 }
887
890 break;
891 }
892
893 guMtxL2F(sp10, &animator->mtx);
894 appendGfx_animator_node(animator, animator->rootNode, sp10);
895 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
896}
Gfx Gfx_RM3_DECAL_OPA[]
Definition model.c:1077
Gfx Gfx_RM3_SURFACE_OPA[]
Definition model.c:1067
Gfx Gfx_RM3_DECAL_XLU[]
Definition model.c:1117
void appendGfx_animator_node(ModelAnimator *, AnimatorNode *, Matrix4f)
Definition animator.c:898
Gfx Gfx_RM1_ALPHATEST[]
Definition model.c:676
Gfx Gfx_RM1_INTERSECTING_OPA[]
Definition model.c:665
Gfx Gfx_RM1_INTERSECTING_XLU[]
Definition model.c:706
Gfx Gfx_RM3_ALPHATEST[]
Definition model.c:1097
Gfx Gfx_RM1_SURFACE_XLU[]
Definition model.c:686
Gfx Gfx_RM3_INTERSECTING_OPA[]
Definition model.c:1087
Gfx Gfx_RM1_DECAL_OPA[]
Definition model.c:654
Gfx Gfx_RM1_DECAL_XLU[]
Definition model.c:696
Gfx Gfx_RM3_INTERSECTING_XLU[]
Definition model.c:1127
Gfx Gfx_RM1_SURFACE_OPA[]
Definition model.c:643
Gfx Gfx_RM3_SURFACE_XLU[]
Definition model.c:1107
Mtx matrixStack[0x200]
@ RENDER_MODE_DECAL_OPA
Definition enums.h:3268
@ RENDER_MODE_INTERSECTING_XLU
Definition enums.h:3303
@ RENDER_MODE_DECAL_XLU
Definition enums.h:3291
@ RENDER_MODE_INTERSECTING_OPA
Definition enums.h:3272
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3282
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by render_animated_model(), and render_animated_model_with_vertices().

◆ set_animator_render_callback()

ModelAnimator * set_animator_render_callback ( s32 animModelID,
void * callbackArg,
void(*)(void *) callbackFunc )

Definition at line 1045 of file animator.c.

1045 {
1046 ModelAnimator* ret = (*gCurrentAnimMeshListPtr)[animModelID & ~BATTLE_ID_BIT];
1047
1048 ret->fpRenderCallback = callbackFunc;
1049 ret->renderCallbackArg = callbackArg;
1050 return ret;
1051}
void(* fpRenderCallback)(void *)

Referenced by render_entities().

◆ reload_mesh_animator_tree()

void reload_mesh_animator_tree ( ModelAnimator * animator)

Definition at line 1258 of file animator.c.

1258 {
1259 s32 nodeIDs[ARRAY_COUNT(animator->staticNodeIDs)];
1260 s32 i;
1261
1263 gAnimTreeRoot = animator->staticRoot;
1264
1265 for (i = 0; i < ARRAY_COUNT(animator->staticNodes); i++) {
1266 nodeIDs[i] = 0;
1267 }
1268
1269 reload_mesh_animator_node(animator->staticNodes[animator->treeIndexPos], animator, 0, nodeIDs);
1270 nodeIDs[0] = -1;
1271 set_animator_tree_to_node_map(animator, nodeIDs, ARRAY_COUNT(nodeIDs));
1272}
void set_animator_tree_to_node_map(ModelAnimator *animator, s32 *nodeIDs, s32 count)
Definition animator.c:1032
void delete_model_animator_nodes(ModelAnimator *animator)
Definition animator.c:284
void reload_mesh_animator_node(StaticAnimatorNode *node, ModelAnimator *animator, s32 parentNodeID, s32 *treeIndexToNodeIDs)
Definition animator.c:1226
BSS StaticAnimatorNode ** gAnimTreeRoot
Definition animator.c:31
StaticAnimatorNode * staticNodes[0x7A]
StaticAnimatorNode ** staticRoot

Referenced by step_mesh_animator(), update_model_animator(), and update_model_animator_with_transform().

◆ step_mesh_animator()

s32 step_mesh_animator ( ModelAnimator * animator)

Definition at line 1274 of file animator.c.

1274 {
1275 s16* args = animator->animReadPos;
1276 s16* oldPos = animator->animReadPos;
1277 AnimatorNode* node;
1278 f32 x, y, z;
1279 s32 flags;
1280 s32 nodeId;
1281
1282 switch (*args++) {
1283 case AS_END:
1284 return -1;
1285 case AS_SET_RENDER_MODE:
1286 animator->renderMode = *args++;
1287 animator->animReadPos = args;
1288 return 1;
1289 case AS_WAIT:
1290 args++;
1291 animator->animReadPos = args;
1292 return 1;
1293 case AS_END_LOOP:
1294 animator->animReadPos = animator->savedReadPos;
1295 animator->treeIndexPos = animator->savedTreePos;
1296 reload_mesh_animator_tree(animator);
1297 return 1;
1298 case AS_OP_4:
1299 animator->animReadPos = animator->savedReadPos;
1300 animator->treeIndexPos = animator->savedTreePos;
1301 break;
1302 case AS_LOOP:
1303 animator->animReadPos = animator->savedReadPos = args;
1304 animator->savedTreePos = animator->treeIndexPos;
1305 return 1;
1306 case AS_SET_FLAGS:
1307 flags = *args++;
1308 animator->animReadPos = args;
1309 animator->flags |= flags & 0xFFFF;
1310 return 1;
1311 case AS_SET_NODE_FLAGS:
1312 node = get_animator_child_with_id(animator, animator->staticNodeIDs[*args++ - 1]);
1313 flags = *args++;
1314 node->flags |= flags;
1315 animator->animReadPos = args;
1316 return 1;
1318 node = get_animator_child_with_id(animator, animator->staticNodeIDs[*args++ - 1]);
1319 flags = *args++;
1320 node->flags &= ~flags;
1321 animator->animReadPos = args;
1322 return 1;
1323 case AS_OP_19:
1325 animator->animReadPos = args;
1326 return 1;
1327 case AS_SET_ROTATION:
1328 nodeId = animator->staticNodeIDs[*args++ - 1];
1329 x = (f32)*args++ * 180.0 / 32767.0;
1330 y = (f32)*args++ * 180.0 / 32767.0;
1331 z = (f32)*args++ * 180.0 / 32767.0;
1332 animator->animReadPos = args;
1333 if (nodeId != 0xFF) {
1334 node = get_animator_child_with_id(animator, nodeId);
1335 if (node != NULL) {
1336 node->rot.x = x;
1337 node->rot.y = y;
1338 node->rot.z = z;
1339 return 1;
1340 } else {
1341 animator->animReadPos = oldPos;
1342 animator->treeIndexPos++;
1343 break;
1344 }
1345 }
1346 return 1;
1347 case AS_ADD_ROTATION:
1348 nodeId = animator->staticNodeIDs[*args++ - 1];
1349 x = (f32)*args++ * 180.0 / 32767.0;
1350 y = (f32)*args++ * 180.0 / 32767.0;
1351 z = (f32)*args++ * 180.0 / 32767.0;
1352 animator->animReadPos = args;
1353 if (nodeId != 0xFF) {
1354 node = get_animator_child_with_id(animator, nodeId);
1355 if (node != NULL) {
1356 node->rot.x += x;
1357 node->rot.y += y;
1358 node->rot.z += z;
1359 return 1;
1360 } else {
1361 animator->animReadPos = oldPos;
1362 animator->treeIndexPos++;
1363 break;
1364 }
1365 }
1366 return 1;
1367 case AS_SET_POS:
1368 nodeId = animator->staticNodeIDs[*args++ - 1];
1369 x = *args++;
1370 y = *args++;
1371 z = *args++;
1372 animator->animReadPos = args;
1373 if (nodeId != 0xFF) {
1374 node = get_animator_child_with_id(animator, nodeId);
1375 if (node != NULL) {
1376 node->pos.x = x;
1377 node->pos.y = y;
1378 node->pos.z = z;
1379 return 1;
1380 } else {
1381 animator->animReadPos = oldPos;
1382 animator->treeIndexPos++;
1383 break;
1384 }
1385 }
1386 return 1;
1387 case AS_SET_SCALE:
1388 nodeId = animator->staticNodeIDs[*args++ - 1];
1389 x = (f32)*args++ * 180.0 / 32767.0;
1390 y = (f32)*args++ * 180.0 / 32767.0;
1391 z = (f32)*args++ * 180.0 / 32767.0;
1392 animator->animReadPos = args;
1393 if (nodeId != 0xFF) {
1394 node = get_animator_child_with_id(animator, nodeId);
1395 if (node != NULL) {
1396 node->scale.x = x;
1397 node->scale.y = y;
1398 node->scale.z = z;
1399 return 1;
1400 } else {
1401 animator->animReadPos = oldPos;
1402 animator->treeIndexPos++;
1403 break;
1404 }
1405 }
1406 return 1;
1407 }
1408 return 0;
1409}
@ AS_OP_4

Referenced by update_model_animator(), and update_model_animator_with_transform().

◆ set_custom_gfx_builders()

void set_custom_gfx_builders ( s32 customGfxIndex,
ModelCustomGfxBuilderFunc pre,
ModelCustomGfxBuilderFunc post )

Definition at line 3849 of file model.c.

3849 {
3850 (*gCurrentCustomModelGfxBuildersPtr)[customGfxIndex * 2] = pre;
3851 (*gCurrentCustomModelGfxBuildersPtr)[customGfxIndex * 2 + 1] = post;
3852}

◆ mdl_make_local_vertex_copy()

void mdl_make_local_vertex_copy ( s32 arg0,
u16 treeIdx,
s32 isMakingCopy )

Definition at line 4041 of file model.c.

4041 {
4042 s32 numVertices;
4043 Vtx* baseVtx;
4044 s32 gfxCount;
4045 Gfx* nodeDlist;
4046 Model* model;
4048 s32 i;
4049
4051 nodeDlist = model->modelNode->displayData->displayList;
4052 mdl_get_vertex_count(nodeDlist, &numVertices, &baseVtx, &gfxCount, NULL);
4053
4054 copy = (*gCurrentModelLocalVtxBuffers)[copyIndex] = heap_malloc(sizeof(*copy));
4055
4056 if (isMakingCopy) {
4057 for (i = 0; i < ARRAY_COUNT(copy->gfxCopy); i++) {
4058 copy->gfxCopy[i] = heap_malloc(gfxCount * sizeof(*copy->gfxCopy[i]));
4059 copy->vtxCopy[i] = heap_malloc(numVertices * sizeof(*copy->vtxCopy[i]));
4060 mdl_local_gfx_update_vtx_pointers(nodeDlist, baseVtx, copy->gfxCopy[i], copy->vtxCopy[i]);
4061 mdl_local_gfx_copy_vertices(baseVtx, numVertices, copy->vtxCopy[i]);
4062 }
4064 } else {
4065 for (i = 0; i < ARRAY_COUNT(copy->gfxCopy); i++) {
4066 copy->gfxCopy[i] = NULL;
4067 copy->vtxCopy[i] = NULL;
4068 }
4069 model->flags |= MODEL_FLAG_HIDDEN;
4070 }
4071
4072 copy->selector = 0;
4073 copy->numVertices = numVertices;
4074 copy->minVertexAddr = baseVtx;
4075}
@ MODEL_FLAG_HAS_LOCAL_VERTEX_COPY
Definition enums.h:4364
@ MODEL_FLAG_HIDDEN
Definition enums.h:4358
void * heap_malloc(s32 size)
Definition heap.c:34
void mdl_local_gfx_copy_vertices(Vtx *src, s32 num, Vtx *dest)
Definition model.c:4032
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3397
void mdl_get_vertex_count(Gfx *gfx, s32 *numVertices, Vtx **baseVtx, s32 *gfxCount, Vtx *baseAddr)
Definition model.c:3963
Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3315
void mdl_local_gfx_update_vtx_pointers(Gfx *nodeDlist, Vtx *baseVtx, Gfx *arg2, Vtx *arg3)
Definition model.c:4016
Vtx * vtxCopy[2]
Definition model.h:106
Gfx * gfxCopy[2]
Definition model.h:105
Gfx * displayList
Definition model.h:47
ModelNode * modelNode
Definition model.h:63
ModelDisplayData * displayData
Definition model.h:53

◆ play_model_animation_starting_from()

void play_model_animation_starting_from ( s32 index,
s16 * animPos,
s32 framesToSkip )

Definition at line 1113 of file animator.c.

1113 {
1114 s32 indexMasked = index & ~BATTLE_ID_BIT;
1115 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[indexMasked];
1116 s32 i;
1117
1118 if (animator->animationBuffer != NULL) {
1119 animPos = (s16*) (((s32)animPos & 0xFFFFFF) + (s32)animator->animationBuffer); // TODO: array access? / cleanup
1120 }
1121
1122 animator->animReadPos = animPos;
1123 animator->savedReadPos = animPos;
1124 animator->treeIndexPos = 0;
1125 animator->nextUpdateTime = 1.0f;
1126
1127 for (i = 0; i < framesToSkip; i++) {
1128 update_model_animator(indexMasked);
1129 }
1130}
void update_model_animator(s32 animatorID)
Definition animator.c:482

◆ mdl_set_shroud_tint_params()

void mdl_set_shroud_tint_params ( u8 r,
u8 g,
u8 b,
u8 a )

Definition at line 3906 of file model.c.

3906 {
3907 ShroudTintR = r;
3908 ShroudTintG = g;
3909 ShroudTintB = b;
3910 ShroudTintAmt = a;
3911}
u8 ShroudTintR
Definition model.c:569
u8 ShroudTintAmt
Definition model.c:568
u8 ShroudTintB
Definition model.c:571
u8 ShroudTintG
Definition model.c:570

Referenced by btl_state_update_celebration().

Variable Documentation

◆ gCurrentModelTreeNodeInfo

ModelTreeInfoList* gCurrentModelTreeNodeInfo
extern

Definition at line 107 of file model.c.

◆ gCurrentModels