Mario Kart 64
Loading...
Searching...
No Matches
render.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <PR/gbi.h>
3#include <main.h>
5
14void render_actor_train_engine(Camera* camera, struct TrainCar* actor) {
15 UNUSED s32 pad[2];
16 s32 maxObjectsReached;
17 Vec3f sp160;
18 Mat4 sp120;
19 Mat4 spE0;
20 Mat4 spA0;
21
22 f32 distance = is_within_render_distance(camera->pos, actor->pos, camera->rot[1], 2500.0f,
23 gCameraZoom[camera - camera1], 9000000.0f);
24
25 if (distance < 0.0f) {
26 return;
27 }
28
29 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
30
31 mtxf_pos_rotation_xyz(sp120, actor->pos, actor->rot);
32 maxObjectsReached = render_set_position(sp120, 0) == 0;
33 if (maxObjectsReached) {
34 return;
35 }
36
37 if (distance < 122500.0f) {
38
41
42 } else if (distance < 640000.0f) {
43
46 } else {
49 }
50 if (1440000.0f < distance) {
51 return;
52 }
53
54 gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
56
57 mtxf_rotate_x(sp120, actor->wheelRot);
58 vec3f_set(sp160, 17.0f, 6.0f, 32.0f);
59 mtxf_translate(spE0, sp160);
60 mtxf_multiplication(spA0, sp120, spE0);
61
62 maxObjectsReached = render_set_position(spA0, 3) == 0;
63 if (maxObjectsReached) {
64 return;
65 }
66
68 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
69
70 mtxf_rotate_x(sp120, actor->wheelRot);
71 vec3f_set(sp160, -17.0, 6.0f, 32.0f);
72 mtxf_translate(spE0, sp160);
73 mtxf_multiplication(spA0, sp120, spE0);
74
75 maxObjectsReached = render_set_position(spA0, 3) == 0;
76 if (maxObjectsReached) {
77 return;
78 }
79
81 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
82
83 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C));
84 vec3f_set(sp160, 17.0f, 6.0f, 16.0f);
85 mtxf_translate(spE0, sp160);
86 mtxf_multiplication(spA0, sp120, spE0);
87
88 maxObjectsReached = render_set_position(spA0, 3) == 0;
89 if (maxObjectsReached) {
90 return;
91 }
92
94 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
95
96 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C));
97 vec3f_set(sp160, -17.0f, 6.0f, 16.0f);
98 mtxf_translate(spE0, sp160);
99 mtxf_multiplication(spA0, sp120, spE0);
100
101 maxObjectsReached = render_set_position(spA0, 3) == 0;
102 if (maxObjectsReached) {
103 return;
104 }
105
107 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
108
109 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444));
110 vec3f_set(sp160, 17.0f, 12.0f, -12.0f);
111 mtxf_translate(spE0, sp160);
112 mtxf_multiplication(spA0, sp120, spE0);
113
114 maxObjectsReached = render_set_position(spA0, 3) == 0;
115 if (maxObjectsReached) {
116 return;
117 }
118
120 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
121
122 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444));
123 vec3f_set(sp160, -17.0f, 12.0f, -12.0f);
124 mtxf_translate(spE0, sp160);
125 mtxf_multiplication(spA0, sp120, spE0);
126
127 maxObjectsReached = render_set_position(spA0, 3) == 0;
128 if (maxObjectsReached) {
129 return;
130 }
131
133 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
134
135 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x2D8));
136 vec3f_set(sp160, 17.0f, 12.0f, -34.0f);
137 mtxf_translate(spE0, sp160);
138 mtxf_multiplication(spA0, sp120, spE0);
139
140 maxObjectsReached = render_set_position(spA0, 3) == 0;
141 if (maxObjectsReached) {
142 return;
143 }
144
146 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
147
148 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x2D8));
149 vec3f_set(sp160, -17.0f, 12.0f, -34.0f);
150 mtxf_translate(spE0, sp160);
151 mtxf_multiplication(spA0, sp120, spE0);
152
153 maxObjectsReached = render_set_position(spA0, 3) == 0;
154 if (maxObjectsReached) {
155 return;
156 }
157
159 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
160 gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK);
161}
162
163void render_actor_train_tender(Camera* camera, struct TrainCar* actor) {
164 Mat4 sp120;
165 Vec3f sp160;
166 Mat4 spE0;
167 Mat4 spA0;
168
169 f32 temp_f0 = is_within_render_distance(camera->pos, actor->pos, camera->rot[1], 625.0f,
170 gCameraZoom[camera - camera1], 9000000.0f);
171
172 if (temp_f0 < 0.0f) {
173 return;
174 }
175
176 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
177
178 mtxf_pos_rotation_xyz(sp120, actor->pos, actor->rot);
179 if (render_set_position(sp120, 0) == 0) {
180 return;
181 }
182
183 if (temp_f0 < 250000.0f) {
184
186
187 } else if (temp_f0 < 1000000.0f) {
189 } else {
191 }
192 if (1440000.0f < temp_f0) {
193 return;
194 }
195
196 gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
198
199 mtxf_rotate_x(sp120, actor->wheelRot);
200 vec3f_set(sp160, 17.0f, 6.0f, 8.0f);
201 mtxf_translate(spE0, sp160);
202 mtxf_multiplication(spA0, sp120, spE0);
203
204 if (render_set_position(spA0, 3) == 0) {
205 return;
206 }
207
209 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
210
211 mtxf_rotate_x(sp120, actor->wheelRot);
212 vec3f_set(sp160, -17.0, 6.0f, 8.0f);
213 mtxf_translate(spE0, sp160);
214 mtxf_multiplication(spA0, sp120, spE0);
215
216 if (render_set_position(spA0, 3) == 0) {
217 return;
218 }
219
221 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
222
223 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444));
224 vec3f_set(sp160, 17.0f, 6.0f, -8.0f);
225 mtxf_translate(spE0, sp160);
226 mtxf_multiplication(spA0, sp120, spE0);
227
228 if (render_set_position(spA0, 3) == 0) {
229 return;
230 }
231
233 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
234
235 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444));
236 vec3f_set(sp160, -17.0f, 6.0f, -8.0f);
237 mtxf_translate(spE0, sp160);
238 mtxf_multiplication(spA0, sp120, spE0);
239
240 if (render_set_position(spA0, 3) == 0) {
241 return;
242 }
244 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
245 gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK);
246}
247
249 Mat4 sp120;
250 Vec3f sp160;
251 Mat4 spE0;
252 Mat4 spA0;
253
254 f32 temp_f0 = is_within_render_distance(camera->pos, actor->pos, camera->rot[1], 2025.0f,
255 gCameraZoom[camera - camera1], 9000000.0f);
256
257 if (temp_f0 < 0.0f) {
258 return;
259 }
260
261 gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
262
263 mtxf_pos_rotation_xyz(sp120, actor->pos, actor->rot);
264
265 if (render_set_position(sp120, 0) == 0) {
266 return;
267 }
268
269 if (temp_f0 < 250000.0f) {
270
273
274 } else if (temp_f0 < 1000000.0f) {
275
278 } else {
281 }
282 if (1440000.0f < temp_f0) {
283 return;
284 }
285
286 gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
288
289 mtxf_rotate_x(sp120, actor->wheelRot);
290 vec3f_set(sp160, 17.0f, 6.0f, 28.0f);
291 mtxf_translate(spE0, sp160);
292 mtxf_multiplication(spA0, sp120, spE0);
293
294 if (render_set_position(spA0, 3) == 0) {
295 return;
296 }
297
299 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
300
301 mtxf_rotate_x(sp120, actor->wheelRot);
302 vec3f_set(sp160, -17.0, 6.0f, 28.0f);
303 mtxf_translate(spE0, sp160);
304 mtxf_multiplication(spA0, sp120, spE0);
305
306 if (render_set_position(spA0, 3) == 0) {
307 return;
308 }
309
311 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
312
313 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x222));
314 vec3f_set(sp160, 17.0f, 6.0f, 12.0f);
315 mtxf_translate(spE0, sp160);
316 mtxf_multiplication(spA0, sp120, spE0);
317
318 if (render_set_position(spA0, 3) == 0) {
319 return;
320 }
321
323 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
324
325 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x222));
326 vec3f_set(sp160, -17.0f, 6.0f, 12.0f);
327 mtxf_translate(spE0, sp160);
328 mtxf_multiplication(spA0, sp120, spE0);
329
330 if (render_set_position(spA0, 3) == 0) {
331 return;
332 }
333
335 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
336
337 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x5B0));
338 vec3f_set(sp160, 17.0f, 6.0f, -8.0f);
339 mtxf_translate(spE0, sp160);
340 mtxf_multiplication(spA0, sp120, spE0);
341
342 if (render_set_position(spA0, 3) == 0) {
343 return;
344 }
345
347 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
348
349 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x5B0));
350 vec3f_set(sp160, -17.0f, 6.0f, -8.0f);
351 mtxf_translate(spE0, sp160);
352 mtxf_multiplication(spA0, sp120, spE0);
353
354 if (render_set_position(spA0, 3) == 0) {
355 return;
356 }
357
359 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
360
361 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C));
362 vec3f_set(sp160, 17.0f, 6.0f, -24.0f);
363 mtxf_translate(spE0, sp160);
364 mtxf_multiplication(spA0, sp120, spE0);
365
366 if (render_set_position(spA0, 3) == 0) {
367 return;
368 }
369
371 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
372
373 mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C));
374 vec3f_set(sp160, -17.0f, 6.0f, -24.0f);
375 mtxf_translate(spE0, sp160);
376 mtxf_multiplication(spA0, sp120, spE0);
377
378 if (render_set_position(spA0, 3) == 0) {
379 return;
380 }
381
383 gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
384 gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK);
385}
Camera * camera1
Definition camera.c:23
f32 Vec3f[3]
Definition common_structs.h:6
f32 Mat4[4][4]
Definition common_structs.h:16
#define G_CULL_BACK
Definition gbi.h:351
#define G_MTX_MODELVIEW
Definition gbi.h:305
#define G_LIGHTING
Definition gbi.h:355
Gfx d_course_kalimari_desert_dl_1FAF8[]
Definition course_data.c:5947
Gfx d_course_kalimari_desert_dl_22D28[]
Definition course_data.c:6902
Gfx d_course_kalimari_desert_dl_20A20[]
Definition course_data.c:6345
Gfx d_course_kalimari_desert_dl_21A80[]
Definition course_data.c:6786
Gfx d_course_kalimari_desert_dl_22DB8[]
Definition course_data.c:6928
Gfx d_course_kalimari_desert_dl_21550[]
Definition course_data.c:6657
Gfx d_course_kalimari_desert_dl_20A08[]
Definition course_data.c:6339
Gfx d_course_kalimari_desert_dl_1F708[]
Definition course_data.c:5826
Gfx d_course_kalimari_desert_dl_1F228[]
Definition course_data.c:5691
Gfx d_course_kalimari_desert_dl_1C0F0[]
Definition course_data.c:4421
Gfx d_course_kalimari_desert_dl_21C90[]
Definition course_data.c:6875
Gfx d_course_kalimari_desert_dl_1B978[]
Definition course_data.c:4152
Gfx d_course_kalimari_desert_dl_1E480[]
Definition course_data.c:5292
Gfx d_course_kalimari_desert_dl_1D160[]
Definition course_data.c:4781
Gfx d_course_kalimari_desert_dl_1E910[]
Definition course_data.c:5468
Gfx d_course_kalimari_desert_dl_1D670[]
Definition course_data.c:4973
Gfx d_course_kalimari_desert_dl_21220[]
Definition course_data.c:6528
Gfx d_course_kalimari_desert_dl_22D70[]
Definition course_data.c:6916
#define UNUSED
Definition macros.h:23
Gfx * gDisplayListHead
Definition main.c:132
f32 gCameraZoom[4]
Definition main.c:122
void mtxf_rotate_x(Mat4 mat, s16 angle)
Definition math_util.c:322
f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, f32 minDistance, f32 fov, f32 maxDistance)
Definition math_util.c:1114
void mtxf_multiplication(Mat4 dest, Mat4 mat1, Mat4 mat2)
Definition math_util.c:818
void mtxf_pos_rotation_xyz(Mat4 out, Vec3f pos, Vec3s orientation)
Definition math_util.c:468
void vec3f_set(Vec3f arg0, f32 arg1, f32 arg2, f32 arg3)
Definition math_util.c:103
s32 render_set_position(Mat4 arg0, s32 arg1)
Definition math_util.c:47
void mtxf_translate(Mat4 dest, Vec3f b)
Definition math_util.c:215
Definition camera.h:26
Vec3s rot
Definition camera.h:33
Vec3f pos
Definition camera.h:27
Definition actor_types.h:144
s16 wheelRot
Definition actor_types.h:148
Vec3f pos
Definition actor_types.h:153
Vec3s rot
Definition actor_types.h:151
void render_actor_train_engine(Camera *camera, struct TrainCar *actor)
Renders the train engine actor. Actor used in Kalimari Desert. His update position are made in vehicl...
Definition render.inc.c:14
void render_actor_train_tender(Camera *camera, struct TrainCar *actor)
Definition render.inc.c:163
void render_actor_train_passenger_car(Camera *camera, struct TrainCar *actor)
Definition render.inc.c:248
signed int s32
Definition ultratypes.h:15
signed short int s16
Definition ultratypes.h:13
float f32
Definition ultratypes.h:34