Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
entity_model.c File Reference

Go to the source code of this file.

Functions

s32 step_entity_model_commandlist (EntityModel *entityModel)
 
void free_entity_model_by_ref (EntityModel *entityModel)
 
void clear_entity_models (void)
 
void init_entity_models (void)
 
s32 load_entity_model (EntityModelScript *cmdList)
 
s32 ALT_load_entity_model (EntityModelScript *cmdList)
 
void exec_entity_model_commandlist (s32 idx)
 
void make_entity_model_mtx_flipZ (Matrix4f mtx)
 
void appendGfx_entity_model (EntityModel *model)
 
void draw_entity_model_A (s32 modelIdx, Mtx *transformMtx)
 
void draw_entity_model_B (s32 modelIdx, Mtx *transformMtx, s32 vertexSegment, Vec3s *vertexArray)
 
void draw_entity_model_C (s32 modelIdx, Mtx *transformMtx)
 
void draw_entity_model_D (s32 modelIdx, Mtx *transformMtx, s32 arg2, Vec3s *vertexArray)
 
void draw_entity_model_E (s32 modelIdx, Mtx *transformMtx)
 
void set_entity_model_render_command_list (s32 idx, EntityModelScript *cmdList)
 
EntityModelget_entity_model (s32 listIndex)
 
void free_entity_model_by_index (s32 idx)
 
void set_entity_model_flags (s32 idx, s32 newFlags)
 
void clear_entity_model_flags (s32 idx, s32 newFlags)
 
void bind_entity_model_setupGfx (s32 idx, void *setupGfxCallbackArg0, void(*fpSetupGfxCallback)(void *))
 
void func_80122F8C (s32 idx, s32 newFlags)
 
void func_80122FB8 (s32 idx, s32 newFlags)
 
void enable_entity_fog (void)
 
void disable_entity_fog (void)
 
void set_entity_fog_dist (s32 min, s32 max)
 
void set_entity_fog_color (s32 r, s32 g, s32 b, s32 a)
 
s32 is_entity_fog_enabled (void)
 
void get_entity_fog_distance (s32 *start, s32 *end)
 
void get_entity_fog_color (s32 *r, s32 *g, s32 *b, s32 *a)
 

Variables

EntityModelScript D_8014C260
 
Lights1 D_8014C268 = gdSPDefLights1(255, 255, 255, 0, 0, 0, 0, 0, 0)
 
s32 gEntityModelCount
 
BSS EntityModelList gWorldEntityModelList
 
BSS EntityModelList gBattleEntityModelList
 
BSS EntityModelListgCurrentEntityModelList
 
BSS s32 D_80154374
 
BSS s32 entity_fog_enabled
 
BSS s32 entity_fog_red
 
BSS s32 entity_fog_green
 
BSS s32 entity_fog_blue
 
BSS s32 entity_fog_alpha
 
BSS s32 entity_fog_dist_min
 
BSS s32 entity_fog_dist_max
 
Gfx Gfx_RM1_SURFACE_OPA []
 
Gfx Gfx_RM1_DECAL_OPA []
 
Gfx Gfx_RM1_INTERSECTING_OPA []
 
Gfx Gfx_RM1_ALPHATEST []
 
Gfx Gfx_RM1_SURFACE_XLU []
 
Gfx Gfx_RM1_DECAL_XLU []
 
Gfx Gfx_RM1_INTERSECTING_XLU []
 
Gfx Gfx_RM1_ALPHATEST_ONESIDED []
 
Gfx Gfx_RM1_SURFACE_XLU_NO_AA []
 
Gfx Gfx_RM1_DECAL_XLU_NO_AA []
 
Gfx Gfx_RM1_PASS_THROUGH []
 
Gfx Gfx_RM1_SURFACE_OPA_NO_ZB []
 
Gfx Gfx_RM1_ALPHATEST_NO_ZB []
 
Gfx Gfx_RM1_SURFACE_XLU_NO_ZB []
 
Gfx Gfx_RM1_CLOUD_NO_ZCMP []
 
Gfx Gfx_RM3_SURFACE_OPA []
 
Gfx Gfx_RM3_DECAL_OPA []
 
Gfx Gfx_RM3_INTERSECTING_OPA []
 
Gfx Gfx_RM3_ALPHATEST []
 
Gfx Gfx_RM3_SURFACE_XLU []
 
Gfx Gfx_RM3_DECAL_XLU []
 
Gfx Gfx_RM3_INTERSECTING_XLU []
 

Function Documentation

◆ step_entity_model_commandlist()

s32 step_entity_model_commandlist ( EntityModel * entityModel)

Definition at line 191 of file entity_model.c.

191 {
192 SpriteRasterInfo* imageData;
193
194 u32* curPos = *entityModel->cmdListReadPos;
195 switch (*curPos++) {
196 case ENTITY_MODEL_SCRIPT_OP_End: // kill model
198 return 1;
199 case ENTITY_MODEL_SCRIPT_OP_Draw: // set display list ptr
200 entityModel->nextFrameTime = (f32) *curPos++;
201 entityModel->gfx.displayList = (Gfx*) *curPos++;
202 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
203 break;
204 case ENTITY_MODEL_SCRIPT_OP_Restart: // restore saved position
205 entityModel->cmdListReadPos = entityModel->cmdListSavedPos;
206 return 1;
207 case ENTITY_MODEL_SCRIPT_OP_Loop: // set saved position
208 entityModel->cmdListReadPos = entityModel->cmdListSavedPos = (EntityModelScript*) curPos;
209 return 1;
210 case ENTITY_MODEL_SCRIPT_OP_SetRenderMode: // set render mode
211 entityModel->renderMode = *curPos++;
212 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
213 return 1;
214 case ENTITY_MODEL_SCRIPT_OP_SetFlags: // set flags
215 entityModel->flags |= *curPos++;
216 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
217 return 1;
218 case ENTITY_MODEL_SCRIPT_OP_ClearFlags: // clear flags
219 entityModel->flags &= ~*curPos++;
220 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
221 return 1;
222 case ENTITY_MODEL_SCRIPT_OP_DrawImage: // set image data
223 imageData = entityModel->gfx.imageData;
224 entityModel->nextFrameTime = *curPos++;
225 imageData->raster = (u8*)*curPos++;
226 imageData->defaultPal = (PAL_PTR) *curPos++;
227 imageData->width = *curPos++;
228 imageData->height = *curPos++;
229 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
230 break;
231 }
232 return 0;
233}
BSS s32 PopupMenu_SelectedIndex
#define PAL_PTR
s32 EntityModelScript[]
Definition entity.h:7
@ ENTITY_MODEL_SCRIPT_OP_SetFlags
Definition entity.h:30
@ ENTITY_MODEL_SCRIPT_OP_Draw
Definition entity.h:26
@ ENTITY_MODEL_SCRIPT_OP_Loop
Definition entity.h:28
@ ENTITY_MODEL_SCRIPT_OP_SetRenderMode
Definition entity.h:29
@ ENTITY_MODEL_SCRIPT_OP_Restart
Definition entity.h:27
@ ENTITY_MODEL_SCRIPT_OP_End
Definition entity.h:25
@ ENTITY_MODEL_SCRIPT_OP_DrawImage
Definition entity.h:32
@ ENTITY_MODEL_SCRIPT_OP_ClearFlags
Definition entity.h:31
void free_entity_model_by_ref(EntityModel *entityModel)

Referenced by exec_entity_model_commandlist().

◆ free_entity_model_by_ref()

void free_entity_model_by_ref ( EntityModel * entityModel)

Definition at line 743 of file entity_model.c.

743 {
744 s32 i;
745
746 for (i = 0; i < MAX_ENTITY_MODELS; i++) {
748 break;
749 }
750 }
751
752 if (i < MAX_ENTITY_MODELS) {
754 }
755}
BSS EntityModelList * gCurrentEntityModelList
void free_entity_model_by_index(s32 idx)
#define MAX_ENTITY_MODELS
Definition macros.h:86

Referenced by step_entity_model_commandlist().

◆ clear_entity_models()

void clear_entity_models ( void )

Definition at line 51 of file entity_model.c.

51 {
52 s32 i;
53
56 } else {
58 }
59
60 for (i = 0; i < MAX_ENTITY_MODELS; i++) {
61 (*gCurrentEntityModelList)[i] = nullptr;
62 }
63
66 entity_fog_red = 10;
68 entity_fog_blue = 10;
72}
BSS s32 entity_fog_blue
BSS EntityModelList gBattleEntityModelList
BSS s32 entity_fog_red
BSS s32 entity_fog_dist_max
s32 gEntityModelCount
BSS s32 entity_fog_green
BSS s32 entity_fog_dist_min
BSS s32 entity_fog_enabled
BSS s32 entity_fog_alpha
BSS EntityModelList gWorldEntityModelList
@ CONTEXT_WORLD
Definition enums.h:3562
GameStatus * gGameStatusPtr
Definition main_loop.c:31

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), state_step_startup(), and state_step_title_screen().

◆ init_entity_models()

void init_entity_models ( void )

◆ load_entity_model()

s32 load_entity_model ( EntityModelScript * cmdList)

Definition at line 92 of file entity_model.c.

92 {
95 s32 i;
96
97 for (i = 0; i < MAX_ENTITY_MODELS; i++) {
98 if ((*gCurrentEntityModelList)[i] == nullptr) {
99 break;
100 }
101 }
103
104 (*gCurrentEntityModelList)[i] = newEntityModel = heap_malloc(sizeof(*newEntityModel));
106 (*entityModelCount)++;
107
108 ASSERT(newEntityModel != nullptr);
109
111 newEntityModel->renderMode = 1;
112 newEntityModel->gfx.displayList = nullptr;
113 newEntityModel->cmdListReadPos = cmdList;
114 newEntityModel->nextFrameTime = 1.0f;
115 newEntityModel->timeScale = 1.0f;
116 if (cmdList == nullptr) {
117 newEntityModel->cmdListReadPos = &D_8014C260;
118 }
119 newEntityModel->vertexArray = nullptr;
120 newEntityModel->fpSetupGfxCallback = nullptr;
121 newEntityModel->cmdListSavedPos = newEntityModel->cmdListReadPos;
122
125 }
126 return i;
127}
#define ASSERT(condition)
EntityModelScript D_8014C260
Definition entity_model.c:4
@ ENTITY_MODEL_FLAG_CAM1
Definition enums.h:4596
@ ENTITY_MODEL_FLAG_CAM2
Definition enums.h:4597
@ ENTITY_MODEL_FLAG_CAM0
Definition enums.h:4595
@ ENTITY_MODEL_FLAG_ENABLED
Definition enums.h:4599
void * heap_malloc(s32 size)
Definition heap.c:34
#define BATTLE_ENTITY_ID_BIT
Definition macros.h:157

Referenced by create_entity(), create_shadow_from_data(), show_immune_bonk(), virtual_entity_create(), and virtual_entity_create_at_index().

◆ ALT_load_entity_model()

s32 ALT_load_entity_model ( EntityModelScript * cmdList)

Definition at line 129 of file entity_model.c.

129 {
131 SpriteRasterInfo* imageData;
132 s32 i;
133
134 for (i = 0; i < MAX_ENTITY_MODELS; i++) {
135 if ((*gCurrentEntityModelList)[i] == nullptr) {
136 break;
137 }
138 }
140
141 {
143 (*gCurrentEntityModelList)[i] = newEntityModel = heap_malloc(sizeof(*newEntityModel));
145 (*entityModelCount)++;
146 }
147
148 ASSERT(newEntityModel != nullptr);
149
150 newEntityModel->gfx.imageData = imageData = heap_malloc(sizeof(*imageData));
151 ASSERT(imageData != nullptr);
152
154 newEntityModel->renderMode = 1;
155 newEntityModel->cmdListReadPos = cmdList;
156 newEntityModel->nextFrameTime = 1.0f;
157 newEntityModel->timeScale = 1.0f;
158 if (cmdList == nullptr) {
159 newEntityModel->cmdListReadPos = &D_8014C260;
160 }
161 newEntityModel->vertexArray = nullptr;
162 newEntityModel->fpSetupGfxCallback = nullptr;
163 newEntityModel->cmdListSavedPos = newEntityModel->cmdListReadPos;
164
167 }
168 return i;
169}
@ ENTITY_MODEL_FLAG_USE_IMAGE
Definition enums.h:4605

Referenced by ALT_virtual_entity_create().

◆ exec_entity_model_commandlist()

void exec_entity_model_commandlist ( s32 idx)

Definition at line 171 of file entity_model.c.

171 {
173
176 entityModel = (*gCurrentEntityModelList)[idx];
177 if (entityModel != nullptr && (entityModel->flags)) {
178 if (!(entityModel->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
181 entityModel->nextFrameTime -= entityModel->timeScale;
182 if (entityModel->nextFrameTime <= 0.0f) {
184 }
185 }
186 }
187 }
188 }
189}
s32 step_entity_model_commandlist(EntityModel *entityModel)
@ ENTITY_MODEL_FLAG_DISABLE_SCRIPT
Definition enums.h:4612
@ ENTITY_MODEL_FLAG_HIDDEN
Definition enums.h:4600
s32 flags
Definition entity.h:448

Referenced by ALT_virtual_entity_create(), btl_bonk_update(), create_entity(), update_entities(), update_shadows(), virtual_entity_create(), virtual_entity_create_at_index(), and virtual_entity_list_update().

◆ make_entity_model_mtx_flipZ()

void make_entity_model_mtx_flipZ ( Matrix4f mtx)

Definition at line 235 of file entity_model.c.

235 {
236 guMtxIdentF(mtx);
237 mtx[0][0] = 1.0f;
238 mtx[1][1] = 1.0f;
239 mtx[2][2] = -1.0f;
240 mtx[3][3] = 1.0f;
241}

Referenced by appendGfx_entity_model(), and draw_entity_model_E().

◆ appendGfx_entity_model()

void appendGfx_entity_model ( EntityModel * model)

Definition at line 243 of file entity_model.c.

243 {
244 Matrix4f mtx;
248
251 if (!(model->flags & ENTITY_MODEL_FLAG_USE_IMAGE)) {
252 if (!(model->flags & ENTITY_MODEL_FLAG_10000)) {
255 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, 255);
259
261 case false:
262 switch (model->renderMode) {
265 break;
268 break;
271 break;
274 break;
279 break;
282 break;
286 break;
290 break;
293 break;
296 break;
299 break;
303 break;
307 break;
311 break;
314 break;
315 }
316 break;
317 case true:
318 switch (model->renderMode) {
321 break;
324 break;
327 break;
330 break;
333 break;
336 break;
339 break;
340 }
343 break;
344 }
348 } else {
350 }
351 }
352 if (model->vertexArray != nullptr) {
354 }
356
357 if (model->fpSetupGfxCallback != nullptr) {
358 model->fpSetupGfxCallback(model->setupGfxCallbackArg0);
359 }
361
362 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
365
366 if (!(model->flags & ENTITY_MODEL_FLAG_REFLECT)) {
367 return;
368 }
369
370 guMtxL2F(mtx, &model->transform);
372 guMtxCatF(mtx, mtx2, mtx);
373 guMtxF2L(mtx, &model->transform);
376 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
377 } else {
378 SpriteRasterInfo* imageData;
379
387
388 imageData = model->gfx.imageData;
389 ifxImg.raster = imageData->raster;
390 ifxImg.palette = imageData->defaultPal;
391 ifxImg.width = imageData->width;
392 ifxImg.height = imageData->height;
393 ifxImg.xOffset = -imageData->width / 2;
394 ifxImg.yOffset = imageData->height / 2;
395 ifxImg.alpha = 255;
396 guMtxL2F(imgfxMtx, &model->transform);
398 }
399
402}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guMtxF2L
#define guMtxCatF
Gfx Gfx_RM3_SURFACE_OPA[]
Definition model.c:1067
void make_entity_model_mtx_flipZ(Matrix4f mtx)
Gfx Gfx_RM3_DECAL_XLU[]
Definition model.c:1117
Gfx Gfx_RM3_DECAL_OPA[]
Definition model.c:1077
Gfx Gfx_RM1_SURFACE_XLU[]
Definition model.c:686
Gfx Gfx_RM1_DECAL_XLU[]
Definition model.c:696
Gfx Gfx_RM1_ALPHATEST_ONESIDED[]
Definition model.c:746
BSS s32 D_80154374
Lights1 D_8014C268
Definition entity_model.c:8
Gfx Gfx_RM1_SURFACE_XLU_NO_AA[]
Definition model.c:756
Gfx Gfx_RM1_DECAL_OPA[]
Definition model.c:654
Gfx Gfx_RM1_ALPHATEST[]
Definition model.c:676
Gfx Gfx_RM1_INTERSECTING_XLU[]
Definition model.c:706
Gfx Gfx_RM1_SURFACE_OPA[]
Definition model.c:643
Gfx Gfx_RM3_INTERSECTING_XLU[]
Definition model.c:1127
Gfx Gfx_RM1_ALPHATEST_NO_ZB[]
Definition model.c:810
Gfx Gfx_RM3_INTERSECTING_OPA[]
Definition model.c:1087
Gfx Gfx_RM1_CLOUD_NO_ZCMP[]
Definition model.c:844
Gfx Gfx_RM3_ALPHATEST[]
Definition model.c:1097
Gfx Gfx_RM1_SURFACE_OPA_NO_ZB[]
Definition model.c:800
Gfx Gfx_RM1_DECAL_XLU_NO_AA[]
Definition model.c:766
Gfx Gfx_RM1_PASS_THROUGH[]
Definition model.c:779
Gfx Gfx_RM1_SURFACE_XLU_NO_ZB[]
Definition model.c:820
Gfx Gfx_RM1_INTERSECTING_OPA[]
Definition model.c:665
Gfx Gfx_RM3_SURFACE_XLU[]
Definition model.c:1107
@ ENTITY_MODEL_FLAG_FOG_DISABLED
Definition enums.h:4606
@ ENTITY_MODEL_FLAG_10000
Definition enums.h:4611
@ ENTITY_MODEL_FLAG_REFLECT
Definition enums.h:4604
@ RENDER_MODE_ALPHATEST_ONESIDED
Definition enums.h:3312
@ RENDER_MODE_SURFACE_OPA_NO_ZB
Definition enums.h:3301
@ RENDER_MODE_DECAL_OPA
Definition enums.h:3302
@ RENDER_MODE_SURFACE_XLU_LAYER3
Definition enums.h:3333
@ RENDER_MODE_DECAL_XLU_NO_AA
Definition enums.h:3327
@ RENDER_MODE_SURFACE_XLU_LAYER2
Definition enums.h:3321
@ RENDER_MODE_SURFACE_XLU_NO_AA
Definition enums.h:3318
@ RENDER_MODE_INTERSECTING_XLU
Definition enums.h:3337
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3340
@ RENDER_MODE_DECAL_XLU
Definition enums.h:3325
@ RENDER_MODE_SHADOW
Definition enums.h:3331
@ RENDER_MODE_SURFACE_XLU_NO_ZB
Definition enums.h:3319
@ RENDER_MODE_SURFACE_XLU_NO_ZB_BEHIND
Definition enums.h:3344
@ RENDER_MODE_SURFACE_OPA_NO_ZB_BEHIND
Definition enums.h:3342
@ RENDER_MODE_DECAL_XLU_AHEAD
Definition enums.h:3329
@ RENDER_MODE_ALPHATEST_NO_ZB_BEHIND
Definition enums.h:3343
@ 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_ALPHATEST_NO_ZB
Definition enums.h:3313
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3316
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3345
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:705
#define PM_CC2_MULTIPLY_SHADE
Definition macros.h:320
#define PM_CC_42
Definition macros.h:479
#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 draw_entity_model_A(), draw_entity_model_B(), draw_entity_model_C(), and draw_entity_model_D().

◆ draw_entity_model_A()

void draw_entity_model_A ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 404 of file entity_model.c.

404 {
407 RenderTask* rtPtr = &rt;
409 Matrix4f mtx;
410 f32 x, y, z, w;
411 f32 inX, inY, inZ;
412
415 model = (*gCurrentEntityModelList)[modelIdx];
416
417 if (model != nullptr) {
418 if (model->flags != 0) {
419 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
420 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
421 if (!(model->flags & ENTITY_MODEL_FLAG_40) && (model->flags & (1 << gCurrentCamID))) {
422 model->transform = *transformMtx;
423 model->vertexArray = nullptr;
424 guMtxL2F(mtx, transformMtx);
425 inX = mtx[3][0];
426 inY = mtx[3][1];
427 inZ = mtx[3][2];
428 transform_point(camera->mtxPerspective, inX, inY, inZ, 1.0f, &x, &y, &z, &w);
429 rtPtr->renderMode = model->renderMode;
430 rtPtr->appendGfxArg = model;
431 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
432 rtPtr->dist = ((u32)(model->flags & 0xF000) >> 8) + inZ;
434 }
435 }
436 }
437 }
438 }
439 }
440}
#define transform_point
#define queue_render_task
void appendGfx_entity_model(EntityModel *model)
@ ENTITY_MODEL_FLAG_100
Definition enums.h:4603
@ ENTITY_MODEL_FLAG_40
Definition enums.h:4601
Camera gCameras[4]
Definition cam_main.c:16
s16 gCurrentCamID
Definition cam_main.c:12

Referenced by btl_bonk_render(), render_entities(), render_shadows(), and virtual_entity_list_render_world().

◆ draw_entity_model_B()

void draw_entity_model_B ( s32 modelIdx,
Mtx * transformMtx,
s32 vertexSegment,
Vec3s * vertexArray )

Definition at line 442 of file entity_model.c.

442 {
445 RenderTask* rtPtr = &rt;
447 Matrix4f mtx;
448 f32 x, y, z, w;
449 f32 inX, inY, inZ;
450
453 model = (*gCurrentEntityModelList)[modelIdx];
454
455 if (model != nullptr) {
456 if (model->flags != 0) {
457 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
458 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
459 if (model->flags & (1 << gCurrentCamID)) {
460 model->transform = *transformMtx;
461 D_80154374 = vertexSegment;
462 model->vertexArray = vertexArray;
463 guMtxL2F(mtx, transformMtx);
464 inX = mtx[3][0];
465 inY = mtx[3][1];
466 inZ = mtx[3][2];
467 transform_point(camera->mtxPerspective, inX, inY, inZ, 1.0f, &x, &y, &z, &w);
468 rtPtr->renderMode = model->renderMode;
469 rtPtr->appendGfxArg = model;
470 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
471 rtPtr->dist = ((u32)(model->flags & 0xF000) >> 8) + inZ;
473 }
474 }
475 }
476 }
477 }
478 }
479}

Referenced by render_entities(), and render_shadows().

◆ draw_entity_model_C()

void draw_entity_model_C ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 481 of file entity_model.c.

481 {
484 RenderTask* rtPtr = &rt;
485
488 model = (*gCurrentEntityModelList)[modelIdx];
489
490 if (model != nullptr) {
491 if (model->flags != 0) {
492 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
493 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
494 if (!(model->flags & ENTITY_MODEL_FLAG_40) && (model->flags & (1 << gCurrentCamID))) {
496 model->transform = *transformMtx;
497 model->vertexArray = nullptr;
498 rtPtr->renderMode = model->renderMode;
499 rtPtr->appendGfxArg = model;
500 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
501 rtPtr->dist = (u32)(model->flags & 0xF000) >> 8;
503 }
504 }
505 }
506 }
507 }
508 }
509}

◆ draw_entity_model_D()

void draw_entity_model_D ( s32 modelIdx,
Mtx * transformMtx,
s32 arg2,
Vec3s * vertexArray )

Definition at line 511 of file entity_model.c.

511 {
514 RenderTask* rtPtr = &rt;
515
518 model = (*gCurrentEntityModelList)[modelIdx];
519
520 if (model != nullptr) {
521 if (model->flags != 0) {
522 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
523 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
524 if (model->flags & (1 << gCurrentCamID)) {
526 model->transform = *transformMtx;
527 D_80154374 = arg2;
528 model->vertexArray = vertexArray;
529 rtPtr->renderMode = model->renderMode;
530 rtPtr->appendGfxArg = model;
531 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
532 rtPtr->dist = (u32)(model->flags & 0xF000) >> 8;
534 }
535 }
536 }
537 }
538 }
539 }
540}

◆ draw_entity_model_E()

void draw_entity_model_E ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 542 of file entity_model.c.

542 {
543 EntityModel* model = (*gCurrentEntityModelList)[modelIdx & ~BATTLE_ENTITY_ID_BIT];
544 Matrix4f mtx;
548
549 if (model == nullptr) {
550 return;
551 }
552 if (model->flags == 0) {
553 return;
554 }
555 if (model->flags & ENTITY_MODEL_FLAG_100) {
556 return;
557 }
558 if (model->flags & ENTITY_MODEL_FLAG_HIDDEN) {
559 return;
560 }
561 if (model->flags & ENTITY_MODEL_FLAG_40) {
562 return;
563 }
564 if (!(model->flags & ENTITY_MODEL_FLAG_CAM3)) {
565 return;
566 }
567
568 model->transform = *transformMtx;
569 model->vertexArray = nullptr;
572 if (!(model->flags & ENTITY_MODEL_FLAG_USE_IMAGE)) {
574 case false:
575 switch (model->renderMode) {
578 break;
581 break;
584 break;
587 break;
592 break;
595 break;
599 break;
603 break;
606 break;
609 break;
612 break;
616 break;
620 break;
624 break;
627 break;
628 }
629 break;
630 case true:
631 switch (model->renderMode) {
634 break;
637 break;
640 break;
643 break;
646 break;
649 break;
652 break;
653 }
656 break;
657 }
661 } else {
663 }
664 if (model->vertexArray != nullptr) {
666 }
667 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
670 if (!(model->flags & ENTITY_MODEL_FLAG_REFLECT)) {
671 return;
672 }
673
674 guMtxL2F(mtx, &model->transform);
676 guMtxCatF(mtx, mtx2, mtx);
677 guMtxF2L(mtx, &model->transform);
680 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
681 } else {
682 SpriteRasterInfo* imageData;
683
691
692 imageData = model->gfx.imageData;
693 ifxImg.raster = imageData->raster;
694 ifxImg.palette = imageData->defaultPal;
695 ifxImg.width = imageData->width;
696 ifxImg.height = imageData->height;
697 ifxImg.xOffset = -imageData->width / 2;
698 ifxImg.yOffset = imageData->height / 2;
699 ifxImg.alpha = 255;
700 guMtxL2F(imgfxMtx, &model->transform);
702 }
703
706}
@ ENTITY_MODEL_FLAG_CAM3
Definition enums.h:4598

Referenced by virtual_entity_list_render_UI().

◆ set_entity_model_render_command_list()

void set_entity_model_render_command_list ( s32 idx,
EntityModelScript * cmdList )

Definition at line 708 of file entity_model.c.

708 {
709 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
710
711 if (entityModel != nullptr && entityModel->flags) {
712 if (cmdList == nullptr) {
713 cmdList = &D_8014C260;
714 }
715 entityModel->cmdListReadPos = cmdList;
716 entityModel->cmdListSavedPos = cmdList;
717 entityModel->nextFrameTime = 1.0f;
718 entityModel->timeScale = 1.0f;
719 }
720}
EntityModelScript * cmdListReadPos
Definition entity.h:455

Referenced by entity_set_render_script().

◆ get_entity_model()

EntityModel * get_entity_model ( s32 listIndex)

◆ free_entity_model_by_index()

void free_entity_model_by_index ( s32 idx)

Definition at line 726 of file entity_model.c.

726 {
727 s32 index = idx & ~BATTLE_ENTITY_ID_BIT;
728 EntityModel* entityModel = (*gCurrentEntityModelList)[index];
729
730 if (entityModel != nullptr && entityModel->flags) {
732 heap_free(entityModel->gfx.imageData);
733 }
734 {
737 (*gCurrentEntityModelList)[index] = nullptr;
738 (*modelCount)--;
739 }
740 }
741}
s32 heap_free(void *ptr)
Definition heap.c:42

Referenced by btl_bonk_update(), delete_entity(), delete_entity_and_unload_data(), delete_shadow(), free_entity_model_by_ref(), and virtual_entity_delete_by_index().

◆ set_entity_model_flags()

void set_entity_model_flags ( s32 idx,
s32 newFlags )

Definition at line 757 of file entity_model.c.

757 {
758 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
759
760 if (entityModel != nullptr && entityModel->flags) {
762 }
763}

Referenced by show_immune_bonk().

◆ clear_entity_model_flags()

void clear_entity_model_flags ( s32 idx,
s32 newFlags )

Definition at line 765 of file entity_model.c.

765 {
766 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
767
768 if (entityModel != nullptr && entityModel->flags) {
770 }
771}

Referenced by btl_bonk_update().

◆ bind_entity_model_setupGfx()

void bind_entity_model_setupGfx ( s32 idx,
void * setupGfxCallbackArg0,
void(*)(void *) fpSetupGfxCallback )

Definition at line 773 of file entity_model.c.

773 {
774 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
775
776 entityModel->fpSetupGfxCallback = fpSetupGfxCallback;
777 entityModel->setupGfxCallbackArg0 = setupGfxCallbackArg0;
778}
void(* fpSetupGfxCallback)(void *)
Definition entity.h:463

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

◆ func_80122F8C()

void func_80122F8C ( s32 idx,
s32 newFlags )

Definition at line 780 of file entity_model.c.

780 {
781 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
782
784}

◆ func_80122FB8()

void func_80122FB8 ( s32 idx,
s32 newFlags )

Definition at line 786 of file entity_model.c.

◆ enable_entity_fog()

void enable_entity_fog ( void )

Definition at line 792 of file entity_model.c.

792 {
794}

◆ disable_entity_fog()

void disable_entity_fog ( void )

Definition at line 796 of file entity_model.c.

796 {
798}

◆ set_entity_fog_dist()

void set_entity_fog_dist ( s32 min,
s32 max )

Definition at line 800 of file entity_model.c.

800 {
803}

◆ set_entity_fog_color()

void set_entity_fog_color ( s32 r,
s32 g,
s32 b,
s32 a )

Definition at line 805 of file entity_model.c.

805 {
806 entity_fog_red = r;
808 entity_fog_blue = b;
810}

◆ is_entity_fog_enabled()

s32 is_entity_fog_enabled ( void )

Definition at line 812 of file entity_model.c.

812 {
813 return entity_fog_enabled;
814}

◆ get_entity_fog_distance()

void get_entity_fog_distance ( s32 * start,
s32 * end )

Definition at line 816 of file entity_model.c.

816 {
817 *start = entity_fog_dist_min;
818 *end = entity_fog_dist_max;
819}

◆ get_entity_fog_color()

void get_entity_fog_color ( s32 * r,
s32 * g,
s32 * b,
s32 * a )

Definition at line 821 of file entity_model.c.

821 {
822 *r = entity_fog_red;
823 *g = entity_fog_green;
824 *b = entity_fog_blue;
825 *a = entity_fog_alpha;
826}

Variable Documentation

◆ D_8014C260

EntityModelScript D_8014C260
Initial value:
= {
}
#define ems_End
Definition entity.h:47

Definition at line 4 of file entity_model.c.

4 {
7};

Referenced by ALT_load_entity_model(), load_entity_model(), and set_entity_model_render_command_list().

◆ D_8014C268

Lights1 D_8014C268 = gdSPDefLights1(255, 255, 255, 0, 0, 0, 0, 0, 0)

Definition at line 8 of file entity_model.c.

Referenced by appendGfx_entity_model(), and draw_entity_model_E().

◆ gEntityModelCount

◆ gWorldEntityModelList

BSS EntityModelList gWorldEntityModelList

Definition at line 12 of file entity_model.c.

Referenced by clear_entity_models(), and init_entity_models().

◆ gBattleEntityModelList

BSS EntityModelList gBattleEntityModelList

Definition at line 13 of file entity_model.c.

Referenced by clear_entity_models(), and init_entity_models().

◆ gCurrentEntityModelList

◆ D_80154374

◆ entity_fog_enabled

◆ entity_fog_red

◆ entity_fog_green

◆ entity_fog_blue

◆ entity_fog_alpha

◆ entity_fog_dist_min

◆ entity_fog_dist_max

◆ Gfx_RM1_SURFACE_OPA

◆ Gfx_RM1_DECAL_OPA

◆ Gfx_RM1_INTERSECTING_OPA

◆ Gfx_RM1_ALPHATEST

◆ Gfx_RM1_SURFACE_XLU

◆ Gfx_RM1_DECAL_XLU

◆ Gfx_RM1_INTERSECTING_XLU

◆ Gfx_RM1_ALPHATEST_ONESIDED

◆ Gfx_RM1_SURFACE_XLU_NO_AA

◆ Gfx_RM1_DECAL_XLU_NO_AA

◆ Gfx_RM1_PASS_THROUGH

◆ Gfx_RM1_SURFACE_OPA_NO_ZB

◆ Gfx_RM1_ALPHATEST_NO_ZB

◆ Gfx_RM1_SURFACE_XLU_NO_ZB

◆ Gfx_RM1_CLOUD_NO_ZCMP

◆ Gfx_RM3_SURFACE_OPA

◆ Gfx_RM3_DECAL_OPA

◆ Gfx_RM3_INTERSECTING_OPA

◆ Gfx_RM3_ALPHATEST

◆ Gfx_RM3_SURFACE_XLU

◆ Gfx_RM3_DECAL_XLU

◆ Gfx_RM3_INTERSECTING_XLU