Mario Kart 64
Loading...
Searching...
No Matches
render.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <code_800029B0.h>
3#include <PR/gbi.h>
4#include <main.h>
5
12void render_actor_fake_item_box(Camera* camera, struct FakeItemBox* fakeItemBox) {
13 Vec3s someRot;
14 UNUSED s32 pad[3];
15 Vec3f someVec;
16 Mat4 someMatrix2;
17 Mat4 someMatrix3;
18 UNUSED s32 pad2[12];
19 f32 temp_f0_2;
20 f32 temp_f0_3;
21 f32 temp_f12;
22 f32 temp_f2;
23 f32 thing;
24 f32 temp_f2_2;
25 f32 someMultiplier;
26
27 if (distance_if_visible(camera->pos, fakeItemBox->pos, camera->rot[1], 2500.0f, gCameraZoom[camera - camera1],
28 1000000.0f) < 0) {
29 actor_not_rendered(camera, (struct Actor*) fakeItemBox);
30 return;
31 }
32 if (((f32) gCourseMaxY + 800.0f) < fakeItemBox->pos[1]) {
33 actor_not_rendered(camera, (struct Actor*) fakeItemBox);
34 return;
35 }
36 if (fakeItemBox->pos[1] < ((f32) gCourseMinY - 800.0f)) {
37 actor_not_rendered(camera, (struct Actor*) fakeItemBox);
38 return;
39 }
40
41 actor_rendered(camera, (struct Actor*) fakeItemBox);
42 someRot[0] = 0;
43 someRot[1] = fakeItemBox->rot[1];
44 someRot[2] = 0;
45 mtxf_rotate_zxy_translate(someMatrix2, fakeItemBox->pos, someRot);
46 mtxf_scale(someMatrix2, fakeItemBox->sizeScaling);
47 if (fakeItemBox->state != 2) {
48
49 if (!render_set_position(someMatrix2, 0)) {
50 return;
51 }
52
54 mtxf_rotate_zxy_translate(someMatrix2, fakeItemBox->pos, fakeItemBox->rot);
55 mtxf_scale(someMatrix2, fakeItemBox->sizeScaling);
56
57 if (!render_set_position(someMatrix2, 0)) {
58 return;
59 }
60
61 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
63 // unclear why it is 14.95 degrees instead of 15. Perhaps just a typo when entering the value as a s16.
64 if ((fakeItemBox->rot[1] < DEGREES(14.95f)) && (fakeItemBox->rot[1] > 0)) {
66 } else if ((fakeItemBox->rot[1] > (150 * DEGREES(1))) && (fakeItemBox->rot[1] < (165 * DEGREES(1)))) {
68 } else if ((fakeItemBox->rot[1] > (80 * DEGREES(1))) && (fakeItemBox->rot[1] < (95 * DEGREES(1)))) {
70 } else if ((fakeItemBox->rot[1] > (280 * DEGREES(1))) && (fakeItemBox->rot[1] < (295 * DEGREES(1)))) {
72 } else {
73 gDPSetBlendMask(gDisplayListHead++, 0xFF);
75 }
76 gSPDisplayList(gDisplayListHead++, D_0D003090);
77 } else {
78 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
79 gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
80 gDPSetBlendMask(gDisplayListHead++, 0xFF);
81 thing = fakeItemBox->someTimer;
82 mtxf_rotate_zxy_translate(someMatrix2, fakeItemBox->pos, fakeItemBox->rot);
83 if (thing < 10.0f) {
84 someMultiplier = 1.0f;
85 } else {
86 someMultiplier = 1.0f - ((thing - 10.0f) * 0.1f);
87 }
88 mtxf_scale(someMatrix2, someMultiplier);
89 if (fakeItemBox->someTimer & 1) {
91 } else {
93 }
94 temp_f2 = 2.0f * thing;
95 someVec[0] = 0.0f;
96 someVec[1] = temp_f2;
97 someVec[2] = thing;
98 add_translate_mat4_vec3f(someMatrix2, someMatrix3, someVec);
99
100 if (!render_set_position(someMatrix3, 0)) {
101 return;
102 }
103
104 gSPDisplayList(gDisplayListHead++, D_0D003158);
105 temp_f2_2 = 0.8f * thing;
106 temp_f12 = 0.5f * thing;
107 someVec[0] = temp_f2_2;
108 someVec[1] = 2.3f * thing;
109 someVec[2] = temp_f12;
110 add_translate_mat4_vec3f(someMatrix2, someMatrix3, someVec);
111
112 if (!render_set_position(someMatrix3, 0)) {
113 return;
114 }
115
116 gSPDisplayList(gDisplayListHead++, D_0D0031B8);
117 temp_f0_2 = -0.5f * thing;
118 someVec[0] = temp_f2_2;
119 someVec[1] = 1.2f * thing;
120 someVec[2] = temp_f0_2;
121 add_translate_mat4_vec3f(someMatrix2, someMatrix3, someVec);
122
123 if (!render_set_position(someMatrix3, 0)) {
124 return;
125 }
126
127 gSPDisplayList(gDisplayListHead++, D_0D003128);
128 if (!(fakeItemBox->someTimer & 1)) {
130 } else {
132 }
133 someVec[0] = 0.0f;
134 someVec[1] = 1.8f * thing;
135 someVec[2] = -1.0f * thing;
136 add_translate_mat4_vec3f(someMatrix2, someMatrix3, someVec);
137
138 if (!render_set_position(someMatrix3, 0)) {
139 return;
140 }
141
142 gSPDisplayList(gDisplayListHead++, D_0D0031E8);
143 temp_f0_3 = -0.8f * thing;
144 someVec[0] = temp_f0_3;
145 someVec[1] = 0.6f * thing;
146 someVec[2] = temp_f0_2;
147 add_translate_mat4_vec3f(someMatrix2, someMatrix3, someVec);
148
149 if (!render_set_position(someMatrix3, 0)) {
150 return;
151 }
152
153 gSPDisplayList(gDisplayListHead++, D_0D003188);
154 someVec[0] = temp_f0_3;
155 someVec[1] = temp_f2;
156 someVec[2] = temp_f12;
157 add_translate_mat4_vec3f(someMatrix2, someMatrix3, someVec);
158
159 if (!render_set_position(someMatrix3, 0)) {
160 return;
161 }
162
163 gSPDisplayList(gDisplayListHead++, D_0D0030F8);
164 gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK);
165 }
166}
void actor_not_rendered(Camera *arg0, struct Actor *arg1)
Definition actors.c:283
void actor_rendered(Camera *arg0, struct Actor *arg1)
Definition actors.c:300
Camera * camera1
Definition camera.c:25
s16 gCourseMaxY
Definition code_800029B0.c:91
s16 gCourseMinY
Definition code_800029B0.c:92
Gfx D_0D003090[]
Gfx D_0D003188[]
Gfx D_0D0031E8[]
Gfx D_0D003128[]
Gfx D_0D003158[]
Gfx D_0D0031B8[]
Gfx D_0D0030F8[]
Gfx common_model_fake_itembox[]
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
void render_actor_fake_item_box(Camera *camera, struct FakeItemBox *fakeItemBox)
Renders the fake item box actor.
Definition render.inc.c:12
#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_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
#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
Definition actor_types.h:120
Definition camera.h:26
Vec3s rot
Definition camera.h:33
Vec3f pos
Definition camera.h:27
Definition actor_types.h:349
Vec3s rot
Definition actor_types.h:356
s16 someTimer
Definition actor_types.h:352
f32 sizeScaling
Definition actor_types.h:354
s16 state
Definition actor_types.h:353
Vec3f pos
Definition actor_types.h:358
signed int s32
Definition ultratypes.h:15
float f32
Definition ultratypes.h:34