58int scissior(
float out[][4],
float first[][4],
float second[][4],
float near_z) {
59 float first_distance[4];
60 float second_distance[4];
81 for (i = 0; i < 3; i++) {
82 first_distance[i] = first[i][2] - near_z;
83 second_distance[i] = second[i][2] - near_z;
85 if (!(first_distance[i] <= 0.0f)) {
91 if (!(second_distance[i] <= 0.0f)) {
98 if (first_distance[0] * first_distance[1] < 0.0f) {
102 if (first_distance[1] * first_distance[2] < 0.0f) {
106 if (first_distance[2] * first_distance[0] < 0.0f) {
110 if (second_distance[0] * second_distance[1] < 0.0f) {
114 if (second_distance[1] * second_distance[2] < 0.0f) {
118 if (second_distance[2] * second_distance[0] < 0.0f) {
122 if (first_distance[0] * second_distance[0] < 0.0f) {
126 if (first_distance[1] * second_distance[1] < 0.0f) {
130 if (first_distance[2] * second_distance[2] < 0.0f) {
134 crossing_count = first_crosses + second_crosses + pair_crosses;
136 if (crossing_count == 0) {
137 for (
int j = 0; j < 5; j++) {
138 *(u_long128 *) out[j] = *(u_long128 *) first[0];
144 if (crossing_count == 4 && pair_crosses == 0) {
145 if (first_distance[0] * first_distance[1] < 0.0f) {
146 zcross(near_z, first[0], first[1], out[count++]);
149 if (first_distance[1] * first_distance[2] < 0.0f) {
150 zcross(near_z, first[1], first[2], out[count++]);
153 if (first_distance[2] * first_distance[0] < 0.0f) {
154 zcross(near_z, first[2], first[0], out[count++]);
157 if (second_distance[0] * second_distance[2] < 0.0f) {
158 zcross(near_z, second[0], second[2], out[count++]);
161 if (second_distance[2] * second_distance[1] < 0.0f) {
162 zcross(near_z, second[2], second[1], out[count++]);
165 if (second_distance[1] * second_distance[0] < 0.0f) {
166 zcross(near_z, second[1], second[0], out[count++]);
168 }
else if (crossing_count == 3 || crossing_count == 4) {
169 if (first_distance[0] * second_distance[0] < 0.0f) {
170 zcross(near_z, first[0], second[0], out[count++]);
173 if (first_distance[0] * first_distance[1] < 0.0f) {
174 zcross(near_z, first[0], first[1], out[count++]);
177 if (second_distance[0] * second_distance[1] < 0.0f) {
178 zcross(near_z, second[0], second[1], out[count++]);
181 if (first_distance[1] * second_distance[1] < 0.0f) {
182 zcross(near_z, first[1], second[1], out[count++]);
185 if (second_distance[1] * second_distance[2] < 0.0f) {
186 zcross(near_z, second[1], second[2], out[count++]);
189 if (first_distance[1] * first_distance[2] < 0.0f) {
190 zcross(near_z, first[1], first[2], out[count++]);
193 if (first_distance[2] * second_distance[2] < 0.0f) {
194 zcross(near_z, first[2], second[2], out[count++]);
197 if (first_distance[2] * first_distance[0] < 0.0f) {
198 zcross(near_z, first[2], first[0], out[count++]);
201 if (second_distance[2] * second_distance[0] < 0.0f) {
202 zcross(near_z, second[2], second[0], out[count++]);
204 }
else if (crossing_count == 5) {
208 if (first_distance[0] * second_distance[0] < 0.0f) {
209 zcross(near_z, first[0], second[0], out[count++]);
210 }
else if (first_distance[1] * second_distance[1] < 0.0f) {
211 zcross(near_z, first[1], second[1], out[count++]);
213 }
else if (first_distance[2] * second_distance[2] < 0.0f) {
214 zcross(near_z, first[2], second[2], out[count++]);
218 for (
int side = 0; side < 3; side++) {
219 int next = vertex + 1;
225 if (on_second == 0) {
226 if (first_distance[vertex] * first_distance[next] < 0.0f) {
227 zcross(near_z, first[vertex], first[next], out[count++]);
231 if (second_distance[vertex] * second_distance[next] < 0.0f) {
232 zcross(near_z, second[vertex], second[next], out[count++]);
236 if (second_distance[vertex] * second_distance[next] < 0.0f) {
237 zcross(near_z, second[vertex], second[next], out[count++]);
241 if (first_distance[vertex] * first_distance[next] < 0.0f) {
242 zcross(near_z, first[vertex], first[next], out[count++]);
254 printf(
"%d*******\n", crossing_count);
258 for (
int j = 0; j < 5; j++) {
259 *(u_long128 *) out[j] = *(u_long128 *) first[0];
262 for (
int j = count; j < 5; j++) {
263 *(u_long128 *) out[j] = *(u_long128 *) out[j - count];
879 sceVu0FVECTOR ambient;
880 sceVu0FVECTOR saved_ambient;
881 float light_direction[4][4];
882 float light_colour[4][4];
883 float saved_light_colour[4][4];
884 float saved_light_direction[4][4];
886 sceVu0FVECTOR direction;
895 if (this->
frame != NULL) {
896 this->
frame->SetPosition(this->pos[0], this->pos[1], this->pos[2]);
897 this->
frame->SetRotation(this->
rotation.
x, this->rotation.y, this->rotation.z);
901 fading = this->
fade[0] < 1.0f;
905 MGGetAmbient(ambient);
906 MGGetPLight(light_direction, light_colour);
907 sceVu0CopyMatrix(saved_light_colour, light_colour);
908 sceVu0CopyMatrix(saved_light_direction, light_direction);
909 sceVu0CopyVector(saved_ambient, ambient);
915 if (saved_light_direction[0][light_slot] != 0.0f) {
919 if (saved_light_direction[1][light_slot] != 0.0f) {
923 if (saved_light_direction[2][light_slot] != 0.0f) {
933 distance = DistVector(direction);
935 if (!(distance <= this->
point_light[i].outer_range)) {
939 sceVu0Normalize(direction, direction);
940 light_direction[0][light_slot] = direction[0];
941 light_direction[1][light_slot] = direction[1];
942 light_direction[2][light_slot] = direction[2];
948 if (!(distance <= this->
point_light[i].inner_range)) {
959 if (light_slot <= 2) {
965 sceVu0ScaleVectorXYZ(ambient, ambient, this->
fade[0]);
967 for (colour_no = 0; colour_no < 4; colour_no++) {
968 sceVu0ScaleVectorXYZ(light_colour[colour_no], light_colour[colour_no], this->
fade[0]);
980 MGSetAmbient(ambient);
981 MGSetPLight(light_direction, light_colour);
985 if (this->
cloth[cloth_no] != NULL) {
990 MGSetAmbient(saved_ambient);
991 MGSetPLight(saved_light_direction, saved_light_colour);