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 192 of file entity_model.c.

192 {
193 SpriteRasterInfo* imageData;
194
195 u32* curPos = *entityModel->cmdListReadPos;
196 switch (*curPos++) {
197 case ENTITY_MODEL_SCRIPT_OP_End: // kill model
199 return 1;
200 case ENTITY_MODEL_SCRIPT_OP_Draw: // set display list ptr
201 entityModel->nextFrameTime = (f32) *curPos++;
202 entityModel->gfx.displayList = (Gfx*) *curPos++;
203 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
204 break;
205 case ENTITY_MODEL_SCRIPT_OP_Restart: // restore saved position
206 entityModel->cmdListReadPos = entityModel->cmdListSavedPos;
207 return 1;
208 case ENTITY_MODEL_SCRIPT_OP_Loop: // set saved position
209 entityModel->cmdListReadPos = entityModel->cmdListSavedPos = (EntityModelScript*) curPos;
210 return 1;
211 case ENTITY_MODEL_SCRIPT_OP_SetRenderMode: // set render mode
212 entityModel->renderMode = *curPos++;
213 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
214 return 1;
215 case ENTITY_MODEL_SCRIPT_OP_SetFlags: // set flags
216 entityModel->flags |= *curPos++;
217 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
218 return 1;
219 case ENTITY_MODEL_SCRIPT_OP_ClearFlags: // clear flags
220 entityModel->flags &= ~*curPos++;
221 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
222 return 1;
223 case ENTITY_MODEL_SCRIPT_OP_DrawImage: // set image data
224 imageData = entityModel->gfx.imageData;
225 entityModel->nextFrameTime = *curPos++;
226 imageData->raster = (u8*)*curPos++;
227 imageData->defaultPal = (PAL_PTR) *curPos++;
228 imageData->width = *curPos++;
229 imageData->height = *curPos++;
230 entityModel->cmdListReadPos = (EntityModelScript*) curPos;
231 break;
232 }
233 return 0;
234}
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 744 of file entity_model.c.

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

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] = NULL;
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:3528
GameStatus * gGameStatusPtr
Definition main_loop.c:32

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 )

Definition at line 74 of file entity_model.c.

Referenced by state_step_end_battle(), and state_step_unpause().

◆ load_entity_model()

s32 load_entity_model ( EntityModelScript * cmdList)

Definition at line 93 of file entity_model.c.

93 {
96 s32 i;
97
98 for (i = 0; i < MAX_ENTITY_MODELS; i++) {
99 if ((*gCurrentEntityModelList)[i] == NULL) {
100 break;
101 }
102 }
104
105 (*gCurrentEntityModelList)[i] = newEntityModel = heap_malloc(sizeof(*newEntityModel));
107 (*entityModelCount)++;
108
110
112 newEntityModel->renderMode = 1;
113 newEntityModel->gfx.displayList = NULL;
114 newEntityModel->cmdListReadPos = cmdList;
115 newEntityModel->nextFrameTime = 1.0f;
116 newEntityModel->timeScale = 1.0f;
117 if (cmdList == NULL) {
118 newEntityModel->cmdListReadPos = &D_8014C260;
119 }
120 newEntityModel->vertexArray = NULL;
121 newEntityModel->fpSetupGfxCallback = NULL;
122 newEntityModel->cmdListSavedPos = newEntityModel->cmdListReadPos;
123
126 }
127 return i;
128}
#define ASSERT(condition)
EntityModelScript D_8014C260
Definition entity_model.c:4
@ ENTITY_MODEL_FLAG_CAM1
Definition enums.h:5010
@ ENTITY_MODEL_FLAG_CAM2
Definition enums.h:5011
@ ENTITY_MODEL_FLAG_CAM0
Definition enums.h:5009
@ ENTITY_MODEL_FLAG_ENABLED
Definition enums.h:5013
void * heap_malloc(s32 size)
Definition heap.c:34
#define BATTLE_ENTITY_ID_BIT
Definition macros.h:150

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 130 of file entity_model.c.

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

Referenced by ALT_virtual_entity_create().

◆ exec_entity_model_commandlist()

void exec_entity_model_commandlist ( s32 idx)

Definition at line 172 of file entity_model.c.

172 {
174
177 entityModel = (*gCurrentEntityModelList)[idx];
178 if (entityModel != NULL && (entityModel->flags)) {
179 if (!(entityModel->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
182 entityModel->nextFrameTime -= entityModel->timeScale;
183 if (entityModel->nextFrameTime <= 0.0f) {
185 }
186 }
187 }
188 }
189 }
190}
s32 step_entity_model_commandlist(EntityModel *entityModel)
@ ENTITY_MODEL_FLAG_DISABLE_SCRIPT
Definition enums.h:5026
@ ENTITY_MODEL_FLAG_HIDDEN
Definition enums.h:5014
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 236 of file entity_model.c.

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

Referenced by appendGfx_entity_model(), and draw_entity_model_E().

◆ appendGfx_entity_model()

void appendGfx_entity_model ( EntityModel * model)

Definition at line 244 of file entity_model.c.

244 {
245 Matrix4f mtx;
249
252 if (!(model->flags & ENTITY_MODEL_FLAG_USE_IMAGE)) {
253 if (!(model->flags & ENTITY_MODEL_FLAG_10000)) {
256 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, 255);
260
262 case FALSE:
263 switch (model->renderMode) {
266 break;
269 break;
272 break;
275 break;
280 break;
283 break;
287 break;
291 break;
294 break;
297 break;
300 break;
304 break;
308 break;
312 break;
315 break;
316 }
317 break;
318 case TRUE:
319 switch (model->renderMode) {
322 break;
325 break;
328 break;
331 break;
334 break;
337 break;
340 break;
341 }
344 break;
345 }
349 } else {
351 }
352 }
353 if (model->vertexArray != NULL) {
355 }
357
358 if (model->fpSetupGfxCallback != NULL) {
359 model->fpSetupGfxCallback(model->setupGfxCallbackArg0);
360 }
362
363 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
366
367 if (!(model->flags & ENTITY_MODEL_FLAG_REFLECT)) {
368 return;
369 }
370
371 guMtxL2F(mtx, &model->transform);
373 guMtxCatF(mtx, mtx2, mtx);
374 guMtxF2L(mtx, &model->transform);
377 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
378 } else {
379 SpriteRasterInfo* imageData;
380
388
389 imageData = model->gfx.imageData;
390 ifxImg.raster = imageData->raster;
391 ifxImg.palette = imageData->defaultPal;
392 ifxImg.width = imageData->width;
393 ifxImg.height = imageData->height;
394 ifxImg.xOffset = -imageData->width / 2;
395 ifxImg.yOffset = imageData->height / 2;
396 ifxImg.alpha = 255;
397 guMtxL2F(imgfxMtx, &model->transform);
399 }
400
403}
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:5020
@ ENTITY_MODEL_FLAG_10000
Definition enums.h:5025
@ ENTITY_MODEL_FLAG_REFLECT
Definition enums.h:5018
@ RENDER_MODE_ALPHATEST_ONESIDED
Definition enums.h:3278
@ RENDER_MODE_SURFACE_OPA_NO_ZB
Definition enums.h:3267
@ RENDER_MODE_DECAL_OPA
Definition enums.h:3268
@ RENDER_MODE_SURFACE_XLU_LAYER3
Definition enums.h:3299
@ RENDER_MODE_DECAL_XLU_NO_AA
Definition enums.h:3293
@ RENDER_MODE_SURFACE_XLU_LAYER2
Definition enums.h:3287
@ RENDER_MODE_SURFACE_XLU_NO_AA
Definition enums.h:3284
@ RENDER_MODE_INTERSECTING_XLU
Definition enums.h:3303
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
@ RENDER_MODE_DECAL_XLU
Definition enums.h:3291
@ RENDER_MODE_SHADOW
Definition enums.h:3297
@ RENDER_MODE_SURFACE_XLU_NO_ZB
Definition enums.h:3285
@ RENDER_MODE_SURFACE_XLU_NO_ZB_BEHIND
Definition enums.h:3310
@ RENDER_MODE_SURFACE_OPA_NO_ZB_BEHIND
Definition enums.h:3308
@ RENDER_MODE_DECAL_XLU_AHEAD
Definition enums.h:3295
@ RENDER_MODE_ALPHATEST_NO_ZB_BEHIND
Definition enums.h:3309
@ 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_ALPHATEST_NO_ZB
Definition enums.h:3279
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3282
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:703
#define PM_CC2_MULTIPLY_SHADE
Definition macros.h:312
#define PM_CC_42
Definition macros.h:471
#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 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 405 of file entity_model.c.

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

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 443 of file entity_model.c.

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

Referenced by render_entities(), and render_shadows().

◆ draw_entity_model_C()

void draw_entity_model_C ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 482 of file entity_model.c.

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

◆ draw_entity_model_D()

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

Definition at line 512 of file entity_model.c.

512 {
515 RenderTask* rtPtr = &rt;
516
519 model = (*gCurrentEntityModelList)[modelIdx];
520
521 if (model != NULL) {
522 if (model->flags != 0) {
523 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
524 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
525 if (model->flags & (1 << gCurrentCamID)) {
527 model->transform = *transformMtx;
529 model->vertexArray = vertexArray;
530 rtPtr->renderMode = model->renderMode;
531 rtPtr->appendGfxArg = model;
532 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
533 rtPtr->dist = (u32)(model->flags & 0xF000) >> 8;
535 }
536 }
537 }
538 }
539 }
540 }
541}

◆ draw_entity_model_E()

void draw_entity_model_E ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 543 of file entity_model.c.

543 {
544 EntityModel* model = (*gCurrentEntityModelList)[modelIdx & ~BATTLE_ENTITY_ID_BIT];
545 Matrix4f mtx;
549
550 if (model == NULL) {
551 return;
552 }
553 if (model->flags == 0) {
554 return;
555 }
556 if (model->flags & ENTITY_MODEL_FLAG_100) {
557 return;
558 }
559 if (model->flags & ENTITY_MODEL_FLAG_HIDDEN) {
560 return;
561 }
562 if (model->flags & ENTITY_MODEL_FLAG_40) {
563 return;
564 }
565 if (!(model->flags & ENTITY_MODEL_FLAG_CAM3)) {
566 return;
567 }
568
569 model->transform = *transformMtx;
570 model->vertexArray = NULL;
573 if (!(model->flags & ENTITY_MODEL_FLAG_USE_IMAGE)) {
575 case FALSE:
576 switch (model->renderMode) {
579 break;
582 break;
585 break;
588 break;
593 break;
596 break;
600 break;
604 break;
607 break;
610 break;
613 break;
617 break;
621 break;
625 break;
628 break;
629 }
630 break;
631 case TRUE:
632 switch (model->renderMode) {
635 break;
638 break;
641 break;
644 break;
647 break;
650 break;
653 break;
654 }
657 break;
658 }
662 } else {
664 }
665 if (model->vertexArray != NULL) {
667 }
668 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
671 if (!(model->flags & ENTITY_MODEL_FLAG_REFLECT)) {
672 return;
673 }
674
675 guMtxL2F(mtx, &model->transform);
677 guMtxCatF(mtx, mtx2, mtx);
678 guMtxF2L(mtx, &model->transform);
681 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
682 } else {
683 SpriteRasterInfo* imageData;
684
692
693 imageData = model->gfx.imageData;
694 ifxImg.raster = imageData->raster;
695 ifxImg.palette = imageData->defaultPal;
696 ifxImg.width = imageData->width;
697 ifxImg.height = imageData->height;
698 ifxImg.xOffset = -imageData->width / 2;
699 ifxImg.yOffset = imageData->height / 2;
700 ifxImg.alpha = 255;
701 guMtxL2F(imgfxMtx, &model->transform);
703 }
704
707}
@ ENTITY_MODEL_FLAG_CAM3
Definition enums.h:5012

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 709 of file entity_model.c.

709 {
710 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
711
712 if (entityModel != NULL && entityModel->flags) {
713 if (cmdList == NULL) {
714 cmdList = &D_8014C260;
715 }
716 entityModel->cmdListReadPos = cmdList;
717 entityModel->cmdListSavedPos = cmdList;
718 entityModel->nextFrameTime = 1.0f;
719 entityModel->timeScale = 1.0f;
720 }
721}
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 727 of file entity_model.c.

727 {
728 s32 index = idx & ~BATTLE_ENTITY_ID_BIT;
729 EntityModel* entityModel = (*gCurrentEntityModelList)[index];
730
731 if (entityModel != NULL && entityModel->flags) {
733 heap_free(entityModel->gfx.imageData);
734 }
735 {
738 (*gCurrentEntityModelList)[index] = NULL;
739 (*modelCount)--;
740 }
741 }
742}
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 758 of file entity_model.c.

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

Referenced by show_immune_bonk().

◆ clear_entity_model_flags()

void clear_entity_model_flags ( s32 idx,
s32 newFlags )

Definition at line 766 of file entity_model.c.

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

Referenced by btl_bonk_update().

◆ bind_entity_model_setupGfx()

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

Definition at line 774 of file entity_model.c.

774 {
775 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
776
777 entityModel->fpSetupGfxCallback = fpSetupGfxCallback;
778 entityModel->setupGfxCallbackArg0 = setupGfxCallbackArg0;
779}
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 781 of file entity_model.c.

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

◆ func_80122FB8()

void func_80122FB8 ( s32 idx,
s32 newFlags )

Definition at line 787 of file entity_model.c.

◆ enable_entity_fog()

void enable_entity_fog ( void )

Definition at line 793 of file entity_model.c.

793 {
795}

◆ disable_entity_fog()

void disable_entity_fog ( void )

Definition at line 797 of file entity_model.c.

797 {
799}

◆ set_entity_fog_dist()

void set_entity_fog_dist ( s32 min,
s32 max )

Definition at line 801 of file entity_model.c.

801 {
804}

◆ set_entity_fog_color()

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

Definition at line 806 of file entity_model.c.

806 {
807 entity_fog_red = r;
809 entity_fog_blue = b;
811}

◆ is_entity_fog_enabled()

s32 is_entity_fog_enabled ( void )

Definition at line 813 of file entity_model.c.

813 {
814 return entity_fog_enabled;
815}

◆ get_entity_fog_distance()

void get_entity_fog_distance ( s32 * start,
s32 * end )

Definition at line 817 of file entity_model.c.

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

◆ get_entity_fog_color()

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

Definition at line 822 of file entity_model.c.

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

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

BSS s32 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