74 sceVu0FVECTOR *vertices;
87 u_int end[4] = {0x11000000, 0, 0, 0};
91 vertices = (sceVu0FVECTOR *) ((u_char *) model + model->
vertex_ofs);
95 for (shape_index = 0; shape_index < shape_num; shape_index++) {
96 index_num = ((
MDT_SSHAPE *) corner)->index_num;
100 sceVu0FVECTOR one = {1.0f, 1.0f, 1.0f, 1.0f};
102 while (emitted < index_num) {
105 block[(u_int) (word + 1)] = 0;
106 block[(u_int) (word + 2)] = 0;
108 block[unpack] = 0x6C008000;
111 block[(u_int) (word + 5)] = 0x2022C000;
112 block[(u_int) (word + 6)] = 0x41;
113 block[(u_int) (word + 7)] = 0;
117 out = (u_long128 *) &block[word];
119 for (triangle = 0; triangle < 10 && emitted < index_num; triangle++, emitted += 3) {
120 out[0] = *(u_long128 *) one;
121 out[1] = *(u_long128 *) one;
122 out[2] = *(u_long128 *) one;
123 out[3] = *(u_long128 *) vertices[source[0].index];
124 out[4] = *(u_long128 *) vertices[source[1].index];
125 out[5] = *(u_long128 *) vertices[source[2].index];
130 word += triangle * 24;
132 corner += triangle * 3;
133 block[(u_int) tag] |= triangle;
134 block[(u_int) unpack] |= qwc << 16;
136 block[(u_int) (word + 1)] = 0;
137 block[(u_int) (word + 2)] = 0;
141 block[(u_int) (word + 3)] = 0x14000000;
145 block[(u_int) (word + 3)] = 0x14000001;
151 block[(u_int) (word + 3)] = 0x17000000;
156 *(u_long128 *) &block[word] = *(u_long128 *) end;
184 sceVu0FVECTOR *vertices;
191 sceVu0FVECTOR *projected;
207 sceVu0FMATRIX near_shadow;
208 sceVu0FVECTOR local_light;
210 sceVu0FVECTOR eye_light;
211 sceVu0FMATRIX shadow_matrix;
212 sceVu0FMATRIX local_to_clip;
213 sceVu0FMATRIX transpose;
214 sceVu0FMATRIX local_to_eye;
215 sceVu0FMATRIX shadow_to_eye;
217 sceVu0FVECTOR normal;
218 sceVu0FVECTOR direction;
219 sceVu0FVECTOR near_light;
221 if (model_data == NULL) {
229 sceVu0TransposeMatrix(transpose, matrix);
230 sceVu0ApplyMatrix(local_light, transpose, light);
231 MulMatrix(local_to_eye, info->
view_scaled, matrix);
232 sceVu0ApplyMatrix(eye_light, info->
view_scaled, light);
233 MulMatrix(local_to_clip, info->
perspective, local_to_eye);
234 sceVu0Normalize(eye_light, eye_light);
241 plane_scale = sceVu0InnerProduct(normal, point);
243 if (plane_scale == 0.0f) {
244 point[0] -= 0.1f * normal[0];
245 point[1] -= 0.1f * normal[1];
246 point[2] -= 0.1f * normal[2];
250 plane_scale = 1.0f / plane_scale;
251 nx = normal[0] * plane_scale;
252 ny = normal[1] * plane_scale;
253 nz = normal[2] * plane_scale;
254 sceVu0Normalize(direction, direction);
255 sceVu0DropShadowMatrix(shadow_matrix, direction, nx, ny, nz, 0);
256 MulMatrix(shadow_matrix, shadow_matrix, matrix);
257 MulMatrix(shadow_to_eye, info->
view_scaled, shadow_matrix);
258 MulMatrix(shadow_matrix, info->
perspective, shadow_to_eye);
260 sceVu0FVECTOR near_normal = {0.0f, 0.0f, 1.0f, 0.0f};
261 sceVu0FVECTOR near_point = {0.0f, 0.0f, 0.0f, 0.0f};
262 near_point[2] = info->
near[2];
263 scale = 1.0f / sceVu0InnerProduct(near_normal, near_point);
264 nx = near_normal[0] * scale;
265 ny = near_normal[1] * scale;
266 nz = near_normal[2] * scale;
267 sceVu0Normalize(near_light, eye_light);
268 sceVu0DropShadowMatrix(near_shadow, near_light, nx, ny, nz, 0);
272 u_int end[4] = {0, 0, 0, 0x11000000};
276 vertices = (sceVu0FVECTOR *) ((u_char *) model + model->
vertex_ofs);
278 eye = (sceVu0FVECTOR *) 0x70000000;
282 sceVu0ApplyMatrix((
float *) eye[i], local_to_eye, vertices[i]);
283 sceVu0ApplyMatrix(projected[i], shadow_to_eye, vertices[i]);
286 for (pass = 0; pass < 2; pass++) {
288 block[(u_int) (word + 1)] = 0;
289 block[(u_int) (word + 2)] = 0;
290 block[(u_int) (word + 3)] = 0x50000002;
291 block[(u_int) (word + 4)] = 0x8001;
292 block[(u_int) (word + 5)] = 0x102E8000;
293 block[(u_int) (word + 6)] = 0xE;
294 block[(u_int) (word + 7)] = 0;
297 block[(u_int) (word + 8)] = 0x68;
298 block[(u_int) (word + 9)] = 0x80;
299 block[(u_int) (word + 10)] = 0x42;
300 block[(u_int) (word + 11)] = 0;
303 block[(u_int) (word + 8)] = 0x62;
304 block[(u_int) (word + 9)] = 0x80;
305 block[(u_int) (word + 10)] = 0x42;
306 block[(u_int) (word + 11)] = 0;
312 for (shape_index = 0; shape_index < shape_num; shape_index++) {
313 index_num = ((
MDT_SSHAPE *) corner)->index_num;
317 u_int edges[4] = {0, 0, 0, 0};
319 while (emitted < index_num) {
322 block[(u_int) (word + 1)] = 0;
323 block[(u_int) (word + 2)] = 0;
325 block[unpack] = 0x6C008000;
328 block[(u_int) (word + 5)] = 0x2022C000;
329 block[(u_int) (word + 6)] = 0x41;
330 block[(u_int) (word + 7)] = 0;
331 block[(u_int) (word + 8)] = pass != 0;
332 block[(u_int) (word + 9)] = 0;
333 block[(u_int) (word + 10)] = 0;
334 block[(u_int) (word + 11)] = 0;
337 out = (u_long128 *) &block[word];
340 for (count = 0; count < 12 && emitted < index_num; count++, emitted += 3, corner += 3) {
344 sceVu0FVECTOR near_side[4];
345 sceVu0FVECTOR clipped[5];
346 sceVu0FVECTOR far_side[4];
350 index_a = corner[0].
index;
351 index_b = corner[1].
index;
352 index_c = corner[2].
index;
353 edges[0] = corner[0].
edge;
354 edges[1] = corner[1].
edge;
355 edges[2] = corner[2].
edge;
357 offset_a = index_a *
sizeof(sceVu0FVECTOR);
358 out[1] = *(u_long128 *) ((u_char *) vertices + offset_a);
359 offset_b = index_b *
sizeof(sceVu0FVECTOR);
360 out[2] = *(u_long128 *) ((u_char *) vertices + offset_b);
361 offset_c = index_c *
sizeof(sceVu0FVECTOR);
362 out[3] = *(u_long128 *) ((u_char *) vertices + offset_c);
363 sceVu0SubVector(edge0, (
float *) &out[2], (
float *) &out[1]);
364 sceVu0SubVector(edge1, (
float *) &out[3], (
float *) &out[1]);
365 sceVu0OuterProduct(face, edge0, edge1);
367 if (sceVu0InnerProduct(face, local_light) <= 0.0f) {
368 out[4] = *(u_long128 *) vertices[index_c];
370 out[0] = *(u_long128 *) edges;
371 *(u_long128 *) near_side[0] = *(u_long128 *) ((u_char *) eye + offset_a);
372 *(u_long128 *) near_side[1] = *(u_long128 *) ((u_char *) eye + offset_b);
373 *(u_long128 *) near_side[2] = *(u_long128 *) ((u_char *) eye + offset_c);
374 *(u_long128 *) near_side[3] = *(u_long128 *) ((u_char *) eye + offset_a);
375 *(u_long128 *) far_side[0] = *(u_long128 *) ((u_char *) projected + offset_a);
376 *(u_long128 *) far_side[1] = *(u_long128 *) ((u_char *) projected + offset_b);
377 *(u_long128 *) far_side[2] = *(u_long128 *) ((u_char *) projected + offset_c);
378 *(u_long128 *) far_side[3] = *(u_long128 *) ((u_char *) projected + offset_a);
379 clip_num = scissior(clipped, near_side, far_side, info->
near[2]);
380 sceVu0SubVector(side0, clipped[1], clipped[0]);
381 sceVu0SubVector(side1, clipped[2], clipped[0]);
382 sceVu0ApplyMatrix(near_side[0], clip, (
float *) clipped[0]);
383 sceVu0ApplyMatrix(near_side[1], clip, clipped[1]);
384 sceVu0ApplyMatrix(near_side[2], clip, clipped[2]);
385 sceVu0ApplyMatrix(near_side[3], clip, (
float *) clipped[3]);
386 sceVu0ApplyMatrix(clipped[0], clip, (
float *) clipped[4]);
387 int counts[4] = {0, 0, 0, 1};
388 counts[0] = clip_num;
400 out[5] = *(u_long128 *) counts;
403 out[6] = *(u_long128 *) clipped[0];
404 out[7] = *(u_long128 *) near_side[3];
405 out[8] = *(u_long128 *) near_side[2];
406 out[9] = *(u_long128 *) near_side[1];
407 out[10] = *(u_long128 *) near_side[0];
410 out[6] = *(u_long128 *) near_side[0];
411 out[7] = *(u_long128 *) near_side[0];
412 out[8] = *(u_long128 *) near_side[0];
413 out[9] = *(u_long128 *) near_side[0];
414 out[10] = *(u_long128 *) near_side[0];
421 word += triangle * 44;
422 qwc += triangle * 11;
423 block[(u_int) tag] |= triangle;
424 block[(u_int) unpack] |= qwc << 16;
426 block[(u_int) (word + 1)] = 0;
427 block[(u_int) (word + 2)] = 0;
431 block[(u_int) (word + 3)] = 0x14000000;
435 block[(u_int) (word + 3)] = 0x14000001;
441 block[(u_int) (word + 3)] = 0x17000000;
449 *(u_long128 *) &block[word] = *(u_long128 *) end;