Mario Kart 64
Loading...
Searching...
No Matches
render.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <main.h>
3#include <macros.h>
4
11void render_actor_item_box(Camera* camera, struct ItemBox* item_box) {
12 UNUSED s32 pad[2];
13 Vec3f someVec1;
14 Vec3f someVec2;
15 Vec3s someRot;
16 f32 thing;
17 UNUSED s32 pad2;
18 Mat4 someMatrix1;
19 Mat4 someMatrix2;
20 UNUSED s32 pad3[4];
21 f32 temp_f0;
22 f32 temp_f0_2;
23 f32 temp_f0_3;
24 f32 temp_f12;
25 f32 temp_f2;
26 f32 temp_f2_2;
27 f32 someMultiplier;
28
29 temp_f0 = distance_if_visible(camera->pos, item_box->pos, camera->rot[1], 0.0f, gCameraZoom[camera - camera1],
30 4000000.0f);
31 if (!(temp_f0 < 0.0f) && !(600000.0f < temp_f0)) {
32 if ((item_box->state == 2) && (temp_f0 < 100000.0f)) {
33 someRot[0] = 0;
34 someRot[1] = item_box->rot[1];
35 someRot[2] = 0;
36 someVec2[0] = item_box->pos[0];
37 someVec2[1] = item_box->resetDistance + 2.0f;
38 someVec2[2] = item_box->pos[2];
39 mtxf_rotate_zxy_translate(someMatrix1, someVec2, someRot);
40
41 if (!render_set_position(someMatrix1, 0)) {
42 return;
43 }
44
45 gSPDisplayList(gDisplayListHead++, D_0D002EE8);
46 someRot[1] = item_box->rot[1] * 2;
47 someVec2[1] = item_box->pos[1];
48 mtxf_rotate_zxy_translate(someMatrix1, someVec2, someRot);
49
50 if (!render_set_position(someMatrix1, 0)) {
51 return;
52 }
53
55 }
56 if (item_box->state == 5) {
57 mtxf_rotate_zxy_translate(someMatrix1, item_box->pos, item_box->rot);
58
59 if (!render_set_position(someMatrix1, 0)) {
60 return;
61 }
62
64 }
65 if (item_box->state != 3) {
66 mtxf_rotate_zxy_translate(someMatrix1, item_box->pos, item_box->rot);
67
68 if (!render_set_position(someMatrix1, 0)) {
69 return;
70 }
71
72 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
74 // unclear why it is 14.95 degrees instead of 15. Perhaps just a typo when entering the value as a s16.
75 if ((item_box->rot[1] < DEGREES(14.95f)) && (item_box->rot[1] > 0)) {
77 } else if ((item_box->rot[1] > (150 * DEGREES(1))) && (item_box->rot[1] < (165 * DEGREES(1)))) {
79 } else if ((item_box->rot[1] > (80 * DEGREES(1))) && (item_box->rot[1] < (95 * DEGREES(1)))) {
81 } else if ((item_box->rot[1] > (280 * DEGREES(1))) && (item_box->rot[1] < (295 * DEGREES(1)))) {
83 } else {
84 gDPSetBlendMask(gDisplayListHead++, 0xFF);
86 }
87 gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
88 gSPDisplayList(gDisplayListHead++, D_0D003090);
89 } else {
90 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
91 gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
92 gDPSetBlendMask(gDisplayListHead++, 0xFF);
93 thing = item_box->someTimer;
94 mtxf_rotate_zxy_translate(someMatrix1, item_box->pos, item_box->rot);
95 if (thing < 10.0f) {
96 someMultiplier = 1.0f;
97 } else {
98 someMultiplier = 1.0f - ((thing - 10.0f) * 0.1f);
99 }
100 mtxf_scale(someMatrix1, someMultiplier);
101 if (item_box->someTimer & 1) {
103 } else {
105 }
106 temp_f2 = 2.0f * thing;
107 someVec1[0] = 0.0f;
108 someVec1[1] = temp_f2;
109 someVec1[2] = thing;
110 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
111
112 if (!render_set_position(someMatrix2, 0)) {
113 return;
114 }
115
116 gSPDisplayList(gDisplayListHead++, D_0D003158);
117 temp_f2_2 = 0.8f * thing;
118 temp_f12 = 0.5f * thing;
119 someVec1[0] = temp_f2_2;
120 someVec1[1] = 2.3f * thing;
121 someVec1[2] = temp_f12;
122 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
123
124 if (!render_set_position(someMatrix2, 0)) {
125 return;
126 }
127
128 gSPDisplayList(gDisplayListHead++, D_0D0031B8);
129 temp_f0_2 = -0.5f * thing;
130 someVec1[0] = temp_f2_2;
131 someVec1[1] = 1.2f * thing;
132 someVec1[2] = temp_f0_2;
133 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
134
135 if (!render_set_position(someMatrix2, 0)) {
136 return;
137 }
138
139 gSPDisplayList(gDisplayListHead++, D_0D003128);
140 if (!(item_box->someTimer & 1)) {
142 } else {
144 }
145 someVec1[0] = 0.0f;
146 someVec1[1] = 1.8f * thing;
147 someVec1[2] = -1.0f * thing;
148 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
149
150 if (!render_set_position(someMatrix2, 0)) {
151 return;
152 }
153
154 gSPDisplayList(gDisplayListHead++, D_0D0031E8);
155 temp_f0_3 = -0.8f * thing;
156 someVec1[0] = temp_f0_3;
157 someVec1[1] = 0.6f * thing;
158 someVec1[2] = temp_f0_2;
159 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
160
161 if (!render_set_position(someMatrix2, 0)) {
162 return;
163 }
164
165 gSPDisplayList(gDisplayListHead++, D_0D003188);
166 someVec1[0] = temp_f0_3;
167 someVec1[1] = temp_f2;
168 someVec1[2] = temp_f12;
169 add_translate_mat4_vec3f(someMatrix1, someMatrix2, someVec1);
170
171 if (!render_set_position(someMatrix2, 0)) {
172 return;
173 }
174
175 gSPDisplayList(gDisplayListHead++, D_0D0030F8);
176 gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK);
177 }
178 gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
179 }
180}
Camera * camera1
Definition camera.c:25
Gfx D_0D003090[]
Gfx itemBoxQuestionMarkModel[]
Gfx D_0D003188[]
Gfx D_0D0031E8[]
Gfx D_0D002EE8[]
Gfx D_0D003128[]
Gfx D_0D003158[]
Gfx D_0D0031B8[]
Gfx D_0D0030F8[]
f32 Vec3f[3]
Definition common_structs.h:6
s16 Vec3s[3]
Definition common_structs.h:11
f32 Mat4[4][4]
Definition common_structs.h:16
#define DEGREES(degree)
Definition defines.h:347
#define G_CULL_BACK
Definition gbi.h:351
#define G_RM_NOOP2
Definition gbi.h:968
#define G_RM_ZB_CLD_SURF2
Definition gbi.h:949
#define G_RM_ZB_CLD_SURF
Definition gbi.h:948
#define G_SHADING_SMOOTH
Definition gbi.h:349
#define G_RM_AA_ZB_OPA_SURF
Definition gbi.h:878
#define G_RM_AA_ZB_OPA_SURF2
Definition gbi.h:879
#define G_RM_AA_ZB_XLU_INTER
Definition gbi.h:888
#define G_LIGHTING
Definition gbi.h:355
#define G_CC_MODULATEIA
Definition gbi.h:488
void render_actor_item_box(Camera *camera, struct ItemBox *item_box)
Renders the item box actor.
Definition render.inc.c:11
#define UNUSED
Definition macros.h:23
Gfx * gDisplayListHead
Definition main.c:129
f32 gCameraZoom[4]
Definition main.c:119
void mtxf_rotate_zxy_translate(Mat4 dest, Vec3f translate, Vec3s orientation)
Definition math_util.c:588
void mtxf_scale(Mat4 mtx, f32 coef)
Definition math_util.c:570
s32 render_set_position(Mat4 mtx, s32 mode)
Definition math_util.c:47
void add_translate_mat4_vec3f(Mat4 src, Mat4 dest, Vec3f translate)
Definition math_util.c:235
f32 distance_if_visible(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, f32 preloadDistanceSquared, f32 fovDegrees, f32 maxDistanceSquared)
Definition math_util.c:1361
#define G_ON
Definition mbi.h:51
Definition camera.h:26
Vec3s rot
Definition camera.h:33
Vec3f pos
Definition camera.h:27
Definition actor_types.h:331
s16 someTimer
Definition actor_types.h:334
Vec3f pos
Definition actor_types.h:342
s16 state
Definition actor_types.h:335
f32 resetDistance
Definition actor_types.h:336
Vec3s rot
Definition actor_types.h:340
signed int s32
Definition ultratypes.h:15
float f32
Definition ultratypes.h:34