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 GfxModelCustomGfxList[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

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

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 3916 of file model.c.

3916 {
3917 DepthTintBaseR = primR;
3918 DepthTintBaseG = primG;
3919 DepthTintBaseB = primB;
3920 DepthTintBaseA = primA;
3926}
BSS s32 PopupMenu_SelectedIndex
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 3941 of file model.c.

3941 {
3948}
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 3950 of file model.c.

3950 {
3951 *primR = RemapTintMaxR;
3952 *primG = RemapTintMaxG;
3953 *primB = RemapTintMaxB;
3954 *envR = RemapTintMinR;
3955 *envG = RemapTintMinG;
3956 *envB = RemapTintMinB;
3957}

Referenced by appendGfx_background_texture().

◆ init_model_data()

void init_model_data ( void )

Definition at line 2430 of file model.c.

2430 {
2441 } else {
2451 }
2452}
@ CONTEXT_WORLD
Definition enums.h:3562
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:31

Referenced by state_step_end_battle(), and state_step_unpause().

◆ update_model_animator()

void update_model_animator ( s32 animatorID)

Definition at line 481 of file animator.c.

481 {
483 s32 temp;
484 s32 i;
485
487 return;
488 }
489
491 animator = (*gCurrentAnimMeshListPtr)[animatorID];
492
493 if (animator == nullptr || animator->flags == 0) {
494 return;
495 }
496
498 return;
499 }
500
502 animator->nextUpdateTime -= animator->timeScale;
503
504 temp = 0;
505 if (animator->nextUpdateTime <= 0.0f) {
506 if (!(animator->flags & MODEL_ANIMATOR_FLAG_MESH)) {
507 do {
509 } while (temp > 0);
510 } else {
511 animator->nextUpdateTime = 1.0f;
513 do {
515 } while (temp > 0);
516 }
517 }
518 if (temp == -1) {
519 return;
520 }
521
523
524 for (i = 0; i < ARRAY_COUNT(D_801533C0); i++) {
525 if (D_801533C0[i].ttl >= 0) {
526 D_801533C0[i].ttl--;
527 if (D_801533C0[i].ttl == 0) {
528 D_801533C0[i].ttl = -1;
530 }
531 }
532 }
533
534 for (i = 0; i < ARRAY_COUNT(D_801536C0); i++) {
535 if (D_801536C0[i].ttl >= 0) {
536 D_801536C0[i].ttl--;
537 if (D_801536C0[i].ttl == 0) {
538 D_801536C0[i].ttl = -1;
540 }
541 }
542 }
543}
BSS AnimatedMeshVertexCopyList D_801536C0
Definition animator.c:15
void reload_mesh_animator_tree(ModelAnimator *animator)
Definition animator.c:1257
s32 step_mesh_animator(ModelAnimator *animator)
Definition animator.c:1273
s32 step_model_animator(ModelAnimator *animator)
Definition animator.c:609
BSS AnimatedMeshVertexCopyList D_801533C0
Definition animator.c:14
void animator_update_model_transforms(ModelAnimator *animator, Mtx *rootTransform)
Definition animator.c:709
@ MODEL_ANIMATOR_FLAG_MESH
Definition enums.h:4511
@ MODEL_ANIMATOR_FLAG_FREEZE_ANIMATION
Definition enums.h:4514
s32 general_heap_free(void *data)
Definition heap.c:18
#define ARRAY_COUNT(arr)
Definition macros.h:39
#define BATTLE_ID_BIT
Definition macros.h:155

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 545 of file animator.c.

545 {
547 s32 temp;
548 s32 i;
549
551 return;
552 }
553
555 animator = (*gCurrentAnimMeshListPtr)[animatorID];
556
557 if (animator == nullptr || animator->flags == 0) {
558 return;
559 }
560
562 return;
563 }
564
566 animator->nextUpdateTime -= animator->timeScale;
567
568 temp = 0;
569 if (animator->nextUpdateTime <= 0.0f) {
570 if (!(animator->flags & MODEL_ANIMATOR_FLAG_MESH)) {
571 do {
573 } while (temp > 0);
574 } else {
575 animator->nextUpdateTime = 1.0f;
577 do {
579 } while (temp > 0);
580 }
581 }
582 if (temp == -1) {
583 return;
584 }
585
587
588 for (i = 0; i < ARRAY_COUNT(D_801533C0); i++) {
589 if (D_801533C0[i].ttl >= 0) {
590 D_801533C0[i].ttl--;
591 if (D_801533C0[i].ttl == 0) {
592 D_801533C0[i].ttl = -1;
594 }
595 }
596 }
597
598 for (i = 0; i < ARRAY_COUNT(D_801536C0); i++) {
599 if (D_801536C0[i].ttl >= 0) {
600 D_801536C0[i].ttl--;
601 if (D_801536C0[i].ttl == 0) {
602 D_801536C0[i].ttl = -1;
604 }
605 }
606 }
607}

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 3828 of file model.c.

3828 {
3829 if (customGfxIndex == -1) {
3830 customGfxIndex = model->customGfxIndex & 0xF;
3831 }
3832
3833 if (tintType == -1) {
3834 tintType = model->customGfxIndex >> 4;
3835 }
3836
3837 model->customGfxIndex = (customGfxIndex & 0xF) + ((tintType & 0xF) << 4);
3838}

Referenced by mdl_set_all_tint_type().

◆ get_model_property()

ModelNodeProperty * get_model_property ( ModelNode * node,
ModelPropertyKeys key )

Definition at line 2284 of file model.c.

2284 {
2285 s32 numProperties = node->numProperties;
2286 ModelNodeProperty* propertyList = node->propertyList;
2287 s32 i;
2288
2289 for (i = 0; i < numProperties; i++, propertyList++) {
2290 if (propertyList->key == key) {
2291 return propertyList;
2292 }
2293 }
2294 return nullptr;
2295}

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 2172 of file model.c.

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

Referenced by load_texture_by_name().

◆ step_model_animator()

s32 step_model_animator ( ModelAnimator * animator)

Definition at line 609 of file animator.c.

609 {
610 s16* args = animator->animReadPos;
612 f32 x, y, z;
613 s32 flags;
614 s32 nodeId;
615
616 switch (*args++) {
617 case AS_END:
618 return -1;
620 animator->renderMode = *args++;
621 animator->animReadPos = args;
622 return 1;
623 case AS_WAIT:
624 animator->nextUpdateTime = *args++;
625 animator->animReadPos = args;
626 break;
627 case AS_END_LOOP:
628 animator->animReadPos = animator->savedReadPos;
629 return 1;
630 case AS_LOOP:
631 animator->animReadPos = animator->savedReadPos = args;
632 return 1;
633 case AS_SET_FLAGS:
634 flags = *args++;
635 animator->animReadPos = args;
636 animator->flags |= flags & 0xFFFF;
637 return 1;
639 node = get_animator_child_with_id(animator, animator->staticNodeIDs[*args++ - 1]);
640 flags = *args++;
641 node->flags |= flags;
642 animator->animReadPos = args;
643 return 1;
645 node = get_animator_child_with_id(animator, animator->staticNodeIDs[*args++ - 1]);
646 flags = *args++;
647 node->flags &= ~flags;
648 animator->animReadPos = args;
649 return 1;
650 case AS_OP_19:
652 animator->animReadPos = args;
653 return 1;
654 case AS_SET_ROTATION:
655 nodeId = animator->staticNodeIDs[*args++ - 1];
656 x = (f32)*args++ * 180.0 / 32767.0;
657 y = (f32)*args++ * 180.0 / 32767.0;
658 z = (f32)*args++ * 180.0 / 32767.0;
659 animator->animReadPos = args;
660
662 ASSERT(node != nullptr);
663 node->rot.x = x;
664 node->rot.y = y;
665 node->rot.z = z;
666 return 1;
667 case AS_ADD_ROTATION:
668 nodeId = animator->staticNodeIDs[*args++ - 1];
669 x = (f32)*args++ * 180.0 / 32767.0;
670 y = (f32)*args++ * 180.0 / 32767.0;
671 z = (f32)*args++ * 180.0 / 32767.0;
672 animator->animReadPos = args;
673
675 ASSERT(node != nullptr);
676 node->rot.x += x;
677 node->rot.y += y;
678 node->rot.z += z;
679 return 1;
680 case AS_SET_POS:
681 nodeId = animator->staticNodeIDs[*args++ - 1];
682 x = *args++;
683 y = *args++;
684 z = *args++;
685 animator->animReadPos = args;
687 ASSERT(node != nullptr);
688 node->pos.x = x;
689 node->pos.y = y;
690 node->pos.z = z;
691 return 1;
692 case AS_SET_SCALE:
693 nodeId = animator->staticNodeIDs[*args++ - 1];
694 x = (f32)*args++ * 180.0 / 32767.0;
695 y = (f32)*args++ * 180.0 / 32767.0;
696 z = (f32)*args++ * 180.0 / 32767.0;
697 animator->animReadPos = args;
698
700 ASSERT(node != nullptr);
701 node->scale.x = x;
702 node->scale.y = y;
703 node->scale.z = z;
704 return 1;
705 }
706 return 0;
707}
@ 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:4513

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 1023 of file animator.c.

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

◆ get_animator_node_with_id()

AnimatorNode * get_animator_node_with_id ( ModelAnimator * animator,
s32 id )

Definition at line 1027 of file animator.c.

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

◆ animator_update_model_transforms()

void animator_update_model_transforms ( ModelAnimator * animator,
Mtx * rootTransform )

Definition at line 709 of file animator.c.

709 {
711
712 if (animator->rootNode != nullptr) {
716 break;
719 break;
722 break;
723 default:
725 break;
726 }
728 }
729}
void animator_node_update_model_transform(ModelAnimator *animator, f32(*flipMtx)[4], AnimatorNode *node, Mtx *rootTransform)
Definition animator.c:731
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:4505
@ MODEL_ANIMATOR_FLAG_FLIP_X
Definition enums.h:4506
@ MODEL_ANIMATOR_FLAG_FLIP_Z
Definition enums.h:4504

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 764 of file animator.c.

764 {
767 RenderTask* rtPtr = &rt;
768
770 return;
771 }
772
774 animator = (*gCurrentAnimMeshListPtr)[animatorID];
775
776 if (animator == nullptr || animator->flags == 0) {
777 return;
778 }
779
781 && animator->flags & (1 << gCurrentCamID)
783 ) {
784 animator->mtx = *rootTransform;
785 animator->baseAddr = nullptr;
787 rtPtr->appendGfx = (void (*)(void*))appendGfx_animator;
788 rtPtr->dist = 0;
789 rtPtr->renderMode = animator->renderMode;
791 }
792}
void appendGfx_animator(ModelAnimator *animator)
Definition animator.c:825
#define queue_render_task
@ MODEL_ANIMATOR_FLAG_HIDDEN
Definition enums.h:4503
@ MODEL_ANIMATOR_FLAG_UPDATE_PENDING
Definition enums.h:4502
void * appendGfxArg
s16 gCurrentCamID
Definition cam_main.c:12

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 731 of file animator.c.

732 {
734 s32 i;
735
737 guScaleF(gAnimScaleMtx, node->scale.x, node->scale.y, node->scale.z);
738 guTranslateF(gAnimTranslateMtx, node->basePos.x + node->pos.x, node->basePos.y + node->pos.y, node->basePos.z + node->pos.z);
741
742 if (!(animator->flags & MODEL_ANIMATOR_FLAG_NO_FLIP)) {
744 }
745
746 copy_matrix(sp10, node->mtx);
747
748 if (node->flags & MODEL_ANIMATOR_FLAG_HAS_MODEL) {
750
751 copy_matrix(sp10, model->userTransformMtx);
753 guMtxCatF(model->userTransformMtx, sp10, model->userTransformMtx);
755 }
756
757 for (i = 0; i < ARRAY_COUNT(node->children); i++) {
758 if (node->children[i] != nullptr) {
760 }
761 }
762}
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
#define guTranslateF
#define guMtxCatF
#define clamp_angle
#define guScaleF
@ MODEL_FLAG_MATRIX_DIRTY
Definition enums.h:3954
@ MODEL_ANIMATOR_FLAG_HAS_MODEL
Definition enums.h:4508
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3393
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3312
void copy_matrix(Matrix4f src, Matrix4f dest)
Definition 43F0.c:437
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 1040 of file animator.c.

1040 {
1041 return (*gCurrentAnimMeshListPtr)[animModelID & ~BATTLE_ID_BIT];
1042}
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] != nullptr) {
276 delete_model_animator_node(node->children[i]);
277 node->children[i] = nullptr;
278 }
279 }
280
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] = nullptr;
290 }
291 if (animator->rootNode != nullptr) {
293 animator->rootNode = nullptr;
294 }
295}

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 != nullptr) {
304 animator->rootNode = nullptr;
305
306 for (i = 0; i < ARRAY_COUNT(*gCurrentAnimMeshListPtr); i++) {
307 if ((*gCurrentAnimMeshListPtr)[i] == animator) {
308 (*gCurrentAnimMeshListPtr)[i] = nullptr;
309 break;
310 }
311 }
312
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 794 of file animator.c.

794 {
797 RenderTask* rtPtr = &rt;
798
800 return;
801 }
802
804 animator = (*gCurrentAnimMeshListPtr)[animatorID];
805
806 if (animator == nullptr || animator->flags == 0) {
807 return;
808 }
809
811 && animator->flags & (1 << gCurrentCamID)
813 ) {
814 animator->mtx = *rootTransform;
816 animator->baseAddr = baseAddr;
818 rtPtr->appendGfx = (void (*)(void*))appendGfx_animator;
819 rtPtr->dist = 0;
820 rtPtr->renderMode = animator->renderMode;
822 }
823}
BSS s32 gAnimVtxSegment
Definition animator.c:26

Referenced by render_entities(), and render_shadows().

◆ appendGfx_animator()

void appendGfx_animator ( ModelAnimator * animator)

Definition at line 825 of file animator.c.

825 {
827
828 if (animator->baseAddr != nullptr) {
830 }
831
834
835 //TODO find better match
836 switch (gAnimModelFogEnabled != 0) {
837 case false:
838 switch (animator->renderMode) {
841 break;
844 break;
847 break;
850 break;
853 break;
856 break;
859 break;
860 }
861 break;
862 case true:
863 switch (animator->renderMode) {
866 break;
869 break;
872 break;
875 break;
878 break;
881 break;
884 break;
885 }
886
889 break;
890 }
891
892 guMtxL2F(sp10, &animator->mtx);
895}
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:897
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:3302
@ RENDER_MODE_INTERSECTING_XLU
Definition enums.h:3337
@ RENDER_MODE_DECAL_XLU
Definition enums.h:3325
@ RENDER_MODE_INTERSECTING_OPA
Definition enums.h:3306
@ RENDER_MODE_ALPHATEST
Definition enums.h:3310
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3298
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3316
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:46
Gfx * gMainGfxPos
Definition cam_main.c:14
u16 gMatrixListPos
Definition main_loop.c:44
DisplayContext * gDisplayContext
Definition cam_main.c:15

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 1044 of file animator.c.

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

Referenced by render_entities().

◆ reload_mesh_animator_tree()

void reload_mesh_animator_tree ( ModelAnimator * animator)

Definition at line 1257 of file animator.c.

1257 {
1258 s32 nodeIDs[ARRAY_COUNT(animator->staticNodeIDs)];
1259 s32 i;
1260
1262 gAnimTreeRoot = animator->staticRoot;
1263
1264 for (i = 0; i < ARRAY_COUNT(animator->staticNodes); i++) {
1265 nodeIDs[i] = 0;
1266 }
1267
1268 reload_mesh_animator_node(animator->staticNodes[animator->treeIndexPos], animator, 0, nodeIDs);
1269 nodeIDs[0] = -1;
1271}
void set_animator_tree_to_node_map(ModelAnimator *animator, s32 *nodeIDs, s32 count)
Definition animator.c:1031
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:1225
BSS StaticAnimatorNode ** gAnimTreeRoot
Definition animator.c:31

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 1273 of file animator.c.

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

3845 {
3846 (*gCurrentCustomModelGfxBuildersPtr)[customGfxIndex * 2] = pre;
3847 (*gCurrentCustomModelGfxBuildersPtr)[customGfxIndex * 2 + 1] = post;
3848}

◆ mdl_make_local_vertex_copy()

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

Definition at line 4035 of file model.c.

4035 {
4036 s32 numVertices;
4037 Vtx* baseVtx;
4038 s32 gfxCount;
4039 Gfx* nodeDlist;
4040 Model* model;
4042 s32 i;
4043
4045 nodeDlist = model->modelNode->displayData->displayList;
4046 mdl_get_vertex_count(nodeDlist, &numVertices, &baseVtx, &gfxCount, nullptr);
4047
4048 copy = (*gCurrentModelLocalVtxBuffers)[copyIndex] = heap_malloc(sizeof(*copy));
4049
4050 if (isMakingCopy) {
4051 for (i = 0; i < ARRAY_COUNT(copy->gfxCopy); i++) {
4052 copy->gfxCopy[i] = heap_malloc(gfxCount * sizeof(*copy->gfxCopy[i]));
4053 copy->vtxCopy[i] = heap_malloc(numVertices * sizeof(*copy->vtxCopy[i]));
4054 mdl_local_gfx_update_vtx_pointers(nodeDlist, baseVtx, copy->gfxCopy[i], copy->vtxCopy[i]);
4055 mdl_local_gfx_copy_vertices(baseVtx, numVertices, copy->vtxCopy[i]);
4056 }
4058 } else {
4059 for (i = 0; i < ARRAY_COUNT(copy->gfxCopy); i++) {
4060 copy->gfxCopy[i] = nullptr;
4061 copy->vtxCopy[i] = nullptr;
4062 }
4063 model->flags |= MODEL_FLAG_HIDDEN;
4064 }
4065
4066 copy->selector = 0;
4067 copy->numVertices = numVertices;
4068 copy->minVertexAddr = baseVtx;
4069}
@ MODEL_FLAG_HAS_LOCAL_VERTEX_COPY
Definition enums.h:3949
@ MODEL_FLAG_HIDDEN
Definition enums.h:3943
void * heap_malloc(s32 size)
Definition heap.c:34
void mdl_local_gfx_copy_vertices(Vtx *src, s32 num, Vtx *dest)
Definition model.c:4027
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3393
void mdl_get_vertex_count(Gfx *gfx, s32 *numVertices, Vtx **baseVtx, s32 *gfxCount, Vtx *baseAddr)
Definition model.c:3959
Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3312
void mdl_local_gfx_update_vtx_pointers(Gfx *nodeDlist, Vtx *baseVtx, Gfx *arg2, Vtx *arg3)
Definition model.c:4011

◆ play_model_animation_starting_from()

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

Definition at line 1112 of file animator.c.

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

◆ mdl_set_shroud_tint_params()

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

Definition at line 3902 of file model.c.

3902 {
3903 ShroudTintR = r;
3904 ShroudTintG = g;
3905 ShroudTintB = b;
3906 ShroudTintAmt = a;
3907}
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