/* Sponge_raw.inc by Piotr Rashidow piotrrashidow@hotmail.com */ #ifndef(Debug) #declare Debug=false; #end #declare spc1=" " #declare spc2=" " #ifndef(Write_X_Wall_Only) #declare Write_X_Wall_Only=false; #end #ifndef(Hollow) #declare Hollow=false; #end #ifndef(tc) #declare tc=0; #end //triangles counter #ifndef(DP) #declare DP=3; #end //RAW #ifndef(RAW_COMMENTS) #declare RAW_COMMENTS=false; #end #declare RC=RAW_COMMENTS; #declare s1=" " #declare s2=" " //INC #ifndef(PRINT_COMMAS) #declare PRINT_COMMAS=false; #end #if(PRINT_COMMAS) #declare mi=">,<" #else #declare mi="><" #end #declare co="," #if(Debug) #if(RAW) #debug concat(spc1,"writing raw-file.\n") #end #if(INC) #debug concat(spc1,"writing inc-file.\n") #end #end #if(!INC & !RAW) #error "No output file is selected." #end #declare RW=Write_X_Wall_Only; #if(!RW) #declare ZA=3; #declare ZB=5; #declare ZC=9; #else #declare ZA=1; #declare ZB=1; #declare ZC=1; #end #ifndef(Dust) #declare Dust=true; #end #declare l1_s = array[3][3] { {1,1,1}, {1,0,1}, {1,1,1} } #declare l2_s = array[3][3] { {1,0,1}, {0,0,0}, {1,0,1} } #declare l1 = array[9][9] { {1,1,1,1,1,1,1,1,1}, {1,0,1,1,0,1,1,0,1}, {1,1,1,1,1,1,1,1,1}, {1,1,1,0,0,0,1,1,1}, {1,0,1,0,0,0,1,0,1}, {1,1,1,0,0,0,1,1,1}, {1,1,1,1,1,1,1,1,1}, {1,0,1,1,0,1,1,0,1}, {1,1,1,1,1,1,1,1,1} } #declare l2 = array[9][9] { {1,0,1,1,0,1,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,1,0,1,1,0,1}, {1,0,1,0,0,0,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,0,0,0,1,0,1}, {1,0,1,1,0,1,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,1,0,1,1,0,1} } #declare l4 = array[9][9] { {1,1,1,0,0,0,1,1,1}, {1,0,1,0,0,0,1,0,1}, {1,1,1,0,0,0,1,1,1}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0}, {1,1,1,0,0,0,1,1,1}, {1,0,1,0,0,0,1,0,1}, {1,1,1,0,0,0,1,1,1} } #declare l5 = array[9][9] { {1,0,1,0,0,0,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,0,0,0,1,0,1}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0}, {1,0,1,0,0,0,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,0,0,0,1,0,1} } #declare dst = array[9][9] { {9,1,9,0,1,0,9,1,9}, {1,0,1,1,0,1,1,0,1}, {9,1,9,0,1,0,9,1,9}, {0,1,0,0,0,0,0,1,0}, {1,0,1,0,0,0,1,0,1}, {0,1,0,0,0,0,0,1,0}, {9,1,9,0,1,0,9,1,9}, {1,0,1,1,0,1,1,0,1}, {9,1,9,0,1,0,9,1,9} } #declare dst2= array[9][9] { {1,0,1,1,0,1,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,1,0,1,1,0,1}, {1,0,1,0,0,0,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,0,0,0,1,0,1}, {1,0,1,1,0,1,1,0,1}, {0,0,0,0,0,0,0,0,0}, {1,0,1,1,0,1,1,0,1} } #macro PRINT(c1,c2,c3) #local P0=str(c1.x,1,DP) #local P1=str(c1.y,1,DP) #local P2=str(c1.z,1,DP) #local P3=str(c2.x,1,DP) #local P4=str(c2.y,1,DP) #local P5=str(c2.z,1,DP) #local P6=str(c3.x,1,DP) #local P7=str(c3.y,1,DP) #local P8=str(c3.z,1,DP) #if(RAW) #write (RAW_FILE,P0,s1,P1,s1,P2,s2,P3,s1,P4,s1,P5,s2,P6,s1,P7,s1,P8,"\n") #end #if(INC) #write (INC_FILE,"triangle{<",P0,co,P1,co,P2,mi,P3,co,P4,co,P5,mi,P6,co,P7,co,P8,">}\n") #end #end #macro BOX(X,Y,Z,X_LEN,Y_LEN,Z_LEN,BT,LR,BF) /* All triangles are clockwise x_len __________ /| /| / | / | y_len /__|______/ | | |______|__| | / | / | / | /z_len |/ |/ x,y,z_______| */ #local x_l=X+X_LEN; #local y_l=Y+Y_LEN; #local z_l=Z+Z_LEN; #if(BT)//bottom and top sides PRINT(,,) PRINT(,,) PRINT(,,) PRINT(,,) #declare tc=tc+4; #end #if(LR)//left and right sides PRINT(,,) PRINT(,,) PRINT(,,) PRINT(,,) #declare tc=tc+4; #end #if(BF)//back and front sides PRINT(,,) PRINT(,,) PRINT(,,) PRINT(,,) #declare tc=tc+4; #end #end #macro ROTATE(v1,v2,v3,vrot,tr,tr_v,DN) #declare vect1=((vrotate(v1,vrot)+tr)*(1/DN))+tr_v; #declare vect2=((vrotate(v2,vrot)+tr)*(1/DN))+tr_v; #declare vect3=((vrotate(v3,vrot)+tr)*(1/DN))+tr_v; PRINT(vect1,vect2,vect3) #end #declare vr=array[6] {<0,0,0>,<0,0,0>,<0,0,90>,<0,90,90>,<-90,0,0>,<-90,0,0>} #declare tr=array[6] {<0,0,0>,<0,9,0>,<0,0,0>,<9,0,9>,<0,0,0>,<0,0,9>} #macro HOLLOW_SPONGE(vect,D) #local i=0; #while(i<6) ROTATE(<0,0,0>,<9,0,0>,<9,0,1>,vr[i],tr[i],vect,D) ROTATE(<0,0,0>,<0,0,1>,<9,0,1>,vr[i],tr[i],vect,D) ROTATE(<0,0,2>,<9,0,2>,<9,0,3>,vr[i],tr[i],vect,D) ROTATE(<0,0,2>,<0,0,3>,<9,0,3>,vr[i],tr[i],vect,D) ROTATE(<0,0,6>,<9,0,6>,<9,0,7>,vr[i],tr[i],vect,D) ROTATE(<0,0,6>,<0,0,7>,<9,0,7>,vr[i],tr[i],vect,D) ROTATE(<0,0,8>,<9,0,8>,<9,0,9>,vr[i],tr[i],vect,D) ROTATE(<0,0,8>,<0,0,9>,<9,0,9>,vr[i],tr[i],vect,D) // ROTATE(<0,0,0>,<0,0,9>,<1,0,9>,vr[i],tr[i],vect,D) ROTATE(<0,0,0>,<1,0,0>,<1,0,9>,vr[i],tr[i],vect,D) ROTATE(<2,0,0>,<2,0,9>,<3,0,9>,vr[i],tr[i],vect,D) ROTATE(<2,0,0>,<3,0,0>,<3,0,9>,vr[i],tr[i],vect,D) ROTATE(<6,0,0>,<6,0,9>,<7,0,9>,vr[i],tr[i],vect,D) ROTATE(<6,0,0>,<7,0,0>,<7,0,9>,vr[i],tr[i],vect,D) ROTATE(<8,0,0>,<8,0,9>,<9,0,9>,vr[i],tr[i],vect,D) ROTATE(<8,0,0>,<9,0,0>,<9,0,9>,vr[i],tr[i],vect,D) // ROTATE(<1,0,3>,<2,0,3>,<2,0,4>,vr[i],tr[i],vect,D) ROTATE(<1,0,3>,<1,0,4>,<2,0,4>,vr[i],tr[i],vect,D) ROTATE(<1,0,5>,<2,0,5>,<2,0,6>,vr[i],tr[i],vect,D) ROTATE(<1,0,5>,<1,0,6>,<2,0,6>,vr[i],tr[i],vect,D) // ROTATE(<7,0,3>,<8,0,3>,<8,0,4>,vr[i],tr[i],vect,D) ROTATE(<7,0,3>,<7,0,4>,<8,0,4>,vr[i],tr[i],vect,D) ROTATE(<7,0,5>,<8,0,5>,<8,0,6>,vr[i],tr[i],vect,D) ROTATE(<7,0,5>,<7,0,6>,<8,0,6>,vr[i],tr[i],vect,D) // ROTATE(<3,0,1>,<3,0,2>,<4,0,2>,vr[i],tr[i],vect,D) ROTATE(<3,0,1>,<4,0,1>,<4,0,2>,vr[i],tr[i],vect,D) ROTATE(<5,0,1>,<5,0,2>,<6,0,2>,vr[i],tr[i],vect,D) ROTATE(<5,0,1>,<6,0,1>,<6,0,2>,vr[i],tr[i],vect,D) // ROTATE(<3,0,7>,<3,0,8>,<4,0,8>,vr[i],tr[i],vect,D) ROTATE(<3,0,7>,<4,0,7>,<4,0,8>,vr[i],tr[i],vect,D) ROTATE(<5,0,7>,<5,0,8>,<6,0,8>,vr[i],tr[i],vect,D) ROTATE(<5,0,7>,<6,0,7>,<6,0,8>,vr[i],tr[i],vect,D) #declare tc=tc+48; // #local i=i+1; #end #end /* Usage: mesh { SPONGE2( translate X, translate Y, translate Z, Denominator // Used for // calculating the // width, height and depth // of each box. ) } */ #macro SPONGE2(X,Y,Z,D) #if(Hollow) HOLLOW_SPONGE(,D) #else #local points=array[4] {0,2/D,6/D,8/D} #local F1=1/D; #local F3=3/D; #local F5=5/D; #local F7=7/D; #local F9=9/D; #if(Dust) #local i=0; #while (i<4) #local j=0; #while (j<4) BOX(X,points[i]+Y,points[j]+Z,F9,F1,F1,1,0,1) BOX(points[i]+X,Y,points[j]+Z,F1,F9,F1,0,1,1) BOX(points[j]+X,points[i]+Y,Z,F1,F1,F9,1,1,0) #local j=j+1; #end #local i=i+1; #end #end #local i=0; #while (i<4) #local co1=array[4] {F1,F7,F1,F7} #local co2=array[4] {F3,F3,F5,F5} #local p_x=points[i]+X; #local p_y=points[i]+Y; #local p_z=points[i]+Z; #local j=0; #while(j<4) BOX(co1[j]+X,p_y,co2[j]+Z,F1,F1,F1,1,0,1) BOX(co1[j]+X,co2[j]+Y,p_z,F1,F1,F1,1,0,1) BOX(p_x,co1[j]+Y,co2[j]+Z,F1,F1,F1,0,1,1) BOX(co2[j]+X,co1[j]+Y,p_z,F1,F1,F1,0,1,1) BOX(p_x,co2[j]+Y,co1[j]+Z,F1,F1,F1,1,1,0) BOX(co2[j]+X,p_y,co1[j]+Z,F1,F1,F1,1,1,0) #local j=j+1; #end #local i=i+1; #end #end #end #if(RW) #declare LIM3=1; #else #declare LIM3=2; #end #macro SPONGE3(Xt,Yt,Zt,DN) #local sp2=0; #local DN3=DN*3; #local X=0; #while (X<2) #local Y=0; #while (Y<2) #local Z=0; #while (Z