#include "colors.inc" light_source{ <-50, 100, 0> color White } camera{ location<-30, 30, -80> look_at<0, 0, 0> angle 30 } #declare roviny = true; #ifdef(roviny) // rovina YZ box{ <0, -10, -10> <.0001, 10, 10> pigment{ color White filter .6 } } // rovina XZ box{ <-10, 0, -10> <10, .0001, 10> pigment{ color White filter .6 } } // rovina XY box{ <-10, -10, 0> <10, 10, .0001> pigment{ color White filter .6 } } #end #macro newTris_x(A, B, C) #local clippnig = false; // Whole triangle alone in it's hlaf-space #if(A.x * B.x >= 0 | A.x * C.x >= 0 | B.x * C.x >= 0) #local clippnig = false; #end // A alone in it's hlaf-space // B = 0, other alone in it's hlaf-spaces #if( (A.x * B.x < 0 & A.x * C.x < 0) | (B.x = 0 & A.x * C.x < 0) ) #local clippnig = true; #end // C alone in it's hlaf-space // C = 0, other alone in it's hlaf-spaces #if( (B.x * C.x < 0 & A.x * C.x < 0) | (C.x = 0 & B.x * A.x < 0) ) #local swap = A; #local A = C; #local C = swap; #local clippnig = true; #end // B alone in it's hlaf-space // A = 0, other alone in it's hlaf-spaces #if( (A.x * B.x < 0 & B.x * C.x < 0) | (A.x = 0 & B.x * C.x < 0) ) #local swap = A; #local A = B; #local B = swap; #local clippnig = true; #end #if(clippnig) #local p = -A.x / (C.x - A.x); #local E = ; #if(!B.x = 0) #local p = -A.x / (B.x - A.x); #local D = ; newTris_y(A, D, E) newTris_y(C, D, E) newTris_y(C, D, B) #else newTris_y(A, E, B) newTris_y(C, E, B) #end #else newTris_y(A, B, C) #end #end //----------------------------------------------------------------------------------------------------------- #macro newTris_y(A, B, C) #local clippnig = false; // Whole triangle alone in it's hlaf-space #if(A.y * B.y >= 0 | A.y * C.y >= 0 | B.y * C.y >= 0) #local clippnig = false; #end // A alone in it's hlaf-space // B = 0, other alone in it's hlaf-spaces #if( (A.y * B.y < 0 & A.y * C.y < 0) | (B.y = 0 & A.y * C.y < 0) ) #local clippnig = true; #end // C alone in it's hlaf-space // C = 0, other alone in it's hlaf-spaces #if( (B.y * C.y < 0 & A.y * C.y < 0) | (C.y = 0 & B.y * A.y < 0) ) #local swap = A; #local A = C; #local C = swap; #local clippnig = true; #end // B alone in it's hlaf-space // A = 0, other alone in it's hlaf-spaces #if( (A.y * B.y < 0 & B.y * C.y < 0) | (A.y = 0 & B.y * C.y < 0) ) #local swap = A; #local A = B; #local B = swap; #local clippnig = true; #end #if(clippnig) #local p = -A.y / (C.y - A.y); #local E = ; #if(!B.y = 0) #local p = -A.y / (B.y - A.y); #local D = ; newTris_z(A, D, E) newTris_z(C, D, E) newTris_z(C, D, B) #else newTris_z(A, E, B) newTris_z(C, E, B) #end #else newTris_z(A, B, C) #end #end //----------------------------------------------------------------------------------------------------------- #macro newTris_z(A, B, C) #local clippnig = false; // Whole triangle alone in it's hlaf-space #if(A.z * B.z >= 0 | A.z * C.z >= 0 | B.z * C.z >= 0) #local clippnig = false; #end // A alone in it's hlaf-space // B = 0, other alone in it's hlaf-spaces #if( (A.z * B.z < 0 & A.z * C.z < 0) | (B.z = 0 & A.z * C.z < 0) ) #local clippnig = true; #end // C alone in it's hlaf-space // C = 0, other alone in it's hlaf-spaces #if( (B.z * C.z < 0 & A.z * C.z < 0) | (C.z = 0 & B.z * A.z < 0) ) #local swap = A; #local A = C; #local C = swap; #local clippnig = true; #end // B alone in it's hlaf-space // A = 0, other alone in it's hlaf-spaces #if( (A.z * B.z < 0 & B.z * C.z < 0) | (A.z = 0 & B.z * C.z < 0) ) #local swap = A; #local A = B; #local B = swap; #local clippnig = true; #end #if(clippnig) #local p = -A.z / (C.z - A.z); #local E = ; #if(!B.z = 0) #local p = -A.z / (B.z - A.z); #local D = ; triangle{A D E pigment{color Red}} triangle{C D E pigment{color Green}} triangle{C D B pigment{color Blue}} #else triangle{A E B pigment{color Orange}} triangle{C E B pigment{color Brown}} #end #else triangle{A B C pigment{color Yellow}} #end #undef A #undef B #undef C #undef D #undef E #end newTris_x(<-5, -4, -3>, <-9, 1, 6>, <6, 8, 1>)