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

Go to the source code of this file.

Data Structures

struct  FogSettings
 
struct  DepthFloatFactors
 

Macros

#define WORLD_TEXTURE_MEMORY_SIZE   0x20000
 
#define BATTLE_TEXTURE_MEMORY_SIZE   0x8000
 
#define DEPTH_EXPONENT_MASK   0xE000
 
#define DEPTH_MANTISSA_MASK   0x1FFC
 
#define DEPTH_DZ_MASK   0x0003
 
#define DEPTH_EXPONENT_SHIFT   13
 
#define DEPTH_MANTISSA_SHIFT   2
 
#define DEPTH_DZ_SHIFT   0
 
#define MAX_VIEWPORT_DEPTH   (2 * 32 * ((G_MAXZ / 2)))
 
#define TEST_POINT_VISIBILITY
 
#define LESS(i, j)   taskList[sorted[i]].dist < taskList[sorted[j]].dist
 
#define SWAP(i, j)   tmp = sorted[i], sorted[i] = sorted[j], sorted[j] = tmp
 
#define LESS(i, j)   taskList[sorted[i]].dist > taskList[sorted[j]].dist
 

Enumerations

enum  {
  AUX_COMBINE_0 = 0 , AUX_COMBINE_1 = 1 , AUX_COMBINE_2 = 2 , AUX_COMBINE_3 = 3 ,
  AUX_COMBINE_4 = 4 , AUX_COMBINE_5 = 5 , AUX_COMBINE_6 = 6 , AUX_COMBINE_7 = 7 ,
  AUX_COMBINE_8 = 8 , AUX_COMBINE_9 = 9 , AUX_COMBINE_A = 10
}
 
enum  { AUX_COMBINE_SUB_0 = 0 , AUX_COMBINE_SUB_1 = 1 , AUX_COMBINE_SUB_2 = 2 , AUX_COMBINE_SUB_COUNT = 3 }
 
enum  {
  TEX_COMBINE_NOTEX = 0 , TEX_COMBINE_MAIN_ONLY_0 = 1 , TEX_COMBINE_MAIN_ONLY_1 = 2 , TEX_COMBINE_MAIN_ONLY_2 = 3 ,
  TEX_COMBINE_MIPMAPS_0 = 4 , TEX_COMBINE_MIPMAPS_1 = 5 , TEX_COMBINE_MIPMAPS_2 = 6 , TEX_COMBINE_AUX_SHARED_0 = 7 ,
  TEX_COMBINE_AUX_SHARED_1 = 8 , TEX_COMBINE_AUX_SHARED_2 = 9 , TEX_COMBINE_AUX_IND_0 = 10 , TEX_COMBINE_AUX_IND_1 = 11 ,
  TEX_COMBINE_AUX_IND_2 = 12 , TEX_COMBINE_3 = 13 , TEX_COMBINE_4 = 14 , TEX_COMBINE_5 = 15 ,
  TEX_COMBINE_6 = 16 , TEX_COMBINE_7 = 17 , TEX_COMBINE_8 = 18 , TEX_COMBINE_9 = 19 ,
  TEX_COMBINE_A = 20
}
 
enum  {
  TINT_COMBINE_NONE = 0 , TINT_COMBINE_FOG = 1 , TINT_COMBINE_SHROUD = 2 , TINT_COMBINE_DEPTH = 3 ,
  TINT_COMBINE_REMAP = 4
}
 
enum  {
  RENDER_CLASS_1CYC = 1 , RENDER_CLASS_2CYC = 2 , RENDER_CLASS_FOG = 3 , RENDER_CLASS_1CYC_SHROUD = 4 ,
  RENDER_CLASS_2CYC_SHROUD = 5 , RENDER_CLASS_FOG_SHROUD = 6 , RENDER_CLASS_1CYC_DEPTH = 10 , RENDER_CLASS_2CYC_DEPTH = 11
}
 
enum  { RENDER_TASK_LIST_NEAR , RENDER_TASK_LIST_MID , RENDER_TASK_LIST_FAR }
 

Functions

BSS TextureHeader gCurrentTextureHeader ALIGNED (16)
 
void func_80117D00 (Model *model)
 
void appendGfx_model_group (void *model)
 
void render_transform_group_node (ModelNode *node)
 
void render_transform_group (void *group)
 
void make_texture_gfx (TextureHeader *, Gfx **, IMG_PTR raster, PAL_PTR palette, IMG_PTR auxRaster, PAL_PTR auxPalette, u8, u8, u16, u16)
 
void load_model_transforms (ModelNode *model, ModelNode *parent, Matrix4f mdlTxMtx, s32 treeDepth)
 
s32 is_identity_fixed_mtx (Mtx *mtx)
 
void build_custom_gfx (void)
 
void appendGfx_model (void *data)
 
void load_texture_impl (u32 romOffset, TextureHandle *handle, TextureHeader *header, s32 mainSize, s32 mainPalSize, s32 auxSize, s32 auxPalSize)
 
void load_texture_by_name (ModelNodeProperty *propertyName, s32 romOffset, s32 size)
 
void load_texture_variants (u32 romOffset, s32 textureID, s32 baseOffset, s32 size)
 
ModelNodePropertyget_model_property (ModelNode *node, ModelPropertyKeys key)
 
void load_next_model_textures (ModelNode *model, s32 romOffset, s32 texSize)
 
void mdl_load_all_textures (ModelNode *rootModel, s32 romOffset, s32 size)
 
s32 mdl_get_child_count (ModelNode *model)
 
void clear_model_data (void)
 
void init_model_data (void)
 
void mdl_calculate_model_sizes (void)
 
void mdl_create_model (ModelBlueprint *bp, s32 unused)
 
void mdl_update_transform_matrices (void)
 
void render_models (void)
 
Modelget_model_from_list_index (s32 listIndex)
 
void load_data_for_models (ModelNode *rootModel, s32 texturesOffset, s32 size)
 
s32 get_model_list_index_from_tree_index (s32 treeIndex)
 
s32 get_transform_group_index (s32 modelID)
 
void get_model_center_and_size (u16 modelID, f32 *centerX, f32 *centerY, f32 *centerZ, f32 *sizeX, f32 *sizeY, f32 *sizeZ)
 
ModelTransformGroupget_transform_group (s32 index)
 
void func_8011B1D8 (ModelNode *node)
 
void mdl_make_transform_group (u16 modelID)
 
void enable_transform_group (u16 modelID)
 
void disable_transform_group (u16 modelID)
 
void clone_model (u16 srcModelID, u16 newModelID)
 
void mdl_group_set_visibility (u16 treeIndex, s32 flags, s32 mode)
 
void mdl_group_set_custom_gfx (u16 groupModelID, s32 customGfxIndex, s32 tintType, b32 invertSelection)
 
void mdl_reset_transform_flags (void)
 
void enable_world_fog (void)
 
void disable_world_fog (void)
 
void set_world_fog_dist (s32 start, s32 end)
 
void set_world_fog_color (s32 r, s32 g, s32 b, s32 a)
 
s32 is_world_fog_enabled (void)
 
void get_world_fog_distance (s32 *start, s32 *end)
 
void get_world_fog_color (s32 *r, s32 *g, s32 *b, s32 *a)
 
void set_tex_panner (Model *model, s32 texPannerID)
 
void set_main_pan_u (s32 texPannerID, s32 value)
 
void set_main_pan_v (s32 texPannerID, s32 value)
 
void set_aux_pan_u (s32 texPannerID, s32 value)
 
void set_aux_pan_v (s32 texPannerID, s32 value)
 
void set_mdl_custom_gfx_set (Model *model, s32 customGfxIndex, u32 tintType)
 
void set_custom_gfx (s32 customGfxIndex, Gfx *pre, Gfx *post)
 
void set_custom_gfx_builders (s32 customGfxIndex, ModelCustomGfxBuilderFunc pre, ModelCustomGfxBuilderFunc post)
 
void mdl_set_shroud_tint_params (u8 r, u8 g, u8 b, u8 a)
 
void mdl_get_shroud_tint_params (u8 *r, u8 *g, u8 *b, u8 *a)
 
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_get_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 maxR, u8 maxG, u8 maxB, u8 minR, u8 minG, u8 minB)
 
void mdl_get_remap_tint_params (u8 *primR, u8 *primG, u8 *primB, u8 *envR, u8 *envG, u8 *envB)
 
void mdl_get_vertex_count (Gfx *gfx, s32 *numVertices, Vtx **baseVtx, s32 *gfxCount, Vtx *baseAddr)
 
void mdl_local_gfx_update_vtx_pointers (Gfx *nodeDlist, Vtx *baseVtx, Gfx *arg2, Vtx *arg3)
 
void mdl_local_gfx_copy_vertices (Vtx *src, s32 num, Vtx *dest)
 
void mdl_make_local_vertex_copy (s32 copyIndex, u16 modelID, s32 isMakingCopy)
 
void mdl_get_copied_vertices (s32 copyIndex, Vtx **firstVertex, Vtx **copiedVertices, s32 *numCopied)
 
Gfxmdl_get_copied_gfx (s32 copyIndex)
 
void mdl_project_tex_coords (s32 modelID, Gfx *outGfx, Matrix4f arg2, Vtx *arg3)
 
s32 is_model_center_visible (u16 modelID, s32 depthQueryID, f32 *screenX, f32 *screenY)
 
OPTIMIZE_OFAST b32 is_point_visible (f32 x, f32 y, f32 z, s32 depthQueryID, f32 *screenX, f32 *screenY)
 
void mdl_draw_hidden_panel_surface (Gfx **arg0, u16 treeIndex)
 
voidmdl_get_next_texture_address (s32 size)
 
void mdl_set_all_tint_type (s32 tintType)
 
void clear_render_tasks (void)
 
RenderTaskqueue_render_task (RenderTask *task)
 
OPTIMIZE_OFAST void execute_render_tasks (void)
 

Variables

u8gBackgroundTintModePtr
 
ModelListgCurrentModels
 
ModelTreeInfoListgCurrentModelTreeNodeInfo
 
Addr TextureHeap
 
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_SURFACE_OPA_NO_AA []
 
Gfx Gfx_RM1_DECAL_OPA_NO_AA []
 
Gfx Gfx_RM1_INTERSECTING_OPA_NO_AA []
 
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_XLU_AA_ZB_ZUPD []
 
Gfx Gfx_RM1_SURFACE_OPA_NO_ZB []
 
Gfx Gfx_RM1_ALPHATEST_NO_ZB []
 
Gfx Gfx_RM1_SURFACE_XLU_NO_ZB []
 
Gfx Gfx_RM1_SURFACE_XLU_ZB_ZUPD []
 
Gfx Gfx_RM1_CLOUD_NO_ZCMP []
 
Gfx Gfx_RM1_CLOUD []
 
Gfx Gfx_RM1_CLOUD_NO_ZB []
 
Gfx Gfx_RM2_SURFACE_OPA []
 
Gfx Gfx_RM2_DECAL_OPA []
 
Gfx Gfx_RM2_INTERSECTING_OPA []
 
Gfx Gfx_RM2_ALPHATEST []
 
Gfx Gfx_RM2_SURFACE_XLU []
 
Gfx Gfx_RM2_DECAL_XLU []
 
Gfx Gfx_RM2_INTERSECTING_XLU []
 
Gfx Gfx_RM2_SURFACE_OPA_NO_AA []
 
Gfx Gfx_RM2_DECAL_OPA_NO_AA []
 
Gfx Gfx_RM2_INTERSECTING_OPA_NO_AA []
 
Gfx Gfx_RM2_ALPHATEST_ONESIDED []
 
Gfx Gfx_RM2_SURFACE_XLU_NO_AA []
 
Gfx Gfx_RM2_DECAL_XLU_NO_AA []
 
Gfx Gfx_RM2_PASS_THROUGH []
 
Gfx Gfx_RM2_SURFACE_XLU_AA_ZB_ZUPD []
 
Gfx Gfx_RM2_SURFACE_OPA_NO_ZB []
 
Gfx Gfx_RM2_ALPHATEST_NO_ZB []
 
Gfx Gfx_RM2_SURFACE_XLU_NO_ZB []
 
Gfx Gfx_RM2_CLOUD []
 
Gfx Gfx_RM2_CLOUD_NO_ZB []
 
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 []
 
Gfx Gfx_RM3_SURFACE_OPA_NO_AA []
 
Gfx Gfx_RM3_DECAL_OPA_NO_AA []
 
Gfx Gfx_RM3_INTERSECTING_OPA_NO_AA []
 
Gfx Gfx_RM3_ALPHATEST_ONESIDED []
 
Gfx Gfx_RM3_SURFACE_XLU_NO_AA []
 
Gfx Gfx_RM3_DECAL_XLU_NO_AA []
 
Gfx Gfx_RM3_PASS_THROUGH []
 
Gfx Gfx_RM3_SURFACE_XLU_AA_ZB_ZUPD []
 
Gfx Gfx_RM3_SURFACE_OPA_NO_ZB []
 
Gfx Gfx_RM3_ALPHATEST_NO_ZB []
 
Gfx Gfx_RM3_SURFACE_XLU_NO_ZB []
 
Gfx Gfx_RM3_CLOUD []
 
Gfx Gfx_RM3_CLOUD_NO_ZB []
 
GfxModelRenderModes []
 
Gfx SolidCombineModes [][5]
 
Gfx AlphaTestCombineModes [][5]
 
voidTextureHeapBase = (void*) &TextureHeap
 
u8 ShroudTintAmt = 0
 
u8 ShroudTintR = 0
 
u8 ShroudTintG = 0
 
u8 ShroudTintB = 0
 
u8 DepthTintBaseR = 0
 
u8 DepthTintBaseG = 0
 
u8 DepthTintBaseB = 0
 
u8 DepthTintBaseA = 0
 
u8 DepthTintColR = 0
 
u8 DepthTintColG = 0
 
u8 DepthTintColB = 0
 
u8 DepthTintColA = 0
 
s32 DepthTintStart = 950
 
s32 DepthTintEnd = 1000
 
u8 RemapTintMaxR = 255
 
u8 RemapTintMaxG = 255
 
u8 RemapTintMaxB = 255
 
u8 RemapTintMinR = 0
 
u8 RemapTintMinG = 0
 
u8 RemapTintMinB = 0
 
Mtx ReferenceIdentityMtx
 
DepthFloatFactors DepthFloatLookupTable []
 
s32 gLastRenderTaskCount = 0
 
s32 RenderTaskBasePriorities []
 
ModelCustomGfxBuilderListgCurrentCustomModelGfxBuildersPtr
 
ModelNode ** gCurrentModelTreeRoot
 
ModelTransformGroupListgCurrentTransformGroups
 
ModelCustomGfxListgCurrentCustomModelGfxPtr
 
BSS ModelList wModelList
 
BSS ModelList bModelList
 
BSS ModelTransformGroupList wTransformGroups
 
BSS ModelTransformGroupList bTransformGroups
 
BSS ModelCustomGfxList wCustomModelGfx
 
BSS ModelCustomGfxList bCustomModelGfx
 
BSS ModelCustomGfxBuilderList wCustomModelGfxBuilders
 
BSS ModelCustomGfxBuilderList bCustomModelGfxBuilders
 
BSS ModelLocalVertexCopyList wModelLocalVtxBuffers
 
BSS ModelLocalVertexCopyList bModelLocalVtxBuffers
 
BSS ModelLocalVertexCopyListgCurrentModelLocalVtxBuffers
 
BSS ModelNodewModelTreeRoot
 
BSS ModelNodebModelTreeRoot
 
BSS ModelTreeInfoList wModelTreeNodeInfo
 
BSS ModelTreeInfoList bModelTreeNodeInfo
 
BSS s8 wBackgroundTintMode
 
BSS s8 bBackgroundTintMode
 
BSS s32 TreeIterPos
 
BSS FogSettings wFogSettings
 
BSS FogSettings bFogSettings
 
BSS FogSettingsgFogSettings
 
BSS s32 texPannerMainU [MAX_TEX_PANNERS]
 
BSS s32 texPannerMainV [MAX_TEX_PANNERS]
 
BSS s32 texPannerAuxU [MAX_TEX_PANNERS]
 
BSS s32 texPannerAuxV [MAX_TEX_PANNERS]
 
BSS voidTextureHeapPos
 
BSS u16 mtg_IterIdx
 
BSS u16 mtg_SearchModelID
 
BSS ModelNodemtg_FoundModelNode
 
BSS u16 mtg_MinChild
 
BSS u16 mtg_MaxChild
 
BSS u16 DepthCopyBuffer [16]
 
BSS RenderTaskRenderTaskLists [3]
 
BSS s32 RenderTaskListIdx
 
BSS s32 RenderTaskCount [3]
 
TextureHandle TextureHandles [128]
 
Addr BattleEntityHeapBottom
 

Data Structure Documentation

◆ FogSettings

struct FogSettings
Data Fields
s32 enabled
Color4i color
s32 startDistance
s32 endDistance

◆ DepthFloatFactors

struct DepthFloatFactors
Data Fields
s32 shift
s32 bias

Macro Definition Documentation

◆ WORLD_TEXTURE_MEMORY_SIZE

#define WORLD_TEXTURE_MEMORY_SIZE   0x20000

Definition at line 102 of file model.c.

Referenced by mdl_get_next_texture_address(), and mdl_load_all_textures().

◆ BATTLE_TEXTURE_MEMORY_SIZE

#define BATTLE_TEXTURE_MEMORY_SIZE   0x8000

Definition at line 103 of file model.c.

Referenced by mdl_get_next_texture_address().

◆ DEPTH_EXPONENT_MASK

#define DEPTH_EXPONENT_MASK   0xE000

Definition at line 605 of file model.c.

◆ DEPTH_MANTISSA_MASK

#define DEPTH_MANTISSA_MASK   0x1FFC

Definition at line 606 of file model.c.

Referenced by is_model_center_visible(), and is_point_visible().

◆ DEPTH_DZ_MASK

#define DEPTH_DZ_MASK   0x0003

Definition at line 607 of file model.c.

Referenced by is_model_center_visible(), and is_point_visible().

◆ DEPTH_EXPONENT_SHIFT

#define DEPTH_EXPONENT_SHIFT   13

Definition at line 609 of file model.c.

Referenced by is_model_center_visible(), and is_point_visible().

◆ DEPTH_MANTISSA_SHIFT

#define DEPTH_MANTISSA_SHIFT   2

Definition at line 610 of file model.c.

Referenced by is_model_center_visible(), and is_point_visible().

◆ DEPTH_DZ_SHIFT

#define DEPTH_DZ_SHIFT   0

Definition at line 611 of file model.c.

◆ MAX_VIEWPORT_DEPTH

#define MAX_VIEWPORT_DEPTH   (2 * 32 * ((G_MAXZ / 2)))

Definition at line 634 of file model.c.

Referenced by is_model_center_visible(), and is_point_visible().

◆ TEST_POINT_VISIBILITY

#define TEST_POINT_VISIBILITY
Value:
outX = (m00 * xComp) + (m10 * yComp) + (m20 * zComp) + m30; \
outY = (m01 * xComp) + (m11 * yComp) + (m21 * zComp) + m31; \
outZ = (m02 * xComp) + (m12 * yComp) + (m22 * zComp) + m32; \
outW = (m03 * xComp) + (m13 * yComp) + (m23 * zComp) + m33; \
if (outW == 0.0f) { \
break; \
} \
/* Perspective divide */ \
outW = 1.0f / outW; \
xComp = outX * outW; \
yComp = outY * outW; \
if (zComp > -1.0f && xComp >= -1.0f && xComp <= 1.0f && yComp >= -1.0f && yComp <= 1.0f) { \
break; \
}
BSS s32 PopupMenu_SelectedIndex

◆ LESS [1/2]

#define LESS ( i,
j )   taskList[sorted[i]].dist < taskList[sorted[j]].dist

◆ SWAP

#define SWAP ( i,
j )   tmp = sorted[i], sorted[i] = sorted[j], sorted[j] = tmp

◆ LESS [2/2]

#define LESS ( i,
j )   taskList[sorted[i]].dist > taskList[sorted[j]].dist

Enumeration Type Documentation

◆ anonymous enum

Enumerator
AUX_COMBINE_0 
AUX_COMBINE_1 
AUX_COMBINE_2 
AUX_COMBINE_3 
AUX_COMBINE_4 
AUX_COMBINE_5 
AUX_COMBINE_6 
AUX_COMBINE_7 
AUX_COMBINE_8 
AUX_COMBINE_9 
AUX_COMBINE_A 

Definition at line 16 of file model.c.

16 {
17 AUX_COMBINE_0 = 0,
18 AUX_COMBINE_1 = 1,
19 AUX_COMBINE_2 = 2,
20 AUX_COMBINE_3 = 3,
21 AUX_COMBINE_4 = 4,
22 AUX_COMBINE_5 = 5,
23 AUX_COMBINE_6 = 6,
24 AUX_COMBINE_7 = 7,
25 AUX_COMBINE_8 = 8,
26 AUX_COMBINE_9 = 9,
27 AUX_COMBINE_A = 10,
28};
@ AUX_COMBINE_0
Definition model.c:17
@ AUX_COMBINE_7
Definition model.c:24
@ AUX_COMBINE_A
Definition model.c:27
@ AUX_COMBINE_6
Definition model.c:23
@ AUX_COMBINE_1
Definition model.c:18
@ AUX_COMBINE_2
Definition model.c:19
@ AUX_COMBINE_5
Definition model.c:22
@ AUX_COMBINE_3
Definition model.c:20
@ AUX_COMBINE_8
Definition model.c:25
@ AUX_COMBINE_4
Definition model.c:21
@ AUX_COMBINE_9
Definition model.c:26

◆ anonymous enum

Enumerator
AUX_COMBINE_SUB_0 
AUX_COMBINE_SUB_1 
AUX_COMBINE_SUB_2 
AUX_COMBINE_SUB_COUNT 

Definition at line 32 of file model.c.

32 {
33 AUX_COMBINE_SUB_0 = 0, // multiply TEX * SHADE for color, use TEX for alpha
34 AUX_COMBINE_SUB_1 = 1, // lerp from TEX to SHADE based on TEX alpha
35 AUX_COMBINE_SUB_2 = 2, // TEX only, shade is ignored
37};
@ AUX_COMBINE_SUB_1
Definition model.c:34
@ AUX_COMBINE_SUB_2
Definition model.c:35
@ AUX_COMBINE_SUB_COUNT
Definition model.c:36
@ AUX_COMBINE_SUB_0
Definition model.c:33

◆ anonymous enum

Enumerator
TEX_COMBINE_NOTEX 
TEX_COMBINE_MAIN_ONLY_0 
TEX_COMBINE_MAIN_ONLY_1 
TEX_COMBINE_MAIN_ONLY_2 
TEX_COMBINE_MIPMAPS_0 
TEX_COMBINE_MIPMAPS_1 
TEX_COMBINE_MIPMAPS_2 
TEX_COMBINE_AUX_SHARED_0 
TEX_COMBINE_AUX_SHARED_1 
TEX_COMBINE_AUX_SHARED_2 
TEX_COMBINE_AUX_IND_0 
TEX_COMBINE_AUX_IND_1 
TEX_COMBINE_AUX_IND_2 
TEX_COMBINE_3 
TEX_COMBINE_4 
TEX_COMBINE_5 
TEX_COMBINE_6 
TEX_COMBINE_7 
TEX_COMBINE_8 
TEX_COMBINE_9 
TEX_COMBINE_A 

Definition at line 41 of file model.c.

41 {
42 // no texture
44
45 // extra tile mode = EXTRA_TILE_NONE
49
50 // extra tile mode = EXTRA_TILE_MIPMAPS
54
55 // extra tile mode = EXTRA_TILE_AUX_SAME_AS_MAIN
59
60 // extra tile mode = EXTRA_TILE_AUX_INDEPENDENT
61 // NOTE: unused; copy of TEX_COMBINE_AUX_SHARED; may not work properly
65
66 // special types selected by auxCombineType (these ignore auxCombineSubType)
67 TEX_COMBINE_3 = 13,
68 TEX_COMBINE_4 = 14,
69 TEX_COMBINE_5 = 15,
70 TEX_COMBINE_6 = 16,
71 TEX_COMBINE_7 = 17,
72 TEX_COMBINE_8 = 18,
73 TEX_COMBINE_9 = 19,
74 TEX_COMBINE_A = 20,
75};
@ TEX_COMBINE_AUX_IND_2
Definition model.c:64
@ TEX_COMBINE_A
Definition model.c:74
@ TEX_COMBINE_AUX_IND_1
Definition model.c:63
@ TEX_COMBINE_AUX_IND_0
Definition model.c:62
@ TEX_COMBINE_NOTEX
Definition model.c:43
@ TEX_COMBINE_4
Definition model.c:68
@ TEX_COMBINE_8
Definition model.c:72
@ TEX_COMBINE_AUX_SHARED_1
Definition model.c:57
@ TEX_COMBINE_5
Definition model.c:69
@ TEX_COMBINE_MAIN_ONLY_2
Definition model.c:48
@ TEX_COMBINE_MIPMAPS_1
Definition model.c:52
@ TEX_COMBINE_9
Definition model.c:73
@ TEX_COMBINE_7
Definition model.c:71
@ TEX_COMBINE_MIPMAPS_2
Definition model.c:53
@ TEX_COMBINE_MAIN_ONLY_0
Definition model.c:46
@ TEX_COMBINE_MAIN_ONLY_1
Definition model.c:47
@ TEX_COMBINE_AUX_SHARED_0
Definition model.c:56
@ TEX_COMBINE_AUX_SHARED_2
Definition model.c:58
@ TEX_COMBINE_3
Definition model.c:67
@ TEX_COMBINE_MIPMAPS_0
Definition model.c:51
@ TEX_COMBINE_6
Definition model.c:70

◆ anonymous enum

Enumerator
TINT_COMBINE_NONE 
TINT_COMBINE_FOG 
TINT_COMBINE_SHROUD 
TINT_COMBINE_DEPTH 
TINT_COMBINE_REMAP 

Definition at line 77 of file model.c.

77 {
83};
@ TINT_COMBINE_DEPTH
Definition model.c:81
@ TINT_COMBINE_REMAP
Definition model.c:82
@ TINT_COMBINE_SHROUD
Definition model.c:80
@ TINT_COMBINE_FOG
Definition model.c:79
@ TINT_COMBINE_NONE
Definition model.c:78

◆ anonymous enum

Enumerator
RENDER_CLASS_1CYC 
RENDER_CLASS_2CYC 
RENDER_CLASS_FOG 
RENDER_CLASS_1CYC_SHROUD 
RENDER_CLASS_2CYC_SHROUD 
RENDER_CLASS_FOG_SHROUD 
RENDER_CLASS_1CYC_DEPTH 
RENDER_CLASS_2CYC_DEPTH 

Definition at line 85 of file model.c.

85 {
86 RENDER_CLASS_1CYC = 1, // render modes are single-cycle
87 RENDER_CLASS_2CYC = 2, // render modes are two-cycle, starting with G_RM_PASS
88 RENDER_CLASS_FOG = 3, // render modes are two-cycle, starting with G_RM_FOG_SHADE_A
89 RENDER_CLASS_1CYC_SHROUD = 4, // render modes use Gfx_RM2_SURFACE_OPA, but overwrite
90 RENDER_CLASS_2CYC_SHROUD = 5, // render modes use Gfx_RM2_SURFACE_OPA, but overwrite
94};
@ RENDER_CLASS_1CYC
Definition model.c:86
@ RENDER_CLASS_1CYC_SHROUD
Definition model.c:89
@ RENDER_CLASS_2CYC
Definition model.c:87
@ RENDER_CLASS_2CYC_DEPTH
Definition model.c:93
@ RENDER_CLASS_1CYC_DEPTH
Definition model.c:92
@ RENDER_CLASS_FOG
Definition model.c:88
@ RENDER_CLASS_2CYC_SHROUD
Definition model.c:90
@ RENDER_CLASS_FOG_SHROUD
Definition model.c:91

◆ anonymous enum

Enumerator
RENDER_TASK_LIST_NEAR 
RENDER_TASK_LIST_MID 
RENDER_TASK_LIST_FAR 

Definition at line 96 of file model.c.

96 {
97 RENDER_TASK_LIST_NEAR, // dist < 800K
99 RENDER_TASK_LIST_FAR, // dist >= 3M
100};
@ RENDER_TASK_LIST_FAR
Definition model.c:99
@ RENDER_TASK_LIST_NEAR
Definition model.c:97
@ RENDER_TASK_LIST_MID
Definition model.c:98

Function Documentation

◆ ALIGNED()

◆ func_80117D00()

void func_80117D00 ( Model * model)

Definition at line 2940 of file model.c.

2940 {
2941 Model* mdl = model; // temps needed to match
2942 ModelNode* modelNode = mdl->modelNode;
2943
2944 if (model->modelNode->type != SHAPE_TYPE_MODEL) {
2945 if (modelNode->groupData != NULL) {
2946 s32 numChildren = modelNode->groupData->numChildren;
2947
2948 if (numChildren != 0) {
2949 s32 i;
2950
2951 for (i = 0; i < numChildren; i++, TreeIterPos++) {
2952 Model newModel = *mdl;
2954
2955 newModel.flags = mdl->flags;
2956 newModel.finalMtx = mdl->finalMtx;
2957 newModel.modelNode = modelNode->groupData->childList[i];
2958 newModel.texPannerID = mdl->texPannerID;
2959 newModel.customGfxIndex = mdl->customGfxIndex;
2960
2961 if (newModel.modelNode->type == SHAPE_TYPE_MODEL) {
2963 } else {
2964 prop = NULL;
2965 }
2966
2967 if (prop != NULL) {
2968 newModel.renderMode = prop->data.s;
2969 } else {
2970 newModel.renderMode = 0;
2971 }
2972
2973 newModel.textureID = (*gCurrentModelTreeNodeInfo)[TreeIterPos].textureID;
2974 newModel.textureVariation = 0;
2976 }
2977 }
2978 }
2979 } else {
2981 }
2982}
BSS s32 TreeIterPos
Definition model.c:1336
void func_80117D00(Model *model)
Definition model.c:2940
ModelNodeProperty * get_model_property(ModelNode *node, ModelPropertyKeys key)
Definition model.c:2285
void appendGfx_model(void *data)
Definition model.c:1368
struct ModelNode ** childList
Definition model.h:43
s32 numChildren
Definition model.h:42
@ SHAPE_TYPE_MODEL
Definition model.h:152
struct ModelGroupData * groupData
Definition model.h:56
@ MODEL_PROP_KEY_RENDER_MODE
Definition model.h:142
Definition model.h:59

Referenced by appendGfx_model_group(), and func_80117D00().

◆ appendGfx_model_group()

void appendGfx_model_group ( void * model)

Definition at line 2925 of file model.c.

2925 {
2926 Model* model = data;
2927 s32 modelTreeDepth = (*gCurrentModelTreeNodeInfo)[model->modelID].treeDepth;
2928 s32 i;
2929
2930 for (i = model->modelID - 1; i >= 0; i--) {
2931 if (modelTreeDepth >= (*gCurrentModelTreeNodeInfo)[i].treeDepth) {
2932 break;
2933 }
2934 }
2935
2936 TreeIterPos = i + 1;
2938}
ModelTreeInfoList * gCurrentModelTreeNodeInfo
Definition model.c:107

Referenced by render_models(), and render_transform_group_node().

◆ render_transform_group_node()

void render_transform_group_node ( ModelNode * node)

Definition at line 2985 of file model.c.

2985 {
2986 Gfx** gfx = &gMainGfxPos;
2987 Model* model;
2988
2989 if (node != NULL) {
2990 if (node->type == SHAPE_TYPE_GROUP) {
2992
2993 if (groupInfoProp != NULL && groupInfoProp->data.s != 0) {
2995 if (!(model->flags & MODEL_FLAG_HIDDEN)) {
2997 }
2998 mtg_IterIdx++;
2999 return;
3000 }
3001 }
3002 if (node->type != SHAPE_TYPE_MODEL) {
3003 if (node->groupData != NULL) {
3004 s32 numChildren;
3005 s32 i;
3006
3007 if (node->groupData->transformMatrix != NULL) {
3008 gSPMatrix((*gfx)++, node->groupData->transformMatrix, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
3009 }
3010
3011 numChildren = node->groupData->numChildren;
3012 if (numChildren != 0) {
3013 for (i = 0; i < numChildren; i++) {
3014 render_transform_group_node(node->groupData->childList[i]);
3015 }
3016 }
3017
3018 if (node->groupData->transformMatrix != NULL) {
3019 gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW);
3020 }
3021 }
3022 return;
3023 }
3024
3026 if (!(model->flags & MODEL_FLAG_HIDDEN)) {
3028 }
3029 mtg_IterIdx++;
3030 }
3031}
@ MODEL_FLAG_HIDDEN
Definition enums.h:4357
void render_transform_group_node(ModelNode *node)
Definition model.c:2985
Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3314
void appendGfx_model_group(void *model)
Definition model.c:2925
BSS u16 mtg_IterIdx
Definition model.c:1345
@ SHAPE_TYPE_GROUP
Definition model.h:153
@ MODEL_PROP_KEY_GROUP_INFO
Definition model.h:146
Gfx * gMainGfxPos
Definition cam_main.c:14

Referenced by render_transform_group(), and render_transform_group_node().

◆ render_transform_group()

void render_transform_group ( void * group)

Definition at line 3034 of file model.c.

3034 {
3035 ModelTransformGroup* group = data;
3036 Gfx** gfx = &gMainGfxPos;
3037
3038 if (!(group->flags & TRANSFORM_GROUP_FLAG_INACTIVE)) {
3040 if (!(group->flags & TRANSFORM_GROUP_FLAG_IGNORE_MATRIX)) {
3041 gSPMatrix((*gfx)++, group->finalMtx, (G_MTX_PUSH | G_MTX_LOAD) | G_MTX_MODELVIEW);
3042 }
3043
3044 render_transform_group_node(group->baseModelNode);
3045
3046 if (!(group->flags & TRANSFORM_GROUP_FLAG_IGNORE_MATRIX)) {
3047 gSPPopMatrix((*gfx)++, G_MTX_MODELVIEW);
3048 }
3049 gDPPipeSync((*gfx)++);
3050 }
3051}
@ TRANSFORM_GROUP_FLAG_INACTIVE
Definition enums.h:5081
@ TRANSFORM_GROUP_FLAG_IGNORE_MATRIX
Definition enums.h:5084

Referenced by render_models().

◆ make_texture_gfx()

void make_texture_gfx ( TextureHeader * header,
Gfx ** gfxPos,
IMG_PTR raster,
PAL_PTR palette,
IMG_PTR auxRaster,
PAL_PTR auxPalette,
u8 auxShiftS,
u8 auxShiftT,
u16 auxOffsetS,
u16 auxOffsetT )

Definition at line 3053 of file model.c.

3053 {
3054 s32 mainWidth, mainHeight;
3055 s32 auxWidth, auxHeight;
3056 s32 mainFmt;
3057 s32 auxFmt;
3058 s32 mainWrapW, mainWrapH;
3059 s32 auxWrapW, auxWrapH;
3060 s32 extraTileType;
3062 s32 lod;
3063 s32 lodDivisor;
3065 s32 filteringMode;
3066 s32 auxPaletteIndex;
3067 s32 lutMode;
3068 s32 lodMode;
3069 s32 mainMasks, mainMaskt;
3070 s32 auxMasks, auxMaskt;
3071 s32 mainBitDepth;
3072 s32 auxBitDepth;
3073 s32 temp;
3074
3075 mainWidth = header->mainW;
3076 mainHeight = header->mainH;
3077
3078 lod = 0;
3079 auxPaletteIndex = 0;
3080
3083
3084 mainWrapW = header->mainWrapW;
3085 mainWrapH = header->mainWrapH;
3086
3087 mainFmt = header->mainFmt;
3088 mainBitDepth = header->mainBitDepth;
3089
3090 extraTileType = header->extraTiles;
3092
3093 auxWidth = header->auxW;
3094 auxHeight = header->auxH;
3095
3098
3099 auxWrapW = header->auxWrapW;
3100 auxWrapH = header->auxWrapH;
3101 auxFmt = header->auxFmt;
3102 auxBitDepth = header->auxBitDepth;
3103
3105 if (palette != NULL) {
3106 auxPaletteIndex = 1;
3107 } else {
3108 auxPaletteIndex = 0;
3109 }
3110 }
3111
3112 if (palette != NULL || auxPalette != NULL) {
3114 if (palette != NULL) {
3115 if (mainBitDepth == G_IM_SIZ_4b) {
3116 gDPLoadTLUT_pal16((*gfxPos)++, 0, palette);
3117 } else if (mainBitDepth == G_IM_SIZ_8b) {
3118 gDPLoadTLUT_pal256((*gfxPos)++, palette);
3119 }
3120 }
3121 if (auxPalette != NULL) {
3122 if (auxBitDepth == G_IM_SIZ_4b) {
3123 gDPLoadTLUT_pal16((*gfxPos)++, auxPaletteIndex, auxPalette);
3124 } else if (auxBitDepth == G_IM_SIZ_8b) {
3125 gDPLoadTLUT_pal256((*gfxPos)++, auxPalette);
3126 }
3127 }
3128 } else {
3130 }
3131
3132 // only the following aux combine modes are ever used:
3133 // (A) 0x00 -> 0, 0
3134 // (B) 0x08 -> 2, 0
3135 // (C) 0x0D -> 3, 1
3136 // (D) 0x10 -> 4, 0
3138 if (texCombineType >= 3) {
3139 // combine modes 3, 4, ... are directly appended to the end of the table and subtype is ignored
3141 } else {
3142 // select based on aux combine subtypes
3143 // in practice, auxCombineSubType is ALWAYS zero here since the only (A) and (B) may reach this block
3145 }
3146
3148 (*gfxPos)++;
3149
3150 switch (extraTileType) {
3151 case EXTRA_TILE_NONE:
3153 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3154 switch (mainBitDepth) {
3155 case G_IM_SIZ_4b:
3156 gDPLoadTextureBlock_4b((*gfxPos)++, raster, mainFmt,
3158 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3159 break;
3160 case G_IM_SIZ_8b:
3161 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_8b,
3163 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3164 break;
3165 case G_IM_SIZ_16b:
3166 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_16b,
3168 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3169 break;
3170 case 3:
3171 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_32b,
3173 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3174 break;
3175 }
3176 break;
3177 case EXTRA_TILE_MIPMAPS:
3178 lodMode = G_TL_LOD;
3179 switch (mainBitDepth) {
3180 case G_IM_SIZ_4b:
3181 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3182 mainWidth / lodDivisor * 4 >= 64 && mainHeight / lodDivisor != 0;
3184 {
3185 gDPLoadMultiTile_4b((*gfxPos)++, rasterPtr, (u32)(rasterPtr - raster) >> 3, lod, mainFmt,
3187 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3188 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3189 }
3190 break;
3191 case G_IM_SIZ_8b:
3192 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3193 mainWidth / lodDivisor * 8 >= 64 && mainHeight / lodDivisor != 0;
3195 {
3196 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 3, lod, mainFmt, G_IM_SIZ_8b,
3198 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3199 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3200 }
3201 break;
3202 case G_IM_SIZ_16b:
3203 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3204 mainWidth / lodDivisor * 16 >= 64 && mainHeight / lodDivisor != 0;
3206 {
3207 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 3, lod, mainFmt, G_IM_SIZ_16b,
3209 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3210 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3211 }
3212 break;
3213 case G_IM_SIZ_32b:
3214 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3215 mainWidth / lodDivisor * 32 >= 64 && mainHeight / lodDivisor != 0;
3217 {
3218 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 4, lod, mainFmt, G_IM_SIZ_32b,
3220 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3221 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3222 }
3223 break;
3224 }
3225 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, lod - 1, G_TX_RENDERTILE, G_ON);
3226 break;
3228 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3229 gDPPipeSync((*gfxPos)++);
3231 switch (mainBitDepth) {
3232 case G_IM_SIZ_4b:
3234 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3236 break;
3237 case G_IM_SIZ_8b:
3239 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3241 break;
3242 case G_IM_SIZ_16b:
3244 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3246 break;
3247 case G_IM_SIZ_32b:
3249 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3251 break;
3252 }
3253 break;
3255 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3257 switch (mainBitDepth) {
3258 case G_IM_SIZ_4b:
3259 gDPLoadTextureTile_4b((*gfxPos)++, raster, mainFmt, mainWidth, mainHeight,
3260 0, 0, mainWidth - 1, mainHeight - 1, 0,
3261 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3262 lodDivisor = (((mainWidth * mainHeight) >> 1) + 7)>>3; // required to use lodDivisor here
3263 break;
3264 case G_IM_SIZ_8b:
3265 gDPLoadTextureTile((*gfxPos)++, raster, mainFmt, G_IM_SIZ_8b, mainWidth, mainHeight,
3266 0, 0, mainWidth - 1, mainHeight - 1, 0,
3267 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3268 lodDivisor = ((mainWidth * mainHeight) + 7)>>3;
3269 break;
3270 case G_IM_SIZ_16b:
3272 0, 0, mainWidth - 1, mainHeight - 1, 0,
3273 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3274 lodDivisor = ((mainWidth * mainHeight) * 2 + 7)>>3;
3275 break;
3276 case G_IM_SIZ_32b:
3278 0, 0, mainWidth - 1, mainHeight - 1, 0,
3279 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3280 lodDivisor = ((mainWidth * mainHeight / 2) * 2 + 7)>>3;
3281 break;
3282 }
3283
3284 switch (auxBitDepth) {
3285 case G_IM_SIZ_4b:
3286 gDPScrollMultiTile_4b((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, auxWidth, auxHeight,
3287 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3288 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3290 break;
3291 case G_IM_SIZ_8b:
3292 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_8b, auxWidth, auxHeight,
3293 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3294 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3296 break;
3297 case G_IM_SIZ_16b:
3298 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_16b, auxWidth, auxHeight,
3299 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3300 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3302 break;
3303 case G_IM_SIZ_32b:
3304 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_32b, auxWidth, auxHeight,
3305 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3306 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3308 break;
3309 }
3310 }
3312}
#define IMG_PTR
#define gDPScrollMultiTile(pkt, timg, tmem, rtile, fmt, siz, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt)
Definition gbi_custom.h:116
#define gDPScrollTextureBlockHalfHeight_4b(pkt, timg, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt, shifts2, shiftt2)
Definition gbi_custom.h:173
#define gDPScrollTextureBlockHalfHeight(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt, shifts2, shiftt2)
Definition gbi_custom.h:143
#define gDPScrollMultiTile_4b(pkt, timg, tmem, rtile, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt)
Definition gbi_custom.h:88
Gfx SolidCombineModes[][5]
Definition model.c:245
@ 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
#define INTEGER_LOG2(x)

Referenced by appendGfx_model(), and load_texture_impl().

◆ load_model_transforms()

void load_model_transforms ( ModelNode * model,
ModelNode * parent,
Matrix4f mdlTxMtx,
s32 treeDepth )

Definition at line 3335 of file model.c.

3335 {
3337 Mtx sp50;
3342 s32 i;
3343
3344 if (model->groupData != NULL && model->groupData->numChildren != 0) {
3345 s32 groupType;
3346
3347 if (model->groupData->transformMatrix != NULL) {
3349
3350 guMtxL2F(tempMtx, model->groupData->transformMatrix);
3352 }
3353
3355 if (prop == NULL) {
3357 } else {
3358 groupType = prop->data.s;
3359 }
3360
3361 if (model->type != SHAPE_TYPE_GROUP || groupType == GROUP_TYPE_0) {
3362 for (i = 0; i < model->groupData->numChildren; i++) {
3363 load_model_transforms(model->groupData->childList[i], model,
3364 model->groupData->transformMatrix != NULL ? combinedMtx : mdlTransformMtx,
3365 treeDepth + 1);
3366 }
3367
3368 (*gCurrentModelTreeNodeInfo)[TreeIterPos].modelIndex = -1;
3369 (*gCurrentModelTreeNodeInfo)[TreeIterPos].treeDepth = treeDepth;
3370 TreeIterPos++;
3371 return;
3372 }
3373 }
3374
3376 modelBPptr->flags = 0;
3377 modelBPptr->mdlNode = model;
3378 modelBPptr->groupData = parent->groupData;
3379 modelBPptr->mtx = &sp50;
3380
3381 if (model->type == SHAPE_TYPE_GROUP) {
3383
3384 for (i = TreeIterPos; i < TreeIterPos + childCount; i++) {
3385 (*gCurrentModelTreeNodeInfo)[i].modelIndex = -1;
3386 (*gCurrentModelTreeNodeInfo)[i].treeDepth = treeDepth + 1;
3387 }
3389 }
3390
3392 (*gCurrentModelTreeNodeInfo)[TreeIterPos].treeDepth = treeDepth;
3393 TreeIterPos++;
3394}
f32 Matrix4f[4][4]
#define guMtxF2L
#define guMtxCatF
void load_model_transforms(ModelNode *model, ModelNode *parent, Matrix4f mdlTxMtx, s32 treeDepth)
Definition model.c:3335
s32 mdl_get_child_count(ModelNode *model)
Definition model.c:2346
void mdl_create_model(ModelBlueprint *bp, s32 unused)
Definition model.c:2472
@ GROUP_TYPE_0
Definition model.h:159

Referenced by load_data_for_models(), and load_model_transforms().

◆ is_identity_fixed_mtx()

s32 is_identity_fixed_mtx ( Mtx * mtx)
Returns
TRUE if mtx is NULL or identity.

Definition at line 3885 of file model.c.

3885 {
3886 s32* mtxIt = (s32*)mtx;
3887 s32* identityIt;
3888 s32 i;
3889
3890 if (mtx == NULL) {
3891 return TRUE;
3892 }
3893
3895
3896 for (i = 0; i < 16; i++, mtxIt++, identityIt++) {
3897 if (*mtxIt != *identityIt) {
3898 return FALSE;
3899 }
3900 }
3901
3902 return TRUE;
3903}
Mtx ReferenceIdentityMtx
Definition model.c:591

Referenced by mdl_create_model().

◆ build_custom_gfx()

void build_custom_gfx ( void )

Definition at line 3853 of file model.c.

3853 {
3854 Gfx* gfx = gMainGfxPos;
3857 s32 i;
3858
3859 // placeholder branch
3860 gSPBranchList(gMainGfxPos++, 0x00000000);
3861
3862 for (i = 0; i < ARRAY_COUNT(*gCurrentCustomModelGfxPtr) / 2; i++) {
3863 preFunc = (*gCurrentCustomModelGfxBuildersPtr)[i * 2];
3864
3865 if (preFunc != NULL) {
3866 (*gCurrentCustomModelGfxPtr)[i * 2] = gMainGfxPos;
3867 preFunc(i);
3869 }
3870
3871 postFunc = (*gCurrentCustomModelGfxBuildersPtr)[i * 2 + 1];
3872 if (postFunc != NULL) {
3873 (*gCurrentCustomModelGfxPtr)[i * 2 + 1] = gMainGfxPos;
3874 postFunc(i);
3876 }
3877 }
3878
3879 // overwrite placeholder with final branch address
3881}
ModelCustomGfxList * gCurrentCustomModelGfxPtr
Definition model.c:1310
void(* ModelCustomGfxBuilderFunc)(s32 index)
Definition model.h:136
#define ARRAY_COUNT(arr)
Definition macros.h:40

Referenced by mdl_update_transform_matrices().

◆ appendGfx_model()

void appendGfx_model ( void * data)

Definition at line 1368 of file model.c.

1368 {
1369 Model* model = data;
1370 s32 mtxPushMode;
1374 s8 renderMode;
1375 s32 renderClass;
1376 s32 renderModeIdx;
1377 s32 flags = model->flags;
1378
1379 ModelNode* modelNode;
1380 u16 customGfxIndex;
1381 s32 mtxLoadMode;
1382 s32 tintCombineType;
1384 s32 temp;
1385
1386 s32 fogMin, fogMax;
1387 s32 fogR, fogG, fogB, fogA;
1388 Gfx** gfxPos = &gMainGfxPos;
1389
1392 modelNode = model->modelNode;
1393
1394 if (model->textureID != 0) {
1395 textureHandle = &TextureHandles[model->textureID + model->textureVariation];
1397
1398 if (textureHandle->gfx != NULL) {
1400 } else {
1402 }
1403 } else {
1406 }
1407
1408 renderMode = model->renderMode;
1409 tintCombineType = 0;
1410
1411 if (textureHeader != NULL) {
1412 switch (extraTileType) {
1413 case EXTRA_TILE_NONE:
1415 break;
1416 case EXTRA_TILE_MIPMAPS:
1420 break;
1421 default:
1423 break;
1424 }
1425 } else {
1427 }
1428
1429 if (textureHeader != NULL || renderMode <= RENDER_MODES_LAST_OPAQUE) {
1433 }
1434 }
1435
1436 // if a model has a tint applied, set it up now
1437 switch ((u32)(model->customGfxIndex >> 4)) {
1438 case ENV_TINT_SHROUD:
1441 break;
1442 case ENV_TINT_DEPTH:
1443 if (renderMode <= RENDER_MODES_LAST_OPAQUE) {
1449 }
1450 break;
1451 case ENV_TINT_REMAP:
1456 break;
1457 }
1458
1459 gDPPipeSync((*gfxPos)++);
1460
1461 if (model->groupData != NULL) {
1462 Lightsn* lights = model->groupData->lightingGroup;
1463 if (model->groupData->lightingGroup != NULL) {
1464 switch (model->groupData->numLights) {
1465 case 0:
1466 gSPSetLights0((*gfxPos)++, lights[0]);
1467 break;
1468 case 1:
1469 gSPSetLights1((*gfxPos)++, lights[0]);
1470 break;
1471 case 2:
1472 gSPSetLights2((*gfxPos)++, lights[0]);
1473 break;
1474 case 3:
1475 gSPSetLights3((*gfxPos)++, lights[0]);
1476 break;
1477 case 4:
1478 gSPSetLights4((*gfxPos)++, lights[0]);
1479 break;
1480 case 5:
1481 gSPSetLights5((*gfxPos)++, lights[0]);
1482 break;
1483 case 6:
1484 gSPSetLights6((*gfxPos)++, lights[0]);
1485 break;
1486 case 7:
1487 gSPSetLights7((*gfxPos)++, lights[0]);
1488 break;
1489 }
1490 }
1491 }
1492
1493 if (textureHeader != NULL) {
1494 switch (extraTileType) {
1496 case EXTRA_TILE_4:
1498 if (prop != NULL) {
1499 s32 shift = prop->data.s;
1500 u16 offsetS = prop->dataType;
1501 s32 offsetT = prop->dataType;
1503 textureHandle->raster, textureHandle->palette,
1504 textureHandle->auxRaster, textureHandle->auxPalette,
1505 (shift >> 12) & 0xF, (shift >> 16) & 0xF,
1506 offsetS & 0xFFF, (offsetT >> 12) & 0xFFF);
1507
1508 } else {
1510 }
1511 break;
1512 default:
1514 break;
1515 }
1516 } else {
1517 gSPTexture((*gfxPos)++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
1521 }
1522
1523 // setup combine modes for main/aux texture blending when fog or tint is enabled
1525 || renderMode == RENDER_MODE_ALPHATEST
1526 || renderMode == RENDER_MODE_ALPHATEST_ONESIDED
1527 ) {
1529
1530 // only the following aux combine modes are ever used:
1531 // (A) 0x00 -> 0, 0
1532 // (B) 0x08 -> 2, 0
1533 // (C) 0x0D -> 3, 1
1534 // (D) 0x10 -> 4, 0
1535 if (textureHeader != NULL) {
1536 u32 auxCombineType = textureHeader->auxCombineType;
1537 if (auxCombineType >= 3) {
1538 // combine modes 3, 4, ... are directly appended to the end of the table and subtype is ignored
1539 texCombineType = TEX_COMBINE_3 + (auxCombineType - 3);
1540 } else {
1541 // select based on aux combine subtypes
1542 // in practice, auxCombineSubType is ALWAYS zero here since the only (A) and (B) may reach this block
1544 }
1545 }
1546
1547 if (!(renderMode == RENDER_MODE_ALPHATEST || renderMode == RENDER_MODE_ALPHATEST_ONESIDED)) {
1549 } else {
1551 }
1552 (*gfxPos)++;
1553 }
1554
1555 // setup geometry modes and render modes
1556 switch (renderClass) {
1557 case RENDER_CLASS_1CYC:
1558 switch (renderMode) {
1561 break;
1564 break;
1567 break;
1570 break;
1573 break;
1576 break;
1579 break;
1582 break;
1587 break;
1590 break;
1593 break;
1596 break;
1599 break;
1602 break;
1605 break;
1608 break;
1611 break;
1612 case RENDER_MODE_CLOUD:
1614 break;
1617 break;
1618 default:
1620 break;
1621 }
1623 break;
1624 case RENDER_CLASS_2CYC:
1625 switch (renderMode) {
1628 break;
1631 break;
1634 break;
1637 break;
1640 break;
1643 break;
1646 break;
1651 break;
1654 break;
1657 break;
1660 break;
1663 break;
1666 break;
1669 break;
1672 break;
1675 break;
1676 case RENDER_MODE_CLOUD:
1678 break;
1681 break;
1682 default:
1684 break;
1685 }
1687 break;
1688 case RENDER_CLASS_FOG:
1689 switch (renderMode) {
1692 break;
1695 break;
1698 break;
1701 break;
1704 break;
1707 break;
1710 break;
1715 break;
1718 break;
1721 break;
1724 break;
1727 break;
1730 break;
1733 break;
1736 break;
1739 break;
1740 case RENDER_MODE_CLOUD:
1742 break;
1745 break;
1746 default:
1748 break;
1749 }
1753 break;
1756 if (ShroudTintAmt == 255) {
1757 return;
1758 }
1760 switch (renderMode) {
1763 break;
1766 break;
1769 break;
1772 break;
1775 break;
1778 break;
1781 break;
1784 break;
1787 break;
1790 break;
1793 break;
1796 break;
1799 break;
1802 break;
1805 break;
1808 break;
1811 break;
1812 case RENDER_MODE_CLOUD:
1814 break;
1817 break;
1818 }
1821 gSPFogPosition((*gfxPos)++, 970, 1000);
1822 break;
1824 switch (renderMode) {
1827 break;
1830 break;
1833 break;
1836 break;
1839 break;
1842 break;
1845 break;
1850 break;
1853 break;
1856 break;
1859 break;
1862 break;
1865 break;
1868 break;
1871 break;
1874 break;
1875 case RENDER_MODE_CLOUD:
1877 break;
1880 break;
1881 default:
1883 break;
1884 }
1886
1887 // lerp between scene fog and shroud fog based on ShroudTintAmt
1891
1892 fogMin = (gFogSettings->startDistance * (255 - ShroudTintAmt) + 900 * ShroudTintAmt) / 255;
1893 fogMax = (gFogSettings->endDistance * (255 - ShroudTintAmt) + 1000 * ShroudTintAmt) / 255;
1894
1897 break;
1900 switch (renderMode) {
1903 break;
1906 break;
1909 break;
1912 break;
1913 case RENDER_MODE_CLOUD:
1915 break;
1918 break;
1919 default:
1921 break;
1922 }
1924 break;
1925 }
1926
1930 if (mtxPushMode != G_MTX_NOPUSH) {
1932 }
1933 if (mtxLoadMode != G_MTX_MUL) {
1935 }
1936 }
1937 } else {
1941 if (mtxPushMode != G_MTX_NOPUSH) {
1943 }
1944 }
1945 }
1946
1947 // custom gfx 'pre'
1949 customGfxIndex = (model->customGfxIndex & 0xF) * 2;
1950 if ((*gCurrentCustomModelGfxPtr)[customGfxIndex] != NULL) {
1951 gSPDisplayList((*gfxPos)++, (*gCurrentCustomModelGfxPtr)[customGfxIndex]);
1952 }
1953 }
1954
1955 // add tex panner gfx
1956 if (textureHeader != NULL) {
1958 s32 panMainU = texPannerMainU[model->texPannerID] >> 8;
1959 s32 panMainV = texPannerMainV[model->texPannerID] >> 8;
1960 s32 panAuxU = texPannerAuxU[model->texPannerID] >> 8;
1961 s32 panAuxV = texPannerAuxV[model->texPannerID] >> 8;
1962
1963 switch (extraTileType) {
1965 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE, panMainU, panMainV, (textureHeader->mainW - 1) * 4 + panMainU, (textureHeader->mainH / 2 - 1) * 4 + panMainV);
1966 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE + 1, panAuxU, panAuxV, (textureHeader->mainW - 1) * 4 + panAuxU, (textureHeader->mainH / 2 - 1) * 4 + panAuxV);
1967 break;
1969 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE, panMainU, panMainV, (textureHeader->mainW - 1) * 4 + panMainU, (textureHeader->mainH - 1) * 4 + panMainV);
1970 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE + 1, panAuxU, panAuxV, (textureHeader->auxW - 1) * 4 + panAuxU, (textureHeader->auxH - 1) * 4 + panAuxV);
1971 break;
1972 default:
1973 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE, panMainU, panMainV, (textureHeader->mainW - 1) * 4 + panMainU, (textureHeader->mainH - 1) * 4 + panMainV);
1974 break;
1975 }
1976 }
1977 }
1978
1981 if (mtxPushMode != G_MTX_NOPUSH) {
1983 }
1984 if (mtxLoadMode != G_MTX_MUL) {
1986 }
1987 }
1988
1989 // render the model
1991 gSPDisplayList((*gfxPos)++, modelNode->displayData->displayList);
1992 }
1993
1994 // custom gfx 'post'
1996 customGfxIndex++;
1997 if ((*gCurrentCustomModelGfxPtr)[customGfxIndex] != NULL) {
1998 gSPDisplayList((*gfxPos)++, (*gCurrentCustomModelGfxPtr)[customGfxIndex]);
1999 }
2000 }
2001
2002 if (mtxPushMode == G_MTX_NOPUSH) {
2004 }
2005
2006 gDPPipeSync((*gfxPos)++);
2007}
s8 flags
Definition demo_api.c:15
@ ENV_TINT_SHROUD
Definition enums.h:4386
@ ENV_TINT_DEPTH
Definition enums.h:4388
@ ENV_TINT_REMAP
Definition enums.h:4392
@ RENDER_MODE_IDX_1D
Definition enums.h:3223
@ RENDER_MODE_IDX_14
Definition enums.h:3214
@ RENDER_MODE_IDX_29
Definition enums.h:3236
@ RENDER_MODE_IDX_18
Definition enums.h:3218
@ RENDER_MODE_IDX_2B
Definition enums.h:3238
@ RENDER_MODE_IDX_0B
Definition enums.h:3204
@ RENDER_MODE_IDX_3A
Definition enums.h:3254
@ RENDER_MODE_IDX_1B
Definition enums.h:3221
@ RENDER_MODE_IDX_26
Definition enums.h:3233
@ RENDER_MODE_IDX_16
Definition enums.h:3216
@ RENDER_MODE_IDX_33
Definition enums.h:3246
@ RENDER_MODE_IDX_39
Definition enums.h:3253
@ RENDER_MODE_IDX_34
Definition enums.h:3247
@ RENDER_MODE_IDX_07
Definition enums.h:3200
@ RENDER_MODE_IDX_31
Definition enums.h:3244
@ RENDER_MODE_IDX_09
Definition enums.h:3202
@ RENDER_MODE_IDX_2A
Definition enums.h:3237
@ RENDER_MODE_IDX_02
Definition enums.h:3195
@ RENDER_MODE_IDX_27
Definition enums.h:3234
@ RENDER_MODE_IDX_3C
Definition enums.h:3256
@ RENDER_MODE_IDX_13
Definition enums.h:3213
@ RENDER_MODE_IDX_1F
Definition enums.h:3226
@ RENDER_MODE_IDX_0C
Definition enums.h:3205
@ RENDER_MODE_IDX_12
Definition enums.h:3212
@ RENDER_MODE_IDX_11
Definition enums.h:3211
@ RENDER_MODE_IDX_3B
Definition enums.h:3255
@ RENDER_MODE_IDX_38
Definition enums.h:3252
@ RENDER_MODE_IDX_22
Definition enums.h:3229
@ RENDER_MODE_IDX_25
Definition enums.h:3232
@ RENDER_MODE_IDX_23
Definition enums.h:3230
@ RENDER_MODE_IDX_19
Definition enums.h:3219
@ RENDER_MODE_IDX_32
Definition enums.h:3245
@ RENDER_MODE_IDX_30
Definition enums.h:3243
@ RENDER_MODE_IDX_06
Definition enums.h:3199
@ RENDER_MODE_IDX_28
Definition enums.h:3235
@ RENDER_MODE_IDX_20
Definition enums.h:3227
@ RENDER_MODE_IDX_1C
Definition enums.h:3222
@ RENDER_MODE_IDX_10
Definition enums.h:3210
@ RENDER_MODE_IDX_2C
Definition enums.h:3239
@ RENDER_MODE_IDX_37
Definition enums.h:3251
@ RENDER_MODE_IDX_2F
Definition enums.h:3242
@ RENDER_MODE_IDX_01
Definition enums.h:3194
@ RENDER_MODE_IDX_1A
Definition enums.h:3220
@ RENDER_MODE_IDX_35
Definition enums.h:3248
@ RENDER_MODE_IDX_08
Definition enums.h:3201
@ RENDER_MODE_IDX_0D
Definition enums.h:3206
@ RENDER_MODE_IDX_36
Definition enums.h:3249
@ RENDER_MODE_IDX_2E
Definition enums.h:3241
@ RENDER_MODE_IDX_04
Definition enums.h:3197
@ RENDER_MODE_IDX_17
Definition enums.h:3217
@ RENDER_MODE_IDX_0A
Definition enums.h:3203
@ RENDER_MODE_IDX_0E
Definition enums.h:3207
@ RENDER_MODE_IDX_21
Definition enums.h:3228
@ RENDER_MODE_IDX_03
Definition enums.h:3196
@ RENDER_MODE_IDX_00
Definition enums.h:3193
@ MODEL_FLAG_IGNORE_MATRIX
Definition enums.h:4369
@ MODEL_FLAG_HAS_LOCAL_VERTEX_COPY
Definition enums.h:4363
@ MODEL_FLAG_BILLBOARD
Definition enums.h:4364
@ MODEL_FLAG_USES_CUSTOM_GFX
Definition enums.h:4360
@ MODEL_FLAG_TRANSFORM_GROUP_MEMBER
Definition enums.h:4359
@ MODEL_FLAG_HAS_TEX_PANNER
Definition enums.h:4367
@ MODEL_FLAG_IGNORE_FOG
Definition enums.h:4362
@ 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_DECAL_XLU
Definition enums.h:3291
@ RENDER_MODE_SURFACE_OPA_NO_AA
Definition enums.h:3266
@ RENDER_MODE_SURFACE_XLU_NO_ZB
Definition enums.h:3285
@ RENDER_MODE_DECAL_OPA_NO_AA
Definition enums.h:3270
@ RENDER_MODE_SURFACE_XLU_ZB_ZUPD
Definition enums.h:3286
@ 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_CLOUD_NO_ZB
Definition enums.h:3313
@ RENDER_MODE_CLOUD
Definition enums.h:3312
@ RENDER_MODES_LAST_OPAQUE
Definition enums.h:3280
@ RENDER_MODE_ALPHATEST_NO_ZB
Definition enums.h:3279
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3282
@ RENDER_MODE_SURFACE_XLU_AA_ZB_ZUPD
Definition enums.h:3307
u8 RemapTintMinG
Definition model.c:588
s32 DepthTintEnd
Definition model.c:582
BSS s32 texPannerMainV[MAX_TEX_PANNERS]
Definition model.c:1341
s32 endDistance
Definition model.c:115
s32 startDistance
Definition model.c:114
BSS s32 texPannerAuxV[MAX_TEX_PANNERS]
Definition model.c:1343
u8 DepthTintBaseR
Definition model.c:573
TextureHandle TextureHandles[128]
Definition model.c:1355
u8 RemapTintMaxR
Definition model.c:584
u8 RemapTintMaxG
Definition model.c:585
u8 DepthTintBaseG
Definition model.c:574
u8 DepthTintColR
Definition model.c:577
BSS s32 texPannerAuxU[MAX_TEX_PANNERS]
Definition model.c:1342
u8 RemapTintMinB
Definition model.c:589
s32 DepthTintStart
Definition model.c:581
s32 enabled
Definition model.c:112
BSS FogSettings * gFogSettings
Definition model.c:1339
u8 RemapTintMaxB
Definition model.c:586
u8 ShroudTintR
Definition model.c:569
u8 RemapTintMinR
Definition model.c:587
Gfx * ModelRenderModes[]
Definition model.c:181
u8 DepthTintBaseA
Definition model.c:576
Gfx AlphaTestCombineModes[][5]
Definition model.c:408
void make_texture_gfx(TextureHeader *, Gfx **, IMG_PTR raster, PAL_PTR palette, IMG_PTR auxRaster, PAL_PTR auxPalette, u8, u8, u16, u16)
Definition model.c:3053
u8 ShroudTintAmt
Definition model.c:568
Color4i color
Definition model.c:113
u8 ShroudTintB
Definition model.c:571
u8 DepthTintColG
Definition model.c:578
BSS s32 texPannerMainU[MAX_TEX_PANNERS]
Definition model.c:1340
u8 DepthTintColB
Definition model.c:579
u8 ShroudTintG
Definition model.c:570
u8 DepthTintBaseB
Definition model.c:575
Gfx * displayList
Definition model.h:47
ModelDisplayData * displayData
Definition model.h:53
TextureHeader header
Definition model.h:121
@ EXTRA_TILE_4
Definition model.h:168
@ MODEL_PROP_KEY_SPECIAL
Definition model.h:145
#define PM_RM_SHROUD
Definition macros.h:278
Camera gCameras[4]
Definition cam_main.c:16
s16 gCurrentCamID
Definition cam_main.c:12

Referenced by func_80117D00(), mdl_draw_hidden_panel_surface(), render_models(), and render_transform_group_node().

◆ load_texture_impl()

void load_texture_impl ( u32 romOffset,
TextureHandle * handle,
TextureHeader * header,
s32 mainSize,
s32 mainPalSize,
s32 auxSize,
s32 auxPalSize )

Definition at line 2009 of file model.c.

2009 {
2010 Gfx** temp;
2011
2012 // load main img + palette to texture heap
2013 handle->raster = (IMG_PTR) TextureHeapPos;
2014 if (mainPalSize != 0) {
2015 handle->palette = (PAL_PTR) (TextureHeapPos + mainSize);
2016 } else {
2017 handle->palette = NULL;
2018 }
2022
2023 // load aux img + palette to texture heap
2024 if (auxSize != 0) {
2025 handle->auxRaster = (IMG_PTR) TextureHeapPos;
2026 if (auxPalSize != 0) {
2027 handle->auxPalette = (PAL_PTR) (TextureHeapPos + auxSize);
2028 } else {
2029 handle->auxPalette = NULL;
2030 }
2033 } else {
2034 handle->auxPalette = NULL;
2035 handle->auxRaster = NULL;
2036 }
2037
2038 // copy header data and create a display list for the texture
2039 handle->gfx = (Gfx*) TextureHeapPos;
2040 memcpy(&handle->header, header, sizeof(*header));
2041 make_texture_gfx(header, (Gfx**) &TextureHeapPos, handle->raster, handle->palette, handle->auxRaster, handle->auxPalette, 0, 0, 0, 0);
2042
2043 temp = (Gfx**) &TextureHeapPos;
2044 gSPEndDisplayList((*temp)++);
2045}
#define PAL_PTR
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:442
BSS void * TextureHeapPos
Definition model.c:1344

Referenced by load_texture_by_name(), and load_texture_variants().

◆ load_texture_by_name()

void load_texture_by_name ( ModelNodeProperty * propertyName,
s32 romOffset,
s32 size )

Definition at line 2047 of file model.c.

2047 {
2048 char* textureName = (char*)propertyName->data.p;
2050 s32 textureIdx = 0;
2052 u32 rasterSize;
2055 TextureHeader* header;
2057 s32 mainSize;
2058
2059 if (textureName == NULL) {
2060 (*gCurrentModelTreeNodeInfo)[TreeIterPos].textureID = 0;
2061 return;
2062 }
2063
2064 while (romOffset < startOffset + size) {
2066 header = &gCurrentTextureHeader;
2067
2068 rasterSize = header->mainW * header->mainH;
2069
2070 // compute mipmaps size
2071 if (header->mainBitDepth == G_IM_SIZ_4b) {
2072 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2073 s32 d = 2;
2074 while (header->mainW / d >= 16 && header->mainH / d > 0) {
2075 rasterSize += header->mainW / d * header->mainH / d;
2076 d *= 2;
2077 }
2078 }
2079 rasterSize /= 2;
2080 } else if (header->mainBitDepth == G_IM_SIZ_8b) {
2081 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2082 s32 d = 2;
2083 while (header->mainW / d >= 8 && header->mainH / d > 0) {
2084 rasterSize += header->mainW / d * header->mainH / d;
2085 d *= 2;
2086 }
2087 }
2088 } else if (header->mainBitDepth == G_IM_SIZ_16b) {
2089 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2090 s32 d = 2;
2091 while (header->mainW / d >= 4 && header->mainH / d > 0) {
2092 rasterSize += header->mainW / d * header->mainH / d;
2093 d *= 2;
2094 }
2095 }
2096 rasterSize *= 2;
2097 } else if (header->mainBitDepth == G_IM_SIZ_32b) {
2098 if (header->extraTiles == EXTRA_TILE_MIPMAPS) {
2099 s32 d = 2;
2100 while (header->mainW / d >= 2 && header->mainH / d > 0) {
2101 rasterSize += header->mainW / d * header->mainH / d;
2102 d *= 2;
2103 }
2104 }
2105 rasterSize *= 4;
2106 }
2107
2108 // compute palette size
2109 if (header->mainFmt == G_IM_FMT_CI) {
2110 paletteSize = 0x20;
2111 if (header->mainBitDepth == G_IM_SIZ_8b) {
2112 paletteSize = 0x200;
2113 }
2114 } else {
2115 paletteSize = 0;
2116 }
2117
2118 // compute aux tile size
2119 if (header->extraTiles == EXTRA_TILE_AUX_INDEPENDENT) {
2120 auxRasterSize = header->auxW * header->auxH;
2121 if (header->auxBitDepth == G_IM_SIZ_4b) {
2122 auxRasterSize /= 2;
2123 } else if (header->auxBitDepth == G_IM_SIZ_8b) {
2124 } else if (header->auxBitDepth == G_IM_SIZ_16b) {
2125 auxRasterSize *= 2;
2126 } else {
2127 if (header->auxBitDepth == G_IM_SIZ_32b) {
2128 auxRasterSize *= 4;
2129 }
2130 }
2131 if (header->auxFmt == G_IM_FMT_CI) {
2132 auxPaletteSize = 0x20;
2133 if (header->auxBitDepth == G_IM_SIZ_8b) {
2134 auxPaletteSize = 0x200;
2135 }
2136 } else {
2137 auxPaletteSize = 0;
2138 }
2139 } else {
2140 auxPaletteSize = 0;
2141 auxRasterSize = 0;
2142 }
2143
2144 if (strcmp(textureName, header->name) == 0) {
2145 // found the texture with `textureName`
2146 break;
2147 }
2148
2149 textureIdx++;
2150 mainSize = rasterSize + paletteSize + sizeof(*header);
2153 }
2154
2155 if (romOffset >= startOffset + 0x40000) {
2156 // did not find the texture with `textureName`
2157 printf("could not find texture '%s'\n", textureName);
2158 (*gCurrentModelTreeNodeInfo)[TreeIterPos].textureID = 0;
2159 return;
2160 }
2161
2162 (*gCurrentModelTreeNodeInfo)[TreeIterPos].textureID = textureIdx + 1;
2163 textureHandle = &TextureHandles[(*gCurrentModelTreeNodeInfo)[TreeIterPos].textureID];
2164 romOffset += sizeof(*header);
2165
2166 if (textureHandle->gfx == NULL) {
2169 }
2170}
int printf(const char *restrict fmt,...)
Definition is_debug.c:25
void load_texture_variants(u32 romOffset, s32 textureID, s32 baseOffset, s32 size)
Definition model.c:2173
void load_texture_impl(u32 romOffset, TextureHandle *handle, TextureHeader *header, s32 mainSize, s32 mainPalSize, s32 auxSize, s32 auxPalSize)
Definition model.c:2009

Referenced by load_next_model_textures().

◆ load_texture_variants()

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

Definition at line 2173 of file model.c.

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

Referenced by load_texture_by_name().

◆ get_model_property()

ModelNodeProperty * get_model_property ( ModelNode * node,
ModelPropertyKeys key )

Definition at line 2285 of file model.c.

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

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_next_model_textures()

void load_next_model_textures ( ModelNode * model,
s32 romOffset,
s32 texSize )

Definition at line 2299 of file model.c.

2299 {
2300 if (model->type != SHAPE_TYPE_MODEL) {
2301 if (model->groupData != NULL) {
2302 s32 numChildren = model->groupData->numChildren;
2303
2304 if (numChildren != 0) {
2305 s32 i;
2306
2307 for (i = 0; i < numChildren; i++) {
2308 load_next_model_textures(model->groupData->childList[i], romOffset, texSize);
2309 }
2310 }
2311 }
2312 } else {
2314 if (propTextureName != NULL) {
2316 }
2317 }
2318 TreeIterPos++;
2319}
void load_next_model_textures(ModelNode *model, s32 romOffset, s32 texSize)
Definition model.c:2299
void load_texture_by_name(ModelNodeProperty *propertyName, s32 romOffset, s32 size)
Definition model.c:2047
@ MODEL_PROP_KEY_TEXTURE_NAME
Definition model.h:144

Referenced by load_next_model_textures(), and mdl_load_all_textures().

◆ mdl_load_all_textures()

void mdl_load_all_textures ( ModelNode * rootModel,
s32 romOffset,
s32 size )

Definition at line 2322 of file model.c.

2322 {
2323 s32 baseOffset = 0;
2324
2325 // textures are loaded to the upper half of the texture heap when not in the world
2328 }
2329
2331
2332 if (rootModel != NULL && romOffset != 0 && size != 0) {
2333 s32 i;
2334
2335 for (i = 0; i < ARRAY_COUNT(TextureHandles); i++) {
2336 TextureHandles[i].gfx = NULL;
2337 }
2338
2339 TreeIterPos = 0;
2340 if (rootModel != NULL) {
2342 }
2343 }
2344}
@ CONTEXT_WORLD
Definition enums.h:3528
void * TextureHeapBase
Definition model.c:566
#define WORLD_TEXTURE_MEMORY_SIZE
Definition model.c:102
Gfx * gfx
Definition model.h:120
GameStatus * gGameStatusPtr
Definition main_loop.c:31

Referenced by load_data_for_models(), state_init_file_select(), and state_step_end_battle().

◆ mdl_get_child_count()

s32 mdl_get_child_count ( ModelNode * model)

Definition at line 2346 of file model.c.

2346 {
2347 s32 ret = 0;
2348
2349 if (model->type != SHAPE_TYPE_MODEL && model->groupData != NULL) {
2350 s32 numChildren = model->groupData->numChildren;
2351
2352 if (numChildren != 0) {
2353 s32 i;
2354
2355 ret += numChildren;
2356 for (i = 0; i < numChildren; i++) {
2357 ret += mdl_get_child_count(model->groupData->childList[i]);
2358 }
2359 }
2360 }
2361 return ret;
2362}

Referenced by func_8011B1D8(), load_model_transforms(), and mdl_get_child_count().

◆ clear_model_data()

void clear_model_data ( void )

Definition at line 2364 of file model.c.

2364 {
2365 s32 i;
2366
2376 ShroudTintAmt = 0;
2377 ShroudTintR = 0;
2378 ShroudTintG = 0;
2379 ShroudTintB = 0;
2381 } else {
2391 }
2392
2393 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
2394 (*gCurrentModels)[i] = 0;
2395 }
2396
2397 for (i = 0; i < ARRAY_COUNT(*gCurrentTransformGroups); i++) {
2398 (*gCurrentTransformGroups)[i] = 0;
2399 }
2400
2401 for (i = 0; i < ARRAY_COUNT(*gCurrentCustomModelGfxPtr); i++) {
2402 (*gCurrentCustomModelGfxPtr)[i] = 0;
2403 (*gCurrentCustomModelGfxBuildersPtr)[i] = 0;
2404 }
2405
2407
2408 for (i = 0; i < ARRAY_COUNT(*gCurrentModelTreeNodeInfo); i++) {
2409 (*gCurrentModelTreeNodeInfo)[i].modelIndex = -1;
2410 (*gCurrentModelTreeNodeInfo)[i].treeDepth = 0;
2411 (*gCurrentModelTreeNodeInfo)[i].textureID = 0;
2412 }
2413
2416 gFogSettings->color.r = 10;
2417 gFogSettings->color.g = 10;
2418 gFogSettings->color.b = 10;
2419 gFogSettings->color.a = 0;
2421 gFogSettings->endDistance = 1000;
2422
2423 for (i = 0; i < ARRAY_COUNT(texPannerAuxV); i++) {
2424 texPannerAuxV[i] = 0;
2425 texPannerAuxU[i] = 0;
2426 texPannerMainV[i] = 0;
2427 texPannerMainU[i] = 0;
2428 }
2429}
@ ENV_TINT_NONE
Definition enums.h:4384
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 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

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

◆ init_model_data()

◆ mdl_calculate_model_sizes()

void mdl_calculate_model_sizes ( void )

Definition at line 2455 of file model.c.

2455 {
2456 s32 i;
2457
2458 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
2459 Model* model = (*gCurrentModels)[i];
2460
2461 if (model != NULL) {
2463
2464 bb->halfSizeX = (bb->maxX - bb->minX) * 0.5;
2465 bb->halfSizeY = (bb->maxY - bb->minY) * 0.5;
2466 bb->halfSizeZ = (bb->maxZ - bb->minZ) * 0.5;
2468 }
2469 }
2470}
@ MODEL_FLAG_MATRIX_DIRTY
Definition enums.h:4368
@ MODEL_PROP_KEY_BOUNDING_BOX
Definition model.h:147

Referenced by state_step_end_battle(), and state_step_unpause().

◆ mdl_create_model()

void mdl_create_model ( ModelBlueprint * bp,
s32 unused )

Definition at line 2472 of file model.c.

2472 {
2473 ModelNode* node = bp->mdlNode;
2476 s32 modelIdx;
2477 Model* model;
2478 f32 x, y, z;
2479
2481 modelIdx = 0;
2482 if (prop != NULL) {
2483 s32 replaceWithFlame = (prop->data.s >> 4) & 0xF;
2484
2485 if (replaceWithFlame != 0) {
2487 if (prop != NULL) {
2489 EffectInstance* effect;
2490
2492 (bb->minX + bb->maxX) * 0.5f,
2493 bb->minY,
2494 (bb->minZ + bb->maxZ) * 0.5f,
2495 1.0f,
2496 &effect);
2497 return;
2498 }
2499 }
2500 }
2501
2503 if ((*gCurrentModels)[modelIdx] == NULL) {
2504 break;
2505 }
2506 }
2507
2508 (*gCurrentModels)[modelIdx] = model = heap_malloc(sizeof(*model));
2509 model->flags = bp->flags | MODEL_FLAG_VALID;
2510 model->modelID = TreeIterPos;
2511 model->modelNode = bp->mdlNode;
2512 model->groupData = bp->groupData;
2513 model->matrixFreshness = 0;
2514 node = model->modelNode;
2515
2517 if (prop != NULL) {
2518 model->texPannerID = prop->data.s & 0xF;
2519 } else {
2520 model->texPannerID = TEX_PANNER_0;
2521 }
2522 model->customGfxIndex = CUSTOM_GFX_0;
2523
2524 if (node->type != SHAPE_TYPE_GROUP) {
2526 } else {
2528
2529 if (prop != NULL) {
2530 // GROUP_INFO properties always come in pairs, with the second giving the render mode
2531 prop++;
2532 }
2533 }
2534
2535 if (prop != NULL) {
2536 model->renderMode = prop->data.s;
2537 } else {
2538 model->renderMode = RENDER_MODE_SURFACE_OPA;
2539 }
2540
2541 model->textureID = (*gCurrentModelTreeNodeInfo)[TreeIterPos].textureID;
2542 model->textureVariation = 0;
2543
2544 if (!is_identity_fixed_mtx(bp->mtx)) {
2545 model->bakedMtx = heap_malloc(sizeof(*model->bakedMtx));
2546 *model->bakedMtx = *bp->mtx;
2547 model->savedMtx = *model->bakedMtx;
2548 } else {
2549 model->bakedMtx = NULL;
2550 guMtxIdent(&model->savedMtx);
2552 }
2553
2554 guMtxIdentF(model->userTransformMtx);
2555 model->finalMtx = NULL;
2557 if (prop != NULL) {
2559
2560 x = (bb->minX + bb->maxX) * 0.5f;
2561 y = (bb->minY + bb->maxY) * 0.5f;
2562 z = (bb->minZ + bb->maxZ) * 0.5f;
2563 } else {
2564 x = y = z = 0.0f;
2565 }
2566
2567 if (model->bakedMtx != NULL) {
2568 guMtxXFML(model->bakedMtx, x, y, z, &x, &y, &z);
2569 }
2570
2571 model->center.x = x;
2572 model->center.y = y;
2573 model->center.z = z;
2574
2576 x = bb->maxX - bb->minX;
2577 y = bb->maxY - bb->minY;
2578 z = bb->maxZ - bb->minZ;
2579 bb->halfSizeX = x * 0.5;
2580 bb->halfSizeY = y * 0.5;
2581 bb->halfSizeZ = z * 0.5;
2582
2583 if (model->bakedMtx == NULL && x < 100.0f && y < 100.0f && z < 100.0f) {
2585 }
2586 (*gCurrentModelTreeNodeInfo)[TreeIterPos].modelIndex = modelIdx;
2587}
@ TEX_PANNER_0
Definition enums.h:4397
@ MODEL_FLAG_DO_BOUNDS_CULLING
Definition enums.h:4365
@ MODEL_FLAG_VALID
Definition enums.h:4356
@ CUSTOM_GFX_0
Definition enums.h:4420
void * heap_malloc(s32 size)
Definition heap.c:34
s32 is_identity_fixed_mtx(Mtx *mtx)
Definition model.c:3885

Referenced by load_model_transforms().

◆ mdl_update_transform_matrices()

void mdl_update_transform_matrices ( void )

Definition at line 2589 of file model.c.

2589 {
2592 f32 mX, mY, mZ;
2593 f32 mtgX, mtgY, mtgZ;
2594 Model* model;
2595 Mtx* curMtx;
2598 s32 i;
2599
2600 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
2601 model = (*gCurrentModels)[i];
2602 if (model != NULL && (model->flags != 0) && !(model->flags & MODEL_FLAG_INACTIVE)) {
2603 if (!(model->flags & MODEL_FLAG_MATRIX_DIRTY)) {
2604 if (model->matrixFreshness != 0) {
2605 // matrix was recalculated recently and stored on the matrix stack
2606 // since DisplayContexts alternate, we can fetch the previous matrix from the other context
2608 if (model->matrixFreshness == 0) {
2609 // since it hasn't changed in a few frames, cache the matrix
2610 model->savedMtx = *model->finalMtx;
2611 }
2612 // copy matrix from previous DisplayContext stack to current one
2613 curMtx = model->finalMtx;
2615 *model->finalMtx = *curMtx;
2616 } else {
2617 // transform matrix is not changed, have gfx build with saved matrix
2618 model->finalMtx = &model->savedMtx;
2619 }
2620 } else {
2621 // first frame with dirty matrix, need to recalculate it
2623 model->matrixFreshness = 2;
2624
2625 // write matrix to the matrix stack
2627 if (model->bakedMtx == NULL || (model->flags & MODEL_FLAG_TRANSFORM_GROUP_MEMBER)) {
2628 guMtxF2L(model->userTransformMtx, curMtx);
2629 } else {
2630 guMtxL2F(tempModelMtx, model->bakedMtx);
2631 guMtxCatF(model->userTransformMtx, tempModelMtx, tempModelMtx);
2633 }
2635
2636 // recalculate the center of the model with transformation applied
2638 mX = (bb->minX + bb->maxX) * 0.5f;
2639 mY = (bb->minY + bb->maxY) * 0.5f;
2640 mZ = (bb->minZ + bb->maxZ) * 0.5f;
2641 guMtxXFML(curMtx, mX, mY, mZ, &mX, &mY, &mZ);
2642 model->center.x = mX;
2643 model->center.y = mY;
2644 model->center.z = mZ;
2645
2646 // point matrix for gfx building to our matrix on the stack
2647 model->finalMtx = curMtx;
2648
2649 // disable bounds culling for models with dynamic transformations
2651 }
2652 }
2653 }
2654
2655 for (i = 0; i < ARRAY_COUNT((*gCurrentTransformGroups)); i++) {
2656 mtg = (*gCurrentTransformGroups)[i];
2657 if (mtg != NULL && mtg->flags != 0 && !(mtg->flags & TRANSFORM_GROUP_FLAG_INACTIVE)) {
2658 if (!(mtg->flags & TRANSFORM_GROUP_FLAG_MATRIX_DIRTY)) {
2659 if (mtg->matrixFreshness != 0) {
2660 // matrix was recalculated recently and stored on the matrix stack
2661 // since DisplayContexts alternate, we can fetch the previous matrix from the other context
2662 mtg->matrixFreshness--;
2663 if (mtg->matrixFreshness == 0) {
2664 // since it hasn't changed in a few frames, cache the matrix
2665 mtg->savedMtx = *mtg->finalMtx;
2666 }
2667 // copy matrix from previous DisplayContext stack to current one
2668 curMtx = mtg->finalMtx;
2670 *mtg->finalMtx = *curMtx;
2671 } else {
2672 // transform matrix is not changed, have gfx build with saved matrix
2673 mtg->finalMtx = &mtg->savedMtx;
2674 }
2675 } else {
2676 // first frame with dirty matrix, need to recalculate it
2678 mtg->matrixFreshness = 2;
2679
2680 // write matrix to the matrix stack
2682 if (mtg->bakedMtx == NULL) {
2683 guMtxF2L(mtg->userTransformMtx, curMtx);
2684 } else {
2685 guMtxL2F(tempGroupMtx, mtg->bakedMtx);
2686 guMtxCatF(mtg->userTransformMtx, tempGroupMtx, tempGroupMtx);
2688 }
2690
2691 // recalculate the center of the transform group with transformation applied
2693 mtgX = (bb->minX + bb->maxX) * 0.5f;
2694 mtgY = (bb->minY + bb->maxY) * 0.5f;
2695 mtgZ = (bb->minZ + bb->maxZ) * 0.5f;
2697 mtg->center.x = mtgX;
2698 mtg->center.y = mtgY;
2699 mtg->center.z = mtgZ;
2700
2701 // point matrix for gfx building to our matrix on the stack
2702 mtg->finalMtx = curMtx;
2703 }
2704 }
2705 }
2706
2708}
Mtx matrixStack[0x200]
@ TRANSFORM_GROUP_FLAG_MATRIX_DIRTY
Definition enums.h:5083
@ MODEL_FLAG_INACTIVE
Definition enums.h:4358
void build_custom_gfx(void)
Definition model.c:3853
u16 gMatrixListPos
Definition main_loop.c:44
DisplayContext * gDisplayContext
Definition cam_main.c:15

Referenced by render_frame().

◆ render_models()

void render_models ( void )

Definition at line 2710 of file model.c.

2710 {
2711 RenderTask rt;
2712 RenderTask* rtPtr = &rt;
2713 f32 outX, outY, outZ, outW;
2714 f32 m00, m01, m02, m03;
2715 f32 m10, m11, m12, m13;
2716 f32 m20, m21, m22, m23;
2717 f32 m30, m31, m32, m33;
2718 f32 centerX, centerY, centerZ;
2719 f32 bbx, bby, bbz;
2720
2722 Model* model;
2725 f32 xComp, yComp, zComp;
2726
2727 s32 distance;
2728 s32 notVisible;
2729 s32 i;
2730
2731#define TEST_POINT_VISIBILITY \
2732 outX = (m00 * xComp) + (m10 * yComp) + (m20 * zComp) + m30; \
2733 outY = (m01 * xComp) + (m11 * yComp) + (m21 * zComp) + m31; \
2734 outZ = (m02 * xComp) + (m12 * yComp) + (m22 * zComp) + m32; \
2735 outW = (m03 * xComp) + (m13 * yComp) + (m23 * zComp) + m33; \
2736 if (outW == 0.0f) { \
2737 break; \
2738 } \
2739 /* Perspective divide */ \
2740 outW = 1.0f / outW; \
2741 xComp = outX * outW; \
2742 yComp = outY * outW; \
2743 zComp = outZ * outW; \
2744 if (zComp > -1.0f && xComp >= -1.0f && xComp <= 1.0f && yComp >= -1.0f && yComp <= 1.0f) { \
2745 break; \
2746 }
2747
2748 m00 = camera->mtxPerspective[0][0];
2749 m01 = camera->mtxPerspective[0][1];
2750 m02 = camera->mtxPerspective[0][2];
2751 m03 = camera->mtxPerspective[0][3];
2752 m10 = camera->mtxPerspective[1][0];
2753 m11 = camera->mtxPerspective[1][1];
2754 m12 = camera->mtxPerspective[1][2];
2755 m13 = camera->mtxPerspective[1][3];
2756 m20 = camera->mtxPerspective[2][0];
2757 m21 = camera->mtxPerspective[2][1];
2758 m22 = camera->mtxPerspective[2][2];
2759 m23 = camera->mtxPerspective[2][3];
2760 m30 = camera->mtxPerspective[3][0];
2761 m31 = camera->mtxPerspective[3][1];
2762 m32 = camera->mtxPerspective[3][2];
2763 m33 = camera->mtxPerspective[3][3];
2764
2765 // enqueue all visible models not in transform groups
2766 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
2767 model = (*gCurrentModels)[i];
2768 if (model == NULL) {
2769 continue;
2770 }
2771 if (model->flags == 0) {
2772 continue;
2773 }
2774 if (model->flags & MODEL_FLAG_INACTIVE) {
2775 continue;
2776 }
2777 if (model->flags & MODEL_FLAG_HIDDEN) {
2778 continue;
2779 }
2780 if (model->flags & MODEL_FLAG_20) {
2781 continue;
2782 }
2784 continue;
2785 }
2786
2787 centerX = model->center.x;
2788 centerY = model->center.y;
2789 centerZ = model->center.z;
2790
2791 // for models that are small enough to do bounds culling, only render if at least one
2792 // corner of its boundary box is visible
2793 if (model->flags & MODEL_FLAG_DO_BOUNDS_CULLING) {
2794 notVisible = FALSE;
2795 boundingBox = (ModelBoundingBox*) model->modelNode->propertyList;
2796 bbx = boundingBox->halfSizeX;
2797 bby = boundingBox->halfSizeY;
2798 bbz = boundingBox->halfSizeZ;
2799
2800 while (TRUE) {
2801 if (TRUE) {
2802 xComp = centerX - bbx;
2803 yComp = centerY - bby;
2804 zComp = centerZ - bbz;
2806 }
2807
2808 if (bbx != 0.0f) {
2809 xComp = centerX + bbx;
2810 yComp = centerY - bby;
2811 zComp = centerZ - bbz;
2813 }
2814
2815 if (bby != 0.0f) {
2816 xComp = centerX - bbx;
2817 yComp = centerY + bby;
2818 zComp = centerZ - bbz;
2820 }
2821
2822 if (bbx != 0.0f && bby != 0.0f) {
2823 xComp = centerX + bbx;
2824 yComp = centerY + bby;
2825 zComp = centerZ - bbz;
2827 }
2828
2829 if (bbz != 0.0f) {
2830 xComp = centerX - bbx;
2831 yComp = centerY - bby;
2832 zComp = centerZ + bbz;
2834 }
2835
2836 if (bbx != 0.0f && bbz != 0.0f) {
2837 xComp = centerX + bbx;
2838 yComp = centerY - bby;
2839 zComp = centerZ + bbz;
2841 }
2842
2843 if (bby != 0.0f && bbz != 0.0f) {
2844 xComp = centerX - bbx;
2845 yComp = centerY + bby;
2846 zComp = centerZ + bbz;
2848 }
2849
2850 if (bbx != 0.0f && bby != 0.0f && bbz != 0.0f) {
2851 xComp = centerX + bbx;
2852 yComp = centerY + bby;
2853 zComp = centerZ + bbz;
2855 }
2856 notVisible = TRUE;
2857 break;
2858 }
2859 // no points of the models bounding box were visible
2860 if (notVisible) {
2861 continue;
2862 }
2863 }
2864
2865 // map all model depths to the interval [0, 10k] and submit render task
2866 transform_point(camera->mtxPerspective, centerX, centerY, centerZ, 1.0f, &outX, &outY, &outZ, &outW);
2867 distance = outZ + 5000.0f;
2868 if (distance < 0) {
2869 distance = 0;
2870 } else if (distance > 10000) {
2871 distance = 10000;
2872 }
2873 rtPtr->appendGfxArg = model;
2874 if (model->modelNode->type == SHAPE_TYPE_GROUP) {
2875 rtPtr->appendGfx = appendGfx_model_group;
2876 } else {
2877 rtPtr->appendGfx = appendGfx_model;
2878 }
2879 rtPtr->dist = -distance;
2880 rtPtr->renderMode = model->renderMode;
2882 }
2883
2884 // enqueue models in transform groups
2885 // only the center of the group is used for depth sorting
2886 for (i = 0; i < ARRAY_COUNT(*gCurrentTransformGroups); i++) {
2887 transformGroup = (*gCurrentTransformGroups)[i];
2888 if (transformGroup == NULL) {
2889 continue;
2890 }
2891
2892 if (transformGroup->flags == 0) {
2893 continue;
2894 }
2895
2897 continue;
2898 }
2899
2900 xComp = transformGroup->center.x;
2901 yComp = transformGroup->center.y;
2902 zComp = transformGroup->center.z;
2903
2905 camera->mtxPerspective,
2906 xComp, yComp, zComp, 1.0f,
2907 &outX, &outY, &outZ, &outW
2908 );
2909 if (outW == 0.0f) {
2910 outW = 1.0f;
2911 }
2912
2913 distance = ((outZ / outW) * 10000.0f);
2914
2916 rtPtr->appendGfx = render_transform_group;
2917 rtPtr->appendGfxArg = transformGroup;
2918 rtPtr->dist = -distance;
2919 rtPtr->renderMode = transformGroup->renderMode;
2921 }
2922 }
2923}
#define transform_point
#define queue_render_task
@ TRANSFORM_GROUP_FLAG_HIDDEN
Definition enums.h:5080
@ MODEL_FLAG_20
Definition enums.h:4361
void render_transform_group(void *group)
Definition model.c:3034
#define TEST_POINT_VISIBILITY
s32 gCurrentCameraID
Definition cam_math.c:5

Referenced by render_frame().

◆ get_model_from_list_index()

◆ load_data_for_models()

void load_data_for_models ( ModelNode * rootModel,
s32 texturesOffset,
s32 size )

Definition at line 3318 of file model.c.

3318 {
3319 Matrix4f mtx;
3320
3321 guMtxIdentF(mtx);
3322
3323 if (texturesOffset != 0) {
3325 }
3326
3328 TreeIterPos = 0;
3329
3330 if (rootModel != NULL) {
3332 }
3333}
void mdl_load_all_textures(ModelNode *rootModel, s32 romOffset, s32 size)
Definition model.c:2322

Referenced by btl_state_update_normal_start(), and load_map_by_IDs().

◆ get_model_list_index_from_tree_index()

s32 get_model_list_index_from_tree_index ( s32 treeIndex)

Definition at line 3396 of file model.c.

3396 {
3397 s32 i;
3398
3399 if (treeIndex < MAX_MODELS) {
3400 u8 modelIndex = (*gCurrentModelTreeNodeInfo)[treeIndex].modelIndex;
3401
3402 if (modelIndex != (u8)-1) {
3403 return modelIndex;
3404 }
3405 }
3406
3407 for (i = 0; i < MAX_MODELS; i++) {
3409
3410 if (model != NULL && model->modelID == treeIndex) {
3411 return i;
3412 }
3413 }
3414 return 0;
3415}
#define MAX_MODELS
Definition macros.h:88

Referenced by animator_node_update_model_transform(), clone_model(), get_model_center_and_size(), hide_foreground_models(), hide_foreground_models_unchecked(), is_model_center_visible(), mdl_draw_hidden_panel_surface(), mdl_make_local_vertex_copy(), mdl_make_transform_group(), mdl_project_tex_coords(), show_foreground_models(), and show_foreground_models_unchecked().

◆ get_transform_group_index()

s32 get_transform_group_index ( s32 modelID)

Definition at line 3417 of file model.c.

3417 {
3419 s32 i;
3420
3421 for (i = 0; i < MAX_MODEL_TRANSFORM_GROUPS; i++) {
3423
3424 if (group != NULL && group->groupModelID == modelID) {
3425 return i;
3426 }
3427 }
3428
3429 return -1;
3430}
ModelTransformGroup * get_transform_group(s32 index)
Definition model.c:3452
#define MAX_MODEL_TRANSFORM_GROUPS
Definition macros.h:89

Referenced by disable_transform_group(), and enable_transform_group().

◆ get_model_center_and_size()

void get_model_center_and_size ( u16 modelID,
f32 * centerX,
f32 * centerY,
f32 * centerZ,
f32 * sizeX,
f32 * sizeY,
f32 * sizeZ )

Definition at line 3432 of file model.c.

3432 {
3434 ModelNode* node = model->modelNode;
3436
3437 *centerX = model->center.x;
3438 *centerY = model->center.y;
3439 *centerZ = model->center.z;
3440
3442
3443 if (bb != NULL) {
3444 *sizeX = bb->halfSizeX;
3445 *sizeY = bb->halfSizeY;
3446 *sizeZ = bb->halfSizeZ;
3447 } else {
3448 *sizeX = *sizeY = *sizeZ = 0.0f;
3449 }
3450}
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3396

◆ get_transform_group()

ModelTransformGroup * get_transform_group ( s32 index)

Definition at line 3452 of file model.c.

3452 {
3453 return (*gCurrentTransformGroups)[index];
3454}

Referenced by disable_transform_group(), enable_transform_group(), and get_transform_group_index().

◆ func_8011B1D8()

void func_8011B1D8 ( ModelNode * node)

Definition at line 3457 of file model.c.

3457 {
3460 s32 numChildren;
3461 s32 i;
3462 u16 currentID;
3463
3464 // stop searching if node is a model
3465 if (node->type == SHAPE_TYPE_MODEL) {
3467 return;
3468 }
3469
3470 // stop searching if node is a group with GROUP_TYPE_0
3471 if (node->type == SHAPE_TYPE_GROUP) {
3473 if (prop != NULL && prop->data.s != GROUP_TYPE_0) {
3476 return;
3477 }
3478 }
3479
3480 if (node->groupData != NULL) {
3481 numChildren = node->groupData->numChildren;
3482 if (numChildren != 0) {
3483 for (i = 0; i < numChildren; i++) {
3484 currentNode = node->groupData->childList[i];
3486
3487 if (currentNode->type == SHAPE_TYPE_GROUP) {
3489 if (prop != NULL && prop->data.s != GROUP_TYPE_0) {
3491 }
3492 }
3494
3495 if (mtg_FoundModelNode != NULL) {
3496 // not possible
3497 return;
3498 }
3499
3500 // the current model is the one we're looking for
3504 return;
3505 }
3506
3507 TreeIterPos++;
3508 }
3509 }
3510 }
3511}
void func_8011B1D8(ModelNode *node)
Definition model.c:3457
BSS u16 mtg_MaxChild
Definition model.c:1349
BSS ModelNode * mtg_FoundModelNode
Definition model.c:1347
BSS u16 mtg_SearchModelID
Definition model.c:1346
BSS u16 mtg_MinChild
Definition model.c:1348

Referenced by func_8011B1D8(), and mdl_make_transform_group().

◆ mdl_make_transform_group()

void mdl_make_transform_group ( u16 modelID)

Definition at line 3513 of file model.c.

3513 {
3514 TreeIterPos = 0;
3516 mtg_SearchModelID = modelID;
3517 mtg_MaxChild = 0;
3518 mtg_MinChild = 0;
3520
3521 if (mtg_FoundModelNode != NULL) {
3523 ModelNode* node;
3526 f32 x, y, z;
3527 s32 i;
3528
3529 for (i = 0; i < ARRAY_COUNT(*gCurrentTransformGroups); i++) {
3530 if ((*gCurrentTransformGroups)[i] == NULL) {
3531 break;
3532 }
3533 }
3534
3535 (*gCurrentTransformGroups)[i] = newMtg = heap_malloc(sizeof(*newMtg));
3537 newMtg->groupModelID = modelID;
3540 newMtg->matrixFreshness = 0;
3541 newMtg->bakedMtx = NULL;
3542 newMtg->baseModelNode = mtg_FoundModelNode;
3543 guMtxIdent(&newMtg->savedMtx);
3545 guMtxIdentF(newMtg->userTransformMtx);
3546
3547 node = newMtg->baseModelNode;
3548
3549 if (node->type != SHAPE_TYPE_GROUP) {
3551 } else {
3553
3554 if (prop != NULL) {
3555 // GROUP_INFO properties always come in pairs, with the second giving the render mode
3556 prop++;
3557 }
3558 }
3559
3560 if (prop != NULL) {
3561 newMtg->renderMode = prop->data.s;
3562 } else {
3563 newMtg->renderMode = RENDER_MODE_SURFACE_OPA;
3564 }
3565
3567 if (bb != NULL) {
3568 x = (bb->minX + bb->maxX) * 0.5f;
3569 y = (bb->minY + bb->maxY) * 0.5f;
3570 z = (bb->minZ + bb->maxZ) * 0.5f;
3571 } else {
3572 x = y = z = 0.0f;
3573 }
3574
3575 if (newMtg->bakedMtx != NULL) {
3576 guMtxXFML(newMtg->bakedMtx, x, y, z, &x, &y, &z);
3577 }
3578
3579 newMtg->center.x = x;
3580 newMtg->center.y = y;
3581 newMtg->center.z = z;
3582 enable_transform_group(modelID);
3583 }
3584}
@ TRANSFORM_GROUP_FLAG_VALID
Definition enums.h:5079
void enable_transform_group(u16 modelID)
Definition model.c:3586

◆ enable_transform_group()

void enable_transform_group ( u16 modelID)

Definition at line 3586 of file model.c.

3586 {
3588 s32 i;
3589
3591
3592 for (i = group->minChildModelIndex; i <= group->maxChildModelIndex; i++) {
3594
3596
3597 if (model->bakedMtx != NULL) {
3599 }
3600 }
3601}
s32 get_transform_group_index(s32 modelID)
Definition model.c:3417

Referenced by mdl_make_transform_group().

◆ disable_transform_group()

void disable_transform_group ( u16 modelID)

Definition at line 3603 of file model.c.

3603 {
3605 s32 i;
3606
3608
3609 for (i = group->minChildModelIndex; i <= group->maxChildModelIndex; i++) {
3611
3613
3614 if (model->bakedMtx != NULL) {
3616 }
3617 }
3618}

◆ clone_model()

void clone_model ( u16 srcModelID,
u16 newModelID )

Definition at line 3620 of file model.c.

3620 {
3622 Model* newModel;
3623 s32 i;
3624
3625 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
3626 if ((*gCurrentModels)[i] == NULL) {
3627 break;
3628 }
3629 }
3630
3631 (*gCurrentModels)[i] = newModel = heap_malloc(sizeof(*newModel));
3632 *newModel = *srcModel;
3633 newModel->modelID = newModelID;
3634}

◆ mdl_group_set_visibility()

void mdl_group_set_visibility ( u16 treeIndex,
s32 flags,
s32 mode )

Definition at line 3636 of file model.c.

3636 {
3637 s32 maxGroupIndex = -1;
3638 s32 minGroupIndex;
3639 s32 modelIndex = (*gCurrentModelTreeNodeInfo)[treeIndex].modelIndex;
3640 s32 siblingIndex;
3641 s32 i;
3642
3643 if (modelIndex < MAX_MODELS - 1) {
3644 minGroupIndex = maxGroupIndex = modelIndex;
3645 } else {
3646 s32 treeDepth = (*gCurrentModelTreeNodeInfo)[treeIndex].treeDepth;
3647 for (i = treeIndex - 1; i >= 0; i--) {
3648 if ((*gCurrentModelTreeNodeInfo)[i].treeDepth <= treeDepth) {
3649 break;
3650 }
3651
3652 siblingIndex = (*gCurrentModelTreeNodeInfo)[i].modelIndex;
3653
3654 if (siblingIndex < MAX_MODELS - 1) {
3655 if (maxGroupIndex == -1) {
3657 }
3659 }
3660 }
3661 }
3662
3663 if (mode < 2) {
3664 for (i = minGroupIndex; i <= maxGroupIndex; i++) {
3665 Model* model = (*gCurrentModels)[i];
3666 if (mode != MODEL_GROUP_HIDDEN) {
3667 model->flags &= ~flags;
3668 } else {
3669 model->flags |= flags;
3670 }
3671 }
3672 } else {
3673 for (i = 0; i < minGroupIndex; i++) {
3674 Model* model = (*gCurrentModels)[i];
3675 if (mode == MODEL_GROUP_OTHERS_VISIBLE) {
3676 model->flags &= ~flags;
3677 } else {
3678 model->flags |= flags;
3679 }
3680 }
3681 for (i = maxGroupIndex + 1; i < MAX_MODELS; i++) {
3682 Model* model = (*gCurrentModels)[i];
3683 if (model != NULL) {
3684 if (mode == MODEL_GROUP_OTHERS_VISIBLE) {
3685 model->flags &= ~flags;
3686 } else {
3687 model->flags |= flags;
3688 }
3689 }
3690 }
3691 }
3692}
@ MODEL_GROUP_OTHERS_VISIBLE
Definition enums.h:4378
@ MODEL_GROUP_HIDDEN
Definition enums.h:4375
u16 flags
Definition model.h:60

◆ mdl_group_set_custom_gfx()

void mdl_group_set_custom_gfx ( u16 groupModelID,
s32 customGfxIndex,
s32 tintType,
b32 invertSelection )

Definition at line 3694 of file model.c.

3694 {
3695 s32 maxGroupIndex = -1;
3696 s32 i;
3697 s32 minGroupIndex;
3698 s32 modelIndex = (*gCurrentModelTreeNodeInfo)[groupModelID].modelIndex;
3699 s32 siblingIndex;
3700 s32 maskLow, maskHigh, packed;
3701
3702 if (modelIndex < MAX_MODELS - 1) {
3703 minGroupIndex = maxGroupIndex = modelIndex;
3704 } else {
3705 s32 treeDepth = (*gCurrentModelTreeNodeInfo)[groupModelID].treeDepth;
3706 for (i = groupModelID - 1; i >= 0; i--) {
3707 if ((*gCurrentModelTreeNodeInfo)[i].treeDepth <= treeDepth) {
3708 break;
3709 }
3710
3711 siblingIndex = (*gCurrentModelTreeNodeInfo)[i].modelIndex;
3712
3713 if (siblingIndex < MAX_MODELS - 1) {
3714 if (maxGroupIndex == -1) {
3716 }
3718 }
3719 }
3720 }
3721
3722 maskLow = maskHigh = 0;
3723
3724 if (customGfxIndex < 0) {
3725 maskLow = 0xF;
3726 customGfxIndex = 0;
3727 }
3728
3729 if (tintType < 0) {
3730 maskHigh = 0xF0;
3731 tintType = 0;
3732 }
3733
3734 packed = customGfxIndex + (tintType << 4);
3735
3736 if (!invertSelection) {
3737 for (i = minGroupIndex; i <= maxGroupIndex; i++) {
3738 Model* model = (*gCurrentModels)[i];
3739 model->customGfxIndex = (model->customGfxIndex & (maskLow + maskHigh)) + packed;
3740 }
3741 } else {
3742 for (i = 0; i < minGroupIndex; i++) {
3743 Model* model = (*gCurrentModels)[i];
3744 model->customGfxIndex = (model->customGfxIndex & (maskLow + maskHigh)) + packed;
3745 }
3746 for (i = maxGroupIndex + 1; i < MAX_MODELS; i++) {
3747 Model* model = (*gCurrentModels)[i];
3748 if (model != NULL) {
3749 model->customGfxIndex = (model->customGfxIndex & (maskLow + maskHigh)) + packed;
3750 }
3751 }
3752 }
3753}
u8 customGfxIndex
Definition model.h:71

◆ mdl_reset_transform_flags()

void mdl_reset_transform_flags ( void )

Definition at line 3755 of file model.c.

3755 {
3756 s32 i;
3757
3758 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
3759 Model* model = (*gCurrentModels)[i];
3760
3761 if (model != NULL) {
3763 }
3764 }
3765
3766 for (i = 0; i < ARRAY_COUNT(*gCurrentTransformGroups); i++) {
3767 ModelTransformGroup* transformGroup = (*gCurrentTransformGroups)[i];
3768
3769 if (transformGroup != NULL) {
3771 }
3772 }
3773}

Referenced by step_game_loop().

◆ enable_world_fog()

void enable_world_fog ( void )

Definition at line 3775 of file model.c.

3775 {
3777}

◆ disable_world_fog()

void disable_world_fog ( void )

Definition at line 3779 of file model.c.

3779 {
3781}

◆ set_world_fog_dist()

void set_world_fog_dist ( s32 start,
s32 end )

Definition at line 3783 of file model.c.

3783 {
3784 gFogSettings->startDistance = start;
3786}

◆ set_world_fog_color()

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

Definition at line 3788 of file model.c.

3788 {
3789 gFogSettings->color.r = r;
3790 gFogSettings->color.g = g;
3791 gFogSettings->color.b = b;
3792 gFogSettings->color.a = a;
3793}

◆ is_world_fog_enabled()

s32 is_world_fog_enabled ( void )

Definition at line 3795 of file model.c.

3795 {
3796 return gFogSettings->enabled;
3797}

Referenced by appendGfx_background_texture(), and tattle_cam_pre_render().

◆ get_world_fog_distance()

void get_world_fog_distance ( s32 * start,
s32 * end )

Definition at line 3799 of file model.c.

3799 {
3800 *start = gFogSettings->startDistance;
3801 *end = gFogSettings->endDistance;
3802}

◆ get_world_fog_color()

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

Definition at line 3804 of file model.c.

3804 {
3805 *r = gFogSettings->color.r;
3806 *g = gFogSettings->color.g;
3807 *b = gFogSettings->color.b;
3808 *a = gFogSettings->color.a;
3809}

Referenced by appendGfx_background_texture(), and tattle_cam_pre_render().

◆ set_tex_panner()

void set_tex_panner ( Model * model,
s32 texPannerID )

Definition at line 3811 of file model.c.

3811 {
3812 model->texPannerID = texPannerID;
3813}

◆ set_main_pan_u()

void set_main_pan_u ( s32 texPannerID,
s32 value )

Definition at line 3815 of file model.c.

3815 {
3816 texPannerMainU[texPannerID] = value;
3817}

◆ set_main_pan_v()

void set_main_pan_v ( s32 texPannerID,
s32 value )

Definition at line 3819 of file model.c.

3819 {
3820 texPannerMainV[texPannerID] = value;
3821}

◆ set_aux_pan_u()

void set_aux_pan_u ( s32 texPannerID,
s32 value )

Definition at line 3823 of file model.c.

3823 {
3824 texPannerAuxU[texPannerID] = value;
3825}

◆ set_aux_pan_v()

void set_aux_pan_v ( s32 texPannerID,
s32 value )

Definition at line 3827 of file model.c.

3827 {
3828 texPannerAuxV[texPannerID] = value;
3829}

◆ set_mdl_custom_gfx_set()

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

Definition at line 3831 of file model.c.

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

Referenced by mdl_set_all_tint_type().

◆ set_custom_gfx()

void set_custom_gfx ( s32 customGfxIndex,
Gfx * pre,
Gfx * post )

Definition at line 3843 of file model.c.

3843 {
3844 (*gCurrentCustomModelGfxPtr)[customGfxIndex * 2] = pre;
3845 (*gCurrentCustomModelGfxPtr)[customGfxIndex * 2 + 1] = post;
3846}

◆ set_custom_gfx_builders()

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

Definition at line 3848 of file model.c.

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

◆ mdl_set_shroud_tint_params()

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

Definition at line 3905 of file model.c.

3905 {
3906 ShroudTintR = r;
3907 ShroudTintG = g;
3908 ShroudTintB = b;
3909 ShroudTintAmt = a;
3910}

Referenced by btl_state_update_celebration().

◆ mdl_get_shroud_tint_params()

void mdl_get_shroud_tint_params ( u8 * r,
u8 * g,
u8 * b,
u8 * a )

Definition at line 3912 of file model.c.

3912 {
3913 *r = ShroudTintR;
3914 *g = ShroudTintG;
3915 *b = ShroudTintB;
3916 *a = ShroudTintAmt;
3917}

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

3919 {
3920 DepthTintBaseR = primR;
3921 DepthTintBaseG = primG;
3922 DepthTintBaseB = primB;
3923 DepthTintBaseA = primA;
3929}

◆ mdl_get_depth_tint_params()

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

Definition at line 3931 of file model.c.

3932 {
3933 *primR = DepthTintBaseR;
3934 *primG = DepthTintBaseG;
3935 *primB = DepthTintBaseB;
3936 *primA = DepthTintBaseA;
3942}

◆ mdl_set_remap_tint_params()

void mdl_set_remap_tint_params ( u8 maxR,
u8 maxG,
u8 maxB,
u8 minR,
u8 minG,
u8 minB )

Definition at line 3944 of file model.c.

3944 {
3951}

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

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

Referenced by appendGfx_background_texture().

◆ mdl_get_vertex_count()

void mdl_get_vertex_count ( Gfx * gfx,
s32 * numVertices,
Vtx ** baseVtx,
s32 * gfxCount,
Vtx * baseAddr )

Definition at line 3962 of file model.c.

3962 {
3963 s8 stuff[2];
3964
3965 s32 vtxCount;
3966 u32 w0, w1;
3967 u32 cmd;
3969 s32 minVtx;
3970 s32 maxVtx;
3972
3973 minVtx = 0;
3974 maxVtx = 0;
3975
3976 if (gfx == NULL) {
3977 *numVertices = 0;
3978 *baseVtx = NULL;
3979 } else {
3980 Gfx* baseGfx = gfx;
3981
3982 do {
3983 w0 = gfx->words.w0;
3984 w1 = gfx->words.w1;
3985 cmd = _SHIFTR(w0,24,8);
3986
3987 if (cmd == G_VTX) {
3988 vtxStartAddr = w1;
3989 if (baseAddr != NULL) {
3990 vtxStartAddr = (vtxStartAddr & 0xFFFF) + (s32)baseAddr;
3991 }
3992 vtxCount = _SHIFTR(w0,12,8);
3993 if (minVtx == 0) {
3995 maxVtx = vtxStartAddr + (vtxCount * sizeof(Vtx));
3996 }
3997 vtxEndAddr = vtxStartAddr + (vtxCount * sizeof(Vtx));
3998 if (maxVtx < vtxEndAddr) {
4000 }
4001 if (minVtx > vtxEndAddr) {
4003 }
4004 }
4005 gfx++;
4006 } while (cmd != G_ENDDL);
4007
4008 *numVertices = (maxVtx - minVtx) >> 4;
4009 *baseVtx = (Vtx*)minVtx;
4010 *gfxCount = gfx - baseGfx;
4011 w1 = 64; // TODO required to match -- can be any operation that stores w1
4012 }
4013}

Referenced by mdl_make_local_vertex_copy(), and mdl_project_tex_coords().

◆ mdl_local_gfx_update_vtx_pointers()

void mdl_local_gfx_update_vtx_pointers ( Gfx * nodeDlist,
Vtx * baseVtx,
Gfx * arg2,
Vtx * arg3 )

Definition at line 4015 of file model.c.

4015 {
4016 u32 w0;
4017 Vtx* w1;
4018 do {
4019 w0 = (*((unsigned long long*)nodeDlist)) >> 0x20; // TODO required to match
4020 w1 = (Vtx*)nodeDlist->words.w1;
4021 if (w0 >> 0x18 == G_VTX) {
4022 w1 = arg3 + (w1 - baseVtx);
4023 }
4024 arg2->words.w0 = w0;
4025 arg2->words.w1 = (u32)w1;
4026 nodeDlist++;
4027 arg2++;
4028 } while (w0 >> 0x18 != G_ENDDL);
4029}

Referenced by mdl_make_local_vertex_copy().

◆ mdl_local_gfx_copy_vertices()

void mdl_local_gfx_copy_vertices ( Vtx * src,
s32 num,
Vtx * dest )

Definition at line 4031 of file model.c.

4031 {
4032 u32 i;
4033
4034 for (i = 0; i < num * sizeof(*src); i++) {
4035 ((u8*)dest)[i] = ((u8*)src)[i];
4036 }
4037}

Referenced by mdl_make_local_vertex_copy().

◆ mdl_make_local_vertex_copy()

void mdl_make_local_vertex_copy ( s32 copyIndex,
u16 modelID,
s32 isMakingCopy )

Definition at line 4039 of file model.c.

4039 {
4040 s32 numVertices;
4041 Vtx* baseVtx;
4042 s32 gfxCount;
4043 Gfx* nodeDlist;
4044 Model* model;
4046 s32 i;
4047
4049 nodeDlist = model->modelNode->displayData->displayList;
4050 mdl_get_vertex_count(nodeDlist, &numVertices, &baseVtx, &gfxCount, NULL);
4051
4052 copy = (*gCurrentModelLocalVtxBuffers)[copyIndex] = heap_malloc(sizeof(*copy));
4053
4054 if (isMakingCopy) {
4055 for (i = 0; i < ARRAY_COUNT(copy->gfxCopy); i++) {
4056 copy->gfxCopy[i] = heap_malloc(gfxCount * sizeof(*copy->gfxCopy[i]));
4057 copy->vtxCopy[i] = heap_malloc(numVertices * sizeof(*copy->vtxCopy[i]));
4058 mdl_local_gfx_update_vtx_pointers(nodeDlist, baseVtx, copy->gfxCopy[i], copy->vtxCopy[i]);
4059 mdl_local_gfx_copy_vertices(baseVtx, numVertices, copy->vtxCopy[i]);
4060 }
4062 } else {
4063 for (i = 0; i < ARRAY_COUNT(copy->gfxCopy); i++) {
4064 copy->gfxCopy[i] = NULL;
4065 copy->vtxCopy[i] = NULL;
4066 }
4067 model->flags |= MODEL_FLAG_HIDDEN;
4068 }
4069
4070 copy->selector = 0;
4071 copy->numVertices = numVertices;
4072 copy->minVertexAddr = baseVtx;
4073}
void mdl_local_gfx_copy_vertices(Vtx *src, s32 num, Vtx *dest)
Definition model.c:4031
void mdl_get_vertex_count(Gfx *gfx, s32 *numVertices, Vtx **baseVtx, s32 *gfxCount, Vtx *baseAddr)
Definition model.c:3962
void mdl_local_gfx_update_vtx_pointers(Gfx *nodeDlist, Vtx *baseVtx, Gfx *arg2, Vtx *arg3)
Definition model.c:4015

◆ mdl_get_copied_vertices()

void mdl_get_copied_vertices ( s32 copyIndex,
Vtx ** firstVertex,
Vtx ** copiedVertices,
s32 * numCopied )

Definition at line 4075 of file model.c.

4075 {
4076 ModelLocalVertexCopy* mlvc = (*gCurrentModelLocalVtxBuffers)[copyIndex];
4077 s32 selector = mlvc->selector;
4078
4079 *firstVertex = mlvc->minVertexAddr;
4080 *copiedVertices = mlvc->vtxCopy[selector];
4081 *numCopied = mlvc->numVertices;
4082}

Referenced by build_gfx_blue_stars(), build_gfx_green_stars(), build_gfx_pink_stars(), build_gfx_star(), build_gfx_yellow_stars(), unkAngleFunc002(), and unkAngleFunc003().

◆ mdl_get_copied_gfx()

Gfx * mdl_get_copied_gfx ( s32 copyIndex)

Definition at line 4084 of file model.c.

4084 {
4085 ModelLocalVertexCopy* mlvc = (*gCurrentModelLocalVtxBuffers)[copyIndex];
4086 s32 selector = mlvc->selector;
4087 Gfx* gfxCopy = mlvc->gfxCopy[selector];
4088
4089 mlvc->selector++;
4090 if (mlvc->selector > ARRAY_COUNT(mlvc->gfxCopy) - 1) {
4091 mlvc->selector = 0;
4092 }
4093
4094 return gfxCopy;
4095}

Referenced by build_gfx_blue_stars(), build_gfx_green_stars(), build_gfx_pink_stars(), build_gfx_star(), build_gfx_yellow_stars(), unkAngleFunc002(), and unkAngleFunc003().

◆ mdl_project_tex_coords()

void mdl_project_tex_coords ( s32 modelID,
Gfx * outGfx,
Matrix4f arg2,
Vtx * arg3 )

Definition at line 4097 of file model.c.

4097 {
4098 s32 sp18;
4099 Vtx* baseVtx;
4100 s32 sp20;
4101 f32 v1tc1;
4102 f32 v2tc1;
4103 f32 sp2C;
4104 f32 v0tc1;
4105 f32 sp40;
4106 f32 v1tc0;
4107 f32 v1ob2;
4108 f32 ob2;
4109 f32 ob1;
4110 f32 v0ob0;
4111 f32 v0ob2;
4112 f32 v0tc0;
4113 f32 v2ob0;
4114 f32 v2tc0;
4115 f32 v1ob0;
4116 f32 v2ob2;
4117 f32 ob0;
4118 f32 var_f10;
4119 f32 var_f24;
4120 f32 var_f26;
4121 f32 tc1;
4122 f32 var_f30;
4123 f32 tc0;
4124 f32 var_f6_2;
4125 s32 i;
4126 u32 cnB;
4127 u32 cnG;
4128 u32 cnR;
4129 f32 var_f20;
4130
4131 s32 listIndex;
4132 Model* model;
4133 Gfx* dlist;
4134 s32 cmd;
4135 Vtx* tempVert;
4136
4137 s8 zero = 0; // TODO needed to match
4138
4139 listIndex = get_model_list_index_from_tree_index(modelID & 0xFFFF);
4140 model = get_model_from_list_index(listIndex);
4141 dlist = model->modelNode->displayData->displayList;
4142
4143 while (TRUE) {
4144 cmd = dlist->words.w0 >> 0x18;
4145 tempVert = (Vtx*)dlist->words.w1;
4146 if (cmd == G_ENDDL) {
4147 break;
4148 }
4149 if (cmd == G_VTX) {
4150 baseVtx = tempVert;
4151 break;
4152 }
4153 dlist++;
4154 }
4155
4156 v0ob0 = baseVtx[zero].v.ob[0];
4157 v0ob2 = baseVtx[zero].v.ob[2];
4158 v0tc0 = baseVtx[zero].v.tc[0];
4159 v0tc1 = baseVtx[zero].v.tc[1];
4160
4161 v1ob0 = baseVtx[1].v.ob[0];
4162 v1ob2 = baseVtx[1].v.ob[2];
4163 v1tc0 = baseVtx[1].v.tc[0];
4164 v1tc1 = baseVtx[1].v.tc[1];
4165
4166 v2ob0 = baseVtx[2].v.ob[0];
4167 v2ob2 = baseVtx[2].v.ob[2];
4168 v2tc0 = baseVtx[2].v.tc[0];
4169 v2tc1 = baseVtx[2].v.tc[1];
4170
4171 cnR = baseVtx[0].v.cn[0];
4172 cnG = baseVtx[0].v.cn[1];
4173 cnB = baseVtx[0].v.cn[2];
4174
4175 if (v0ob0 != v1ob0) {
4176 f32 f2 = v0ob0 - v2ob0;
4177 f32 f14 = v0ob0 - v1ob0;
4178 f32 f8 = v0tc0 - v1tc0;
4179 f32 f2a = f2 / f14;
4180 f32 f0 = f2a * f8;
4181 f32 f12 = v0ob2 - v1ob2;
4182 f32 f10 = f2a * f12;
4183 f32 f4 = v0tc0 - v2tc0;
4184 f32 f6 = v0ob2 - v2ob2;
4185 f32 f0a = f0 - f4;
4186 f32 f10a = f10 - f6;
4187
4188 f32 f0b, f4a, f2b, f8a, f6a, f0c, f8b, f2c, f12a, f2d, f4b, f0d, f6b, f0e;
4189
4190 sp40 = f0a / f10a; // used later
4191 f0b = f12 * sp40;
4192 f4a = v0tc1 - v1tc1;
4193 f2b = f2a * f4a;
4194 f8a = f8 - f0b;
4195 var_f30 = f8a / f14; // used later
4196 f6a = var_f30 * v0ob0;
4197 f0c = v0tc1 - v2tc1;
4198 f2c = f2b - f0c;
4199 var_f26 = f2c / f10a; // used later
4200 f12a = f12 * var_f26;
4201 var_f24 = (f4a - f12a) / f14; // used later
4202 sp2C = v0tc0 - f6a - sp40 * v0ob2; // used later
4203 var_f20 = v0tc1 - var_f24 * v0ob0 - var_f26 * v0ob2; // used later
4204 } else {
4205 f32 f2 = v0ob2 - v2ob2;
4206 f32 f14 = v0ob2 - v1ob2;
4207 f32 f8 = v0tc0 - v1tc0;
4208 f32 f12 = v0ob0 - v1ob0;
4209 f32 f4 = v0tc0 - v2tc0;
4210 f32 f6 = v0ob0 - v2ob0;
4211 f32 f0 = f2 / f14 * f8;
4212 f32 f10 = f2 / f14 * f12;
4213
4214 f32 f0b, f4a, f2b, f8a, f6a, f0c, f8b, f2c, f12a, f2d, f4b, f0d, f6b, f0e;
4215
4216 var_f30 = (f0 - f4) / (f10 - f6); // used later
4217 f0b = f12 * var_f30;
4218 f6a = var_f30 * v0ob0;
4219 f4a = v0tc1 - v1tc1;
4220 f2b = f2 / f14 * f4a;
4221 f8a = f8 - f0b;
4222 sp40 = f8a / f14; // used later
4223 f8b = sp40 * v0ob2;
4224 f0c = v0tc1 - v2tc1;
4225 var_f24 = (f2b - f0c) / (f10 - f6); // used later
4226 var_f26 = (f4a - f12 * var_f24) / f14; // used later
4227 sp2C = v0tc0 - f6a - f8b; // used later
4228 var_f20 = v0tc1 - var_f24 * v0ob0 - var_f26 * v0ob2; // used later
4229 }
4230
4232
4233 for (i = 0; i < sp18; i++) {
4234 ob0 = baseVtx->v.ob[0];
4235 ob1 = baseVtx->v.ob[1];
4236 ob2 = baseVtx->v.ob[2];
4237 if (arg2 != NULL) {
4238 var_f10 = (arg2[0][0] * ob0) + (arg2[1][0] * ob1) + (arg2[2][0] * ob2) + arg2[3][0];
4239 var_f6_2 = (arg2[0][2] * ob0) + (arg2[1][2] * ob1) + (arg2[2][2] * ob2) + arg2[3][2];
4240 } else {
4241 var_f10 = ob0;
4242 var_f6_2 = ob2;
4243 }
4244 tc0 = (var_f30 * var_f10) + (sp40 * var_f6_2) + sp2C;
4245 tc1 = (var_f24 * var_f10) + (var_f26 * var_f6_2) + var_f20;
4246 if (tc0 < 0.0f) {
4247 tc0 -= 0.5;
4248 } else if (tc0 > 0.0f) {
4249 tc0 += 0.5;
4250 }
4251
4252 if (tc1 < 0.0f) {
4253 tc1 -= 0.5;
4254 } else if (tc1 > 0.0f) {
4255 tc1 += 0.5;
4256 }
4257
4258 baseVtx->v.tc[0] = tc0;
4259 baseVtx->v.tc[1] = tc1;
4260 baseVtx->v.cn[0] = cnR;
4261 baseVtx->v.cn[1] = cnG;
4262 baseVtx->v.cn[2] = cnB;
4263 baseVtx++;
4264 }
4265}

◆ is_model_center_visible()

s32 is_model_center_visible ( u16 modelID,
s32 depthQueryID,
f32 * screenX,
f32 * screenY )

Definition at line 4274 of file model.c.

4274 {
4277 f32 outX;
4278 f32 outY;
4279 f32 outZ;
4280 f32 outW;
4281
4282 s32 depthExponent;
4283 s32 depthMantissa;
4286 s32 scaledDepth;
4287
4288 // If an invalid depth query id was provided, return false.
4289 if (depthQueryID >= ARRAY_COUNT(DepthCopyBuffer)) {
4290 return FALSE;
4291 }
4292 // Transform the model's center into clip space.
4293 transform_point(camera->mtxPerspective, model->center.x, model->center.y, model->center.z, 1.0f, &outX, &outY, &outZ, &outW);
4294 if (outW == 0.0f) {
4295 *screenX = 0.0f;
4296 *screenY = 0.0f;
4297 return TRUE;
4298 }
4299 // Perform the perspective divide (divide xyz by w) to convert to normalized device coords.
4300 // Normalized device coords have a range of (-1, 1) on each axis.
4301 outW = 1.0f / outW;
4302 outX *= outW;
4303 outY *= -outW;
4304 outZ *= outW;
4305 // Perform the viewport transform for x and y (convert normalized device coords to viewport coords).
4306 // Viewport coords have a range of (0, Width) for x and (0, Height) for y.
4307 outX = (outX * camera->viewportW + camera->viewportW) * 0.5;
4308 outX += camera->viewportStartX;
4309 outY = (outY * camera->viewportH + camera->viewportH) * 0.5;
4310 outY += camera->viewportStartY;
4311 // Convert depth from (-1, 1) to (0, 1).
4312 outZ = (outZ + 1.0f) * 0.5;
4313 // Write out the calculated x and y values.
4314 *screenX = (s32)outX;
4315 *screenY = (s32)outY;
4316 // If a depth query wasn't requested, simply check if the point is within the view frustum.
4317 if (depthQueryID < 0) {
4318 if (outZ > 0.0f) {
4319 return FALSE;
4320 } else {
4321 return TRUE;
4322 }
4323 }
4324 if (outX >= 0.0f && outY >= 0.0f && outX < 320.0f && outY < 240.0f) {
4326 // Load a 4x1 pixel tile of the depth buffer
4328 (s32) outX, 0, (s32) outX + 3, 0,
4329 0,
4331 9, G_TX_NOMASK,
4334 // Set the current color image to the buffer where copied depth values are stored.
4337 // Set up 1 cycle mode and all other relevant othermode params.
4338 // One cycle mode must be used here because only one pixel is copied, and copy mode only supports multiples of 4 pixels.
4344 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
4348 // Adjust the scissor to only draw to the specified pixel.
4349 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, depthQueryID, 0, depthQueryID + 1, 1);
4350 // Draw a texrect to copy one pixel of the loaded depth tile to the output buffer.
4351 gSPTextureRectangle(gMainGfxPos++, depthQueryID << 2, 0 << 2, 4 << 2, 1 << 2, G_TX_RENDERTILE, (s32) outX << 5, 0, 1 << 10, 1 << 10);
4352 // Sync and swap the color image back to the current framebuffer.
4356 // Reconfigure the frame's normal scissor.
4357 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, camera->viewportStartX, camera->viewportStartY, camera->viewportStartX + camera->viewportW, camera->viewportStartY + camera->viewportH);
4358
4359 // The following code will use last frame's depth value, since the copy that was just written won't be executed until the current frame is drawn.
4360
4361 // Extract the exponent and mantissa from the depth buffer value.
4364 // Convert the exponent and mantissa into a fixed-point value.
4367 // Remove the 3 fractional bits of precision.
4369 // Convert the calculated screen depth into viewport depth.
4371 if (decodedDepth < scaledDepth) {
4372 return FALSE;
4373 }
4374 }
4375 return outZ > 0.0f;
4376}
u16 * nuGfxCfb_ptr
Definition cam_main.c:13
u16 * nuGfxZBuffer
Definition main.c:46
#define DEPTH_MANTISSA_SHIFT
Definition model.c:610
#define DEPTH_MANTISSA_MASK
Definition model.c:606
DepthFloatFactors DepthFloatLookupTable[]
Definition model.c:619
#define MAX_VIEWPORT_DEPTH
Definition model.c:634
#define DEPTH_EXPONENT_SHIFT
Definition model.c:609
BSS u16 DepthCopyBuffer[16]
Definition model.c:1350
#define DEPTH_DZ_MASK
Definition model.c:607
#define SCREEN_WIDTH
Definition macros.h:109

◆ is_point_visible()

OPTIMIZE_OFAST b32 is_point_visible ( f32 x,
f32 y,
f32 z,
s32 depthQueryID,
f32 * screenX,
f32 * screenY )

Definition at line 4385 of file model.c.

4385 {
4387 f32 outX;
4388 f32 outY;
4389 f32 outZ;
4390 f32 outW;
4391
4392 s32 depthExponent;
4393 s32 depthMantissa;
4396 s32 scaledDepth;
4397
4398 // If an invalid depth query id was provided, return false.
4399 if (depthQueryID >= ARRAY_COUNT(DepthCopyBuffer)) {
4400 return FALSE;
4401 }
4402 // Transform the point into clip space.
4403 transform_point(camera->mtxPerspective, x, y, z, 1.0f, &outX, &outY, &outZ, &outW);
4404 if (outW == 0.0f) {
4405 *screenX = 0.0f;
4406 *screenY = 0.0f;
4407 return TRUE;
4408 }
4409 // Perform the perspective divide (divide xyz by w) to convert to normalized device coords.
4410 // Normalized device coords have a range of (-1, 1) on each axis.
4411 outW = 1.0f / outW;
4412 outX *= outW;
4413 outY *= -outW;
4414 outZ *= outW;
4415 // Perform the viewport transform for x and y (convert normalized device coords to viewport coords).
4416 // Viewport coords have a range of (0, Width) for x and (0, Height) for y.
4417 outX = (outX * camera->viewportW + camera->viewportW) * 0.5;
4418 outX += camera->viewportStartX;
4419 outY = (outY * camera->viewportH + camera->viewportH) * 0.5;
4420 outY += camera->viewportStartY;
4421 // Convert depth from (-1, 1) to (0, 1).
4422 outZ = (outZ + 1.0f) * 0.5;
4423 // Write out the calculated x and y values.
4424 *screenX = outX;
4425 *screenY = outY;
4426 // If a depth query wasn't requested, simply check if the point is within the view frustum.
4427 if (depthQueryID < 0) {
4428 return outZ > 0.0f;
4429 }
4430 if (outX >= 0.0f && outY >= 0.0f && outX < 320.0f && outY < 240.0f) {
4432 // Load a 4x1 pixel tile of the depth buffer
4434 (s32) outX, 0, (s32) outX + 3, 0,
4435 0,
4437 9, G_TX_NOMASK,
4440 // Set the current color image to the buffer where copied depth values are stored.
4443 // Set up 1 cycle mode and all other relevant othermode params.
4444 // One cycle mode must be used here because only one pixel is copied, and copy mode only supports multiples of 4 pixels.
4450 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
4454 // Adjust the scissor to only draw to the specified pixel.
4455 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, depthQueryID, 0, depthQueryID + 1, 1);
4456 // Draw a texrect to copy one pixel of the loaded depth tile to the output buffer.
4457 gSPTextureRectangle(gMainGfxPos++, depthQueryID << 2, 0 << 2, (depthQueryID + 1) << 2, 1 << 2, G_TX_RENDERTILE, (s32) outX << 5, 0, 1 << 10, 1 << 10);
4458 // Sync and swap the color image back to the current framebuffer.
4462 // Reconfigure the frame's normal scissor.
4463 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, camera->viewportStartX, camera->viewportStartY, camera->viewportStartX + camera->viewportW, camera->viewportStartY + camera->viewportH);
4464
4465 // The following code will use last frame's depth value, since the copy that was just written won't be executed until the current frame is drawn.
4466
4467 // Extract the exponent and mantissa from the depth buffer value.
4470 // Convert the exponent and mantissa into a fixed-point value.
4473 // Remove the 3 fractional bits of precision.
4475 // Convert the calculated screen depth into viewport depth.
4477 if (decodedDepth < scaledDepth) {
4478 return FALSE;
4479 }
4480 }
4481 return outZ > 0.0f;
4482}

◆ mdl_draw_hidden_panel_surface()

void mdl_draw_hidden_panel_surface ( Gfx ** arg0,
u16 treeIndex )

Definition at line 4484 of file model.c.

4484 {
4486 Model copied = *model;
4487 Gfx* oldGfxPos;
4488 s32 flag;
4489
4490 if (*arg0 == gMainGfxPos) {
4491 flag = 1;
4492 }
4493
4495 gMainGfxPos = *arg0;
4496
4499
4500 *arg0 = gMainGfxPos;
4501
4502 if (flag == 0) {
4504 }
4505}

◆ mdl_get_next_texture_address()

void * mdl_get_next_texture_address ( s32 size)

Definition at line 4507 of file model.c.

4507 {
4508 u32 offset = TextureHeapPos - TextureHeapBase + 0x3F;
4509
4510 offset = (offset >> 6) << 6;
4511
4513 return NULL;
4514 } else {
4515 return TextureHeapBase + offset;
4516 }
4517}
#define BATTLE_TEXTURE_MEMORY_SIZE
Definition model.c:103

Referenced by draw_box().

◆ mdl_set_all_tint_type()

void mdl_set_all_tint_type ( s32 tintType)

Definition at line 4519 of file model.c.

4519 {
4521 Model* model;
4522 s32 type = tintType; // weirdness here and the next line needed to match
4523 s32 i = tintType;
4524
4525 for (i = 0; i < ARRAY_COUNT(*modelList); i++) {
4526 model = (*modelList)[i];
4527
4528 if (model != NULL) {
4530 }
4531 }
4532}
@ CUSTOM_GFX_NONE
Definition enums.h:4419
void set_mdl_custom_gfx_set(Model *model, s32 customGfxIndex, u32 tintType)
Definition model.c:3831
Model * ModelList[256]
Definition model.h:94

Referenced by btl_state_update_celebration().

◆ clear_render_tasks()

void clear_render_tasks ( void )

Definition at line 4534 of file model.c.

4534 {
4535 s32 i;
4536
4537 for (i = 0; i < ARRAY_COUNT(ClearRenderTaskLists); i++) {
4539 }
4540
4541 for (i = 0; i < ARRAY_COUNT(RenderTaskCount); i++) {
4542 RenderTaskCount[i] = 0;
4543 }
4544}
BSS s32 RenderTaskCount[3]
Definition model.c:1353
BSS RenderTask * RenderTaskLists[3]
Definition model.c:1351
BSS RenderTask ClearRenderTaskLists[3][0x100]

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

◆ queue_render_task()

RenderTask * queue_render_task ( RenderTask * task)

Definition at line 4546 of file model.c.

4546 {
4547 s32 dist = RenderTaskBasePriorities[task->renderMode] - task->dist;
4549 if (dist >= 3000000) listIdx = RENDER_TASK_LIST_FAR;
4550 else if (dist < 800000) listIdx = RENDER_TASK_LIST_NEAR;
4551
4553
4555
4557
4558 ret->renderMode = RENDER_TASK_FLAG_ENABLED;
4559 if (task->renderMode == RENDER_MODE_CLOUD_NO_ZCMP) {
4560 ret->renderMode |= RENDER_TASK_FLAG_20;
4561 }
4562
4563 ret->appendGfxArg = task->appendGfxArg;
4564 ret->appendGfx = task->appendGfx;
4565 ret->dist = dist;
4566
4567 return ret;
4568}
#define ASSERT(condition)
@ RENDER_TASK_FLAG_20
Definition enums.h:3319
@ RENDER_TASK_FLAG_ENABLED
Definition enums.h:3317
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
s32 RenderTaskBasePriorities[]
Definition model.c:1256

◆ execute_render_tasks()

OPTIMIZE_OFAST void execute_render_tasks ( void )

Definition at line 4570 of file model.c.

4570 {
4571 s32 i, j;
4573 s32* sorted;
4577 void (*appendGfx)(void*);
4578 s32 tmp;
4579
4580 for (s32 j = 0; j < ARRAY_COUNT(RenderTaskCount); j++) {
4581 for (i = 0; i < RenderTaskCount[j]; i++) {
4582 sorteds[j][i] = i;
4583 }
4584 }
4585
4586 // sort in ascending order of dist
4589#define LESS(i, j) taskList[sorted[i]].dist < taskList[sorted[j]].dist
4590#define SWAP(i, j) tmp = sorted[i], sorted[i] = sorted[j], sorted[j] = tmp
4592
4593 // tasks with dist >= 3M sort in descending order
4596#define LESS(i, j) taskList[sorted[i]].dist > taskList[sorted[j]].dist
4598
4599 // tasks with dist <= 800k sort in descending order
4603
4606 Mtx* dispMtx;
4607 Gfx* savedGfxPos = NULL;
4608
4609 guScaleF(mtxFlipY, 1.0f, -1.0f, 1.0f);
4612 for (j = 0; j < NUM_RENDER_TASK_LISTS; j++) {
4613 for (i = 0; i < RenderTaskCount[j]; i++) {
4614 task = &RenderTaskLists[j][sorteds[j][i]];
4615 appendGfx = task->appendGfx;
4616
4617 if (task->renderMode & RENDER_TASK_FLAG_REFLECT_FLOOR) {
4619 }
4620
4621 appendGfx(task->appendGfxArg);
4622
4623 if (task->renderMode & RENDER_TASK_FLAG_REFLECT_FLOOR) {
4630 }
4631 }
4632 }
4633 } else {
4634 for (j = 0; j < NUM_RENDER_TASK_LISTS; j++) {
4635 for (i = 0; i < RenderTaskCount[j]; i++) {
4636 task = &RenderTaskLists[j][sorteds[j][i]];
4637 appendGfx = task->appendGfx;
4638 appendGfx(task->appendGfxArg);
4639 }
4640 }
4641 }
4642
4646}
#define guScaleF
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ GLOBAL_OVERRIDES_ENABLE_FLOOR_REFLECTION
Definition enums.h:4325
#define SWAP(i, j)
s32 gLastRenderTaskCount
Definition model.c:636
#define LESS(i, j)
#define NUM_RENDER_TASK_LISTS
#define QSORT(Q_N, Q_LESS, Q_SWAP)
Definition qsort.h:161
void(* appendGfx)(void *)
s32 gOverrideFlags
Definition main_loop.c:10

Referenced by render_frame().

Variable Documentation

◆ gBackgroundTintModePtr

◆ gCurrentModels

◆ gCurrentModelTreeNodeInfo

◆ TextureHeap

Addr TextureHeap
extern

Definition at line 6 of file texture_memory.c.

◆ 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_SURFACE_OPA_NO_AA

◆ Gfx_RM1_DECAL_OPA_NO_AA

◆ Gfx_RM1_INTERSECTING_OPA_NO_AA

◆ Gfx_RM1_ALPHATEST_ONESIDED

◆ Gfx_RM1_SURFACE_XLU_NO_AA

◆ Gfx_RM1_DECAL_XLU_NO_AA

◆ Gfx_RM1_PASS_THROUGH

◆ Gfx_RM1_SURFACE_XLU_AA_ZB_ZUPD

◆ Gfx_RM1_SURFACE_OPA_NO_ZB

◆ Gfx_RM1_ALPHATEST_NO_ZB

◆ Gfx_RM1_SURFACE_XLU_NO_ZB

◆ Gfx_RM1_SURFACE_XLU_ZB_ZUPD

◆ Gfx_RM1_CLOUD_NO_ZCMP

◆ Gfx_RM1_CLOUD

◆ Gfx_RM1_CLOUD_NO_ZB

◆ Gfx_RM2_SURFACE_OPA

◆ Gfx_RM2_DECAL_OPA

◆ Gfx_RM2_INTERSECTING_OPA

◆ Gfx_RM2_ALPHATEST

◆ Gfx_RM2_SURFACE_XLU

◆ Gfx_RM2_DECAL_XLU

◆ Gfx_RM2_INTERSECTING_XLU

◆ Gfx_RM2_SURFACE_OPA_NO_AA

◆ Gfx_RM2_DECAL_OPA_NO_AA

◆ Gfx_RM2_INTERSECTING_OPA_NO_AA

◆ Gfx_RM2_ALPHATEST_ONESIDED

◆ Gfx_RM2_SURFACE_XLU_NO_AA

◆ Gfx_RM2_DECAL_XLU_NO_AA

◆ Gfx_RM2_PASS_THROUGH

◆ Gfx_RM2_SURFACE_XLU_AA_ZB_ZUPD

◆ Gfx_RM2_SURFACE_OPA_NO_ZB

◆ Gfx_RM2_ALPHATEST_NO_ZB

◆ Gfx_RM2_SURFACE_XLU_NO_ZB

◆ Gfx_RM2_CLOUD

◆ Gfx_RM2_CLOUD_NO_ZB

◆ 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

◆ Gfx_RM3_SURFACE_OPA_NO_AA

◆ Gfx_RM3_DECAL_OPA_NO_AA

◆ Gfx_RM3_INTERSECTING_OPA_NO_AA

◆ Gfx_RM3_ALPHATEST_ONESIDED

◆ Gfx_RM3_SURFACE_XLU_NO_AA

◆ Gfx_RM3_DECAL_XLU_NO_AA

◆ Gfx_RM3_PASS_THROUGH

◆ Gfx_RM3_SURFACE_XLU_AA_ZB_ZUPD

◆ Gfx_RM3_SURFACE_OPA_NO_ZB

◆ Gfx_RM3_ALPHATEST_NO_ZB

◆ Gfx_RM3_SURFACE_XLU_NO_ZB

◆ Gfx_RM3_CLOUD

◆ Gfx_RM3_CLOUD_NO_ZB

◆ ModelRenderModes

Gfx* ModelRenderModes[]

Definition at line 181 of file model.c.

181 {
243};
@ RENDER_MODE_IDX_15
Definition enums.h:3215
@ RENDER_MODE_IDX_2D
Definition enums.h:3240
@ RENDER_MODE_IDX_1E
Definition enums.h:3224
@ RENDER_MODE_IDX_0F
Definition enums.h:3208
@ RENDER_MODE_IDX_05
Definition enums.h:3198
@ RENDER_MODE_IDX_24
Definition enums.h:3231
Gfx Gfx_RM3_SURFACE_OPA[]
Definition model.c:1067
Gfx Gfx_RM2_DECAL_OPA[]
Definition model.c:886
Gfx Gfx_RM3_DECAL_XLU[]
Definition model.c:1117
Gfx Gfx_RM3_DECAL_OPA[]
Definition model.c:1077
Gfx Gfx_RM2_INTERSECTING_OPA_NO_AA[]
Definition model.c:962
Gfx Gfx_RM2_DECAL_XLU_NO_AA[]
Definition model.c:989
Gfx Gfx_RM3_SURFACE_XLU_NO_ZB[]
Definition model.c:1230
Gfx Gfx_RM2_SURFACE_XLU_NO_ZB[]
Definition model.c:1036
Gfx Gfx_RM2_INTERSECTING_XLU[]
Definition model.c:932
Gfx Gfx_RM2_INTERSECTING_OPA[]
Definition model.c:895
Gfx Gfx_RM1_CLOUD_NO_ZB[]
Definition model.c:865
Gfx Gfx_RM3_INTERSECTING_OPA_NO_AA[]
Definition model.c:1157
Gfx Gfx_RM1_PASS_THROUGH[]
Definition model.c:779
Gfx Gfx_RM1_INTERSECTING_OPA_NO_AA[]
Definition model.c:736
Gfx Gfx_RM1_SURFACE_XLU[]
Definition model.c:686
Gfx Gfx_RM1_DECAL_XLU[]
Definition model.c:696
Gfx Gfx_RM2_SURFACE_OPA_NO_ZB[]
Definition model.c:1018
Gfx Gfx_RM2_DECAL_OPA_NO_AA[]
Definition model.c:953
Gfx Gfx_RM1_SURFACE_XLU_AA_ZB_ZUPD[]
Definition model.c:787
Gfx Gfx_RM3_PASS_THROUGH[]
Definition model.c:1195
Gfx Gfx_RM2_SURFACE_XLU[]
Definition model.c:914
Gfx Gfx_RM3_SURFACE_OPA_NO_ZB[]
Definition model.c:1212
Gfx Gfx_RM2_SURFACE_XLU_NO_AA[]
Definition model.c:980
Gfx Gfx_RM3_DECAL_OPA_NO_AA[]
Definition model.c:1148
Gfx Gfx_RM2_ALPHATEST_NO_ZB[]
Definition model.c:1027
Gfx Gfx_RM2_SURFACE_OPA[]
Definition model.c:877
Gfx Gfx_RM2_ALPHATEST[]
Definition model.c:905
Gfx Gfx_RM3_CLOUD[]
Definition model.c:1239
Gfx Gfx_RM2_CLOUD[]
Definition model.c:1045
Gfx Gfx_RM3_ALPHATEST_ONESIDED[]
Definition model.c:1166
Gfx Gfx_RM2_PASS_THROUGH[]
Definition model.c:1001
Gfx Gfx_RM1_SURFACE_OPA_NO_ZB[]
Definition model.c:800
Gfx Gfx_RM1_DECAL_OPA[]
Definition model.c:654
Gfx Gfx_RM2_SURFACE_OPA_NO_AA[]
Definition model.c:944
Gfx Gfx_RM3_SURFACE_OPA_NO_AA[]
Definition model.c:1139
Gfx Gfx_RM2_SURFACE_XLU_AA_ZB_ZUPD[]
Definition model.c:1009
Gfx Gfx_RM3_SURFACE_XLU_NO_AA[]
Definition model.c:1174
Gfx Gfx_RM1_ALPHATEST[]
Definition model.c:676
Gfx Gfx_RM1_INTERSECTING_XLU[]
Definition model.c:706
Gfx Gfx_RM2_CLOUD_NO_ZB[]
Definition model.c:1054
Gfx Gfx_RM1_SURFACE_OPA[]
Definition model.c:643
Gfx Gfx_RM3_DECAL_XLU_NO_AA[]
Definition model.c:1183
Gfx Gfx_RM3_INTERSECTING_XLU[]
Definition model.c:1127
Gfx Gfx_RM1_CLOUD[]
Definition model.c:856
Gfx Gfx_RM3_INTERSECTING_OPA[]
Definition model.c:1087
Gfx Gfx_RM1_SURFACE_XLU_ZB_ZUPD[]
Definition model.c:830
Gfx Gfx_RM1_DECAL_OPA_NO_AA[]
Definition model.c:727
Gfx Gfx_RM2_ALPHATEST_ONESIDED[]
Definition model.c:972
Gfx Gfx_RM1_ALPHATEST_ONESIDED[]
Definition model.c:746
Gfx Gfx_RM1_SURFACE_XLU_NO_ZB[]
Definition model.c:820
Gfx Gfx_RM3_SURFACE_XLU_AA_ZB_ZUPD[]
Definition model.c:1203
Gfx Gfx_RM1_ALPHATEST_NO_ZB[]
Definition model.c:810
Gfx Gfx_RM3_ALPHATEST[]
Definition model.c:1097
Gfx Gfx_RM1_SURFACE_XLU_NO_AA[]
Definition model.c:756
Gfx Gfx_RM2_DECAL_XLU[]
Definition model.c:923
Gfx Gfx_RM1_DECAL_XLU_NO_AA[]
Definition model.c:766
Gfx Gfx_RM3_ALPHATEST_NO_ZB[]
Definition model.c:1221
Gfx Gfx_RM1_INTERSECTING_OPA[]
Definition model.c:665
Gfx Gfx_RM3_SURFACE_XLU[]
Definition model.c:1107
Gfx Gfx_RM1_SURFACE_OPA_NO_AA[]
Definition model.c:718
Gfx Gfx_RM3_CLOUD_NO_ZB[]
Definition model.c:1248

Referenced by appendGfx_model().

◆ SolidCombineModes

Gfx SolidCombineModes[][5]

Definition at line 245 of file model.c.

245 {
252 },
253
260 },
267 },
274 },
275
276 // blend LODs in first cycle, tint in second cycle
277 // all three sub-types are identical
284 },
291 },
298 },
299
300 // blend main/aux textures in first cycle, tint in second cycle
301 // all three sub-types are identical
308 },
315 },
322 },
323
324 // blend main/aux textures in first cycle, tint in second cycle
325 // all three sub-types are identical
332 },
339 },
346 },
347
348 // shaded color multiplied main/aux textures for alpha
349 [TEX_COMBINE_3] {
355 },
356 // lerp between main/aux textures with shade alpha
357 [TEX_COMBINE_4] {
363 },
364 [TEX_COMBINE_5] {
370 },
371 [TEX_COMBINE_6] {
377 },
378 [TEX_COMBINE_7] {
384 },
385 [TEX_COMBINE_8] {
391 },
392 [TEX_COMBINE_9] {
398 },
399 [TEX_COMBINE_A] {
405 },
406};
#define PM_CC_TEX_COMBINE_3C
Definition macros.h:374
#define PM_CC_TEX_COMBINE_3B
Definition macros.h:373
#define PM_CC_ALT_INTERFERENCE
Definition macros.h:380
#define PM_CC_TINT_REMAP_SHADE_ALPHA
Definition macros.h:363
#define PM_CC_20
Definition macros.h:336
#define PM_CC1_24
Definition macros.h:369
#define PM_CC1_29
Definition macros.h:376
#define PM_CC_TEX_COMBINE_3A
Definition macros.h:372
#define PM_CC_NOISE
Definition macros.h:314
#define PM_CC_22
Definition macros.h:367
#define PM_CC2_29
Definition macros.h:377
#define PM_CC2_MULTIPLY_SHADE
Definition macros.h:312
#define PM_CC_TINT_REMAP_NO_SHADE
Definition macros.h:355
#define PM_CC_TINT_DEPTH_NO_SHADE
Definition macros.h:330
#define PM_CC_23
Definition macros.h:368
#define PM_CC_TINT_DEPTH_MIPMAPS
Definition macros.h:340
#define PM_CC2_24
Definition macros.h:370
#define PM_CC_TINT_REMAP_NOTEX
Definition macros.h:347
#define PM_CC_1A
Definition macros.h:316
#define PM_CC_TINT_DEPTH_NOTEX
Definition macros.h:322

Referenced by appendGfx_model(), and make_texture_gfx().

◆ AlphaTestCombineModes

Gfx AlphaTestCombineModes[][5]

Definition at line 408 of file model.c.

408 {
415 },
416
423 },
430 },
437 },
438
439 // blend LODs in first cycle, tint in second cycle
446 },
453 },
460 },
461
462 // blend main/aux textures in first cycle, tint in second cycle
469 },
476 },
483 },
484
485 // blend main/aux textures in first cycle, tint in second cycle
492 },
499 },
506 },
507
508 [TEX_COMBINE_3] {
514 },
515 [TEX_COMBINE_4] {
521 },
522 [TEX_COMBINE_5] {
528 },
529 [TEX_COMBINE_6] {
535 },
536 [TEX_COMBINE_7] {
542 },
543 [TEX_COMBINE_8] {
549 },
550 [TEX_COMBINE_9] {
556 },
557 [TEX_COMBINE_A] {
563 },
564};

Referenced by appendGfx_model().

◆ TextureHeapBase

void* TextureHeapBase = (void*) &TextureHeap

Definition at line 566 of file model.c.

Referenced by mdl_get_next_texture_address(), and mdl_load_all_textures().

◆ ShroudTintAmt

u8 ShroudTintAmt = 0

◆ ShroudTintR

u8 ShroudTintR = 0

◆ ShroudTintG

u8 ShroudTintG = 0

◆ ShroudTintB

u8 ShroudTintB = 0

◆ DepthTintBaseR

u8 DepthTintBaseR = 0

Definition at line 573 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintBaseG

u8 DepthTintBaseG = 0

Definition at line 574 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintBaseB

u8 DepthTintBaseB = 0

Definition at line 575 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintBaseA

u8 DepthTintBaseA = 0

Definition at line 576 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintColR

u8 DepthTintColR = 0

Definition at line 577 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintColG

u8 DepthTintColG = 0

Definition at line 578 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintColB

u8 DepthTintColB = 0

Definition at line 579 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintColA

u8 DepthTintColA = 0

Definition at line 580 of file model.c.

◆ DepthTintStart

s32 DepthTintStart = 950

Definition at line 581 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ DepthTintEnd

s32 DepthTintEnd = 1000

Definition at line 582 of file model.c.

Referenced by appendGfx_model(), mdl_get_depth_tint_params(), and mdl_set_depth_tint_params().

◆ RemapTintMaxR

u8 RemapTintMaxR = 255

Definition at line 584 of file model.c.

Referenced by appendGfx_model(), mdl_get_remap_tint_params(), and mdl_set_remap_tint_params().

◆ RemapTintMaxG

u8 RemapTintMaxG = 255

Definition at line 585 of file model.c.

Referenced by appendGfx_model(), mdl_get_remap_tint_params(), and mdl_set_remap_tint_params().

◆ RemapTintMaxB

u8 RemapTintMaxB = 255

Definition at line 586 of file model.c.

Referenced by appendGfx_model(), mdl_get_remap_tint_params(), and mdl_set_remap_tint_params().

◆ RemapTintMinR

u8 RemapTintMinR = 0

Definition at line 587 of file model.c.

Referenced by appendGfx_model(), mdl_get_remap_tint_params(), and mdl_set_remap_tint_params().

◆ RemapTintMinG

u8 RemapTintMinG = 0

Definition at line 588 of file model.c.

Referenced by appendGfx_model(), mdl_get_remap_tint_params(), and mdl_set_remap_tint_params().

◆ RemapTintMinB

u8 RemapTintMinB = 0

Definition at line 589 of file model.c.

Referenced by appendGfx_model(), mdl_get_remap_tint_params(), and mdl_set_remap_tint_params().

◆ ReferenceIdentityMtx

Mtx ReferenceIdentityMtx
Initial value:
1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000
)
#define RDP_MATRIX( Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz, Aw, Bw, Cw, Dw)
Definition macros.h:237

Definition at line 591 of file model.c.

Referenced by is_identity_fixed_mtx().

◆ DepthFloatLookupTable

DepthFloatFactors DepthFloatLookupTable[]
Initial value:
= {
{ 6, 0x00000 },
{ 5, 0x20000 },
{ 4, 0x30000 },
{ 3, 0x38000 },
{ 2, 0x3C000 },
{ 1, 0x3E000 },
{ 0, 0x3F000 },
{ 0, 0x3F800 },
{ 0, 0x00000 },
}

Definition at line 619 of file model.c.

619 {
620 { 6, 0x00000 },
621 { 5, 0x20000 },
622 { 4, 0x30000 },
623 { 3, 0x38000 },
624 { 2, 0x3C000 },
625 { 1, 0x3E000 },
626 { 0, 0x3F000 },
627 { 0, 0x3F800 },
628 { 0, 0x00000 },
629};

Referenced by is_model_center_visible(), and is_point_visible().

◆ gLastRenderTaskCount

s32 gLastRenderTaskCount = 0

Definition at line 636 of file model.c.

Referenced by execute_render_tasks(), and spawn_drops().

◆ RenderTaskBasePriorities

s32 RenderTaskBasePriorities[]

Definition at line 1256 of file model.c.

1256 {
1258 [RENDER_MODE_SURFACE_OPA] = 1000000,
1259 [RENDER_MODE_02_UNUSED] = 1000000,
1262 [RENDER_MODE_DECAL_OPA] = 1000000,
1263 [RENDER_MODE_06_UNUSED] = 1000000,
1264 [RENDER_MODE_DECAL_OPA_NO_AA] = 1000000,
1266 [RENDER_MODE_INTERSECTING_OPA] = 1000000,
1267 [RENDER_MODE_0A_UNUSED] = 1000000,
1268 [RENDER_MODE_0B_UNUSED] = 1000000,
1270 [RENDER_MODE_ALPHATEST] = 1000000,
1271 [RENDER_MODE_0E_UNUSED] = 1000000,
1275 [RENDER_MODE_12_UNUSED] = 8000000,
1280 [RENDER_MODE_17_UNUSED] = 7500000,
1281 [RENDER_MODE_18_UNUSED] = 7500000,
1283 [RENDER_MODE_DECAL_XLU] = 7000000,
1284 [RENDER_MODE_1B_UNUSED] = 7000000,
1285 [RENDER_MODE_DECAL_XLU_NO_AA] = 7000000,
1286 [RENDER_MODE_1D_UNUSED] = 7000000,
1287 [RENDER_MODE_DECAL_XLU_AHEAD] = 6500000,
1288 [RENDER_MODE_1F_UNUSED] = 6500000,
1289 [RENDER_MODE_SHADOW] = 6500000,
1292 [RENDER_MODE_23_UNUSED] = 6000000,
1293 [RENDER_MODE_24_UNUSED] = 6000000,
1295 [RENDER_MODE_INTERSECTING_XLU] = 5500000,
1296 [RENDER_MODE_27_UNUSED] = 5500000,
1297 [RENDER_MODE_PASS_THROUGH] = 5500000,
1302 [RENDER_MODE_CLOUD_NO_ZCMP] = 4500000,
1303 [RENDER_MODE_CLOUD] = 8000000,
1304 [RENDER_MODE_CLOUD_NO_ZB] = 700000,
1305};
@ RENDER_MODE_24_UNUSED
Definition enums.h:3301
@ RENDER_MODE_1D_UNUSED
Definition enums.h:3294
@ RENDER_MODE_1F_UNUSED
Definition enums.h:3296
@ RENDER_MODE_0E_UNUSED
Definition enums.h:3277
@ RENDER_MODE_21_UNUSED
Definition enums.h:3298
@ RENDER_MODE_SURF_SOLID_AA_ZB_LAYER0
Definition enums.h:3263
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
@ RENDER_MODE_SHADOW
Definition enums.h:3297
@ RENDER_MODE_02_UNUSED
Definition enums.h:3265
@ RENDER_MODE_1B_UNUSED
Definition enums.h:3292
@ RENDER_MODE_0A_UNUSED
Definition enums.h:3273
@ RENDER_MODE_SURFACE_XLU_NO_ZB_BEHIND
Definition enums.h:3310
@ RENDER_MODE_SURFACE_OPA_NO_ZB_BEHIND
Definition enums.h:3308
@ RENDER_MODE_25_UNUSED
Definition enums.h:3302
@ RENDER_MODE_23_UNUSED
Definition enums.h:3300
@ RENDER_MODE_DECAL_XLU_AHEAD
Definition enums.h:3295
@ RENDER_MODE_18_UNUSED
Definition enums.h:3289
@ RENDER_MODE_0B_UNUSED
Definition enums.h:3274
@ RENDER_MODE_ALPHATEST_NO_ZB_BEHIND
Definition enums.h:3309
@ RENDER_MODE_12_UNUSED
Definition enums.h:3283
@ RENDER_MODE_08_UNUSED
Definition enums.h:3271
@ RENDER_MODE_06_UNUSED
Definition enums.h:3269
@ RENDER_MODE_19_UNUSED
Definition enums.h:3290
@ RENDER_MODE_0C_UNUSED
Definition enums.h:3275
@ RENDER_MODE_27_UNUSED
Definition enums.h:3304
@ RENDER_MODE_17_UNUSED
Definition enums.h:3288

Referenced by queue_render_task().

◆ gCurrentCustomModelGfxBuildersPtr

ModelCustomGfxBuilderList* gCurrentCustomModelGfxBuildersPtr

Definition at line 1307 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ gCurrentModelTreeRoot

ModelNode** gCurrentModelTreeRoot

◆ gCurrentTransformGroups

◆ gCurrentCustomModelGfxPtr

ModelCustomGfxList* gCurrentCustomModelGfxPtr

Definition at line 1310 of file model.c.

Referenced by appendGfx_model(), build_custom_gfx(), clear_model_data(), and init_model_data().

◆ wModelList

BSS ModelList wModelList

Definition at line 1314 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bModelList

BSS ModelList bModelList

Definition at line 1315 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ wTransformGroups

BSS ModelTransformGroupList wTransformGroups

Definition at line 1317 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bTransformGroups

BSS ModelTransformGroupList bTransformGroups

Definition at line 1318 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ wCustomModelGfx

BSS ModelCustomGfxList wCustomModelGfx

Definition at line 1320 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bCustomModelGfx

BSS ModelCustomGfxList bCustomModelGfx

Definition at line 1321 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ wCustomModelGfxBuilders

BSS ModelCustomGfxBuilderList wCustomModelGfxBuilders

Definition at line 1323 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bCustomModelGfxBuilders

BSS ModelCustomGfxBuilderList bCustomModelGfxBuilders

Definition at line 1324 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ wModelLocalVtxBuffers

BSS ModelLocalVertexCopyList wModelLocalVtxBuffers

Definition at line 1325 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bModelLocalVtxBuffers

BSS ModelLocalVertexCopyList bModelLocalVtxBuffers

Definition at line 1326 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ gCurrentModelLocalVtxBuffers

BSS ModelLocalVertexCopyList* gCurrentModelLocalVtxBuffers

Definition at line 1327 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ wModelTreeRoot

BSS ModelNode* wModelTreeRoot

Definition at line 1329 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bModelTreeRoot

BSS ModelNode* bModelTreeRoot

Definition at line 1330 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ wModelTreeNodeInfo

BSS ModelTreeInfoList wModelTreeNodeInfo

Definition at line 1331 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bModelTreeNodeInfo

BSS ModelTreeInfoList bModelTreeNodeInfo

Definition at line 1332 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ wBackgroundTintMode

BSS s8 wBackgroundTintMode

Definition at line 1334 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bBackgroundTintMode

BSS s8 bBackgroundTintMode

Definition at line 1335 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ TreeIterPos

◆ wFogSettings

BSS FogSettings wFogSettings

Definition at line 1337 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ bFogSettings

BSS FogSettings bFogSettings

Definition at line 1338 of file model.c.

Referenced by clear_model_data(), and init_model_data().

◆ gFogSettings

◆ texPannerMainU

BSS s32 texPannerMainU[MAX_TEX_PANNERS]

Definition at line 1340 of file model.c.

Referenced by appendGfx_model(), clear_model_data(), and set_main_pan_u().

◆ texPannerMainV

BSS s32 texPannerMainV[MAX_TEX_PANNERS]

Definition at line 1341 of file model.c.

Referenced by appendGfx_model(), clear_model_data(), and set_main_pan_v().

◆ texPannerAuxU

BSS s32 texPannerAuxU[MAX_TEX_PANNERS]

Definition at line 1342 of file model.c.

Referenced by appendGfx_model(), clear_model_data(), and set_aux_pan_u().

◆ texPannerAuxV

BSS s32 texPannerAuxV[MAX_TEX_PANNERS]

Definition at line 1343 of file model.c.

Referenced by appendGfx_model(), clear_model_data(), and set_aux_pan_v().

◆ TextureHeapPos

BSS void* TextureHeapPos

◆ mtg_IterIdx

BSS u16 mtg_IterIdx

Definition at line 1345 of file model.c.

Referenced by render_transform_group(), and render_transform_group_node().

◆ mtg_SearchModelID

BSS u16 mtg_SearchModelID

Definition at line 1346 of file model.c.

Referenced by func_8011B1D8(), and mdl_make_transform_group().

◆ mtg_FoundModelNode

BSS ModelNode* mtg_FoundModelNode

Definition at line 1347 of file model.c.

Referenced by func_8011B1D8(), and mdl_make_transform_group().

◆ mtg_MinChild

BSS u16 mtg_MinChild

Definition at line 1348 of file model.c.

Referenced by func_8011B1D8(), and mdl_make_transform_group().

◆ mtg_MaxChild

BSS u16 mtg_MaxChild

Definition at line 1349 of file model.c.

Referenced by func_8011B1D8(), and mdl_make_transform_group().

◆ DepthCopyBuffer

BSS u16 DepthCopyBuffer[16]

Definition at line 1350 of file model.c.

Referenced by is_model_center_visible(), and is_point_visible().

◆ RenderTaskLists

BSS RenderTask* RenderTaskLists[3]

Definition at line 1351 of file model.c.

Referenced by clear_render_tasks(), execute_render_tasks(), and queue_render_task().

◆ RenderTaskListIdx

BSS s32 RenderTaskListIdx

Definition at line 1352 of file model.c.

◆ RenderTaskCount

BSS s32 RenderTaskCount[3]

Definition at line 1353 of file model.c.

Referenced by clear_render_tasks(), execute_render_tasks(), and queue_render_task().

◆ TextureHandles

TextureHandle TextureHandles[128]

◆ BattleEntityHeapBottom

Addr BattleEntityHeapBottom
extern