|
|
this is the code used for the transparent rgb-cube in p.b.i Re: color cube
//rgb cube
#include "math.inc"
//variables
#declare dim = 11; //number of cubes per side
#declare d = 0.05; //thickness of cube-wall
#declare s = 1; //size of cube
#declare a = 0.5; //space between cubes
#declare T = 0.8; //transparency (1=transparent, 0 = solid)
global_settings { max_trace_level 20*dim }
//cam&light
camera { location (dim*s+(dim-1)*a)*<1.1,1.1,-1.1> look_at 0 }
light_source { <10000,15000,-8000>, rgb 1 }
#declare cubus = union {
difference {
box { 0.0,s }
/*box { d,s-d }
//holes for the tubes
cylinder { <0.5*s,0.5*s,0-0.1>,<0.5*s,0.5*s,s+0.1>, 0.1 }
cylinder { <0.5*s,0-0.1,0.5*s>,<0.5*s,s+0.1,0.5*s>, 0.1 }
cylinder { <0-0.1,0.5*s,0.5*s>,<s+0.1,0.5*s,0.5*s>, 0.1 }*/
}
//connecting tubes
difference { //1
cylinder { <s,0.5*s,0.5*s>,<s+a/2,0.5*s,0.5*s>,0.12 }
/*cylinder { <0-0.1,0.5*s,0.5*s>,<s+0.1+a/2,0.5*s,0.5*s>,0.1 }*/
}
difference { //2
cylinder { <0.5*s,0.5*s,0>,<0.5*s,0.5*s,0-a/2>,0.12 }
/*cylinder { <0.5*s,0.5*s,0+0.1>,<0.5*s,0.5*s,0-a/2-0.1>,0.1 }*/
}
difference { //3
cylinder { <0,0.5*s,0.5*s>,<0-a/2,0.5*s,0.5*s>,0.12 }
/*cylinder { <0+0.1,0.5*s,0.5*s>,<0-a/2-0.1,0.5*s,0.5*s>,0.1 }*/
}
difference { //4
cylinder { <0.5*s,0.5*s,s>,<0.5*s,0.5*s,s+a/2>,0.12 }
/*cylinder { <0.5*s,0.5*s,s-0.1>,<0.5*s,0.5*s,s+a/2+0.1>,0.1 }*/
}
difference { //5
cylinder { <0.5*s,s,0.5*s>,<0.5*s,s+a/2,0.5*s>,0.12 }
/*cylinder { <0.5*s,s-0.1,0.5*s>,<0.5*s,s+a/2+0.1,0.5*s>,0.1 }*/
}
difference { //6
cylinder { <0.5*s,0,0.5*s>,<0.5*s,0-a/2,0.5*s>,0.12 }
/*cylinder { <0.5*s,0+0.1,0.5*s>,<0.5*s,0-a/2-0.1,0.5*s>,0.1 }*/
}
}
#declare rgb_cube = union {
#declare X = 0; //x-coordinate of cube
#declare Xc = 0; //red-value of cube
#declare Y = 0; //y-coordinate of cube
#declare Yc = 0; //green-value of cube
#declare Z = 0; //z-coordinate of cube
#declare Zc = 0; //blue-value of cube
#while (X<dim)
#declare Y = 0;
#declare Yc = 0;
#declare Z = 0;
#declare Zc = 0;
#while (Y<dim)
#declare Z = 0;
#declare Zc = 0;
#while (Z<dim)
object {
cubus
translate <X*(a+s),Y*(a+s),Z*(a+s)>
pigment { rgbt <Xc,Yc,Zc,T> }
finish { ambient .5 }
}
#declare Zc = Zc+1/dim;
#declare Z = Z+1;
#end
#declare Yc = Yc+1/dim;
#declare Y = Y+1;
#end
#declare Xc = Xc+1/dim;
#declare X = X+1;
#end
}
object { rgb_cube translate -(dim*s+(dim-1)*a)/2*<1,1,1> rotate 90*y }
//animation
//path: white -> yellow -> blue -> red -> black -> violet -> out (well,
thats the idea...
#if (preview = 0)
#if (odd(dim)=1)
#declare cam_loc = spline {
linear_spline
#declare n = 0;
#while (n<dim+1)
n,
<(dim/2+0.5-n)*s+(dim/2+0.5-n)*a,(dim/2-0.5)*s+(dim/2-0.5)*a,-((dim/2-0.5)*s+(dim/2-0.5)*a)>,
//start in the cube right to the white one
#declare n = n+1;
#end
#declare m = 0;
#while (m<dim/2-1)
n,
<(dim/2+0.5-dim)*s+(dim/2+0.5-dim)*a,(dim/2-0.5)*s+(dim/2-0.5)*a,-((dim/2-0.5-m)*s+(dim/2-0.5-m)*a)>,
#declare m = m+1;
#declare n = n+1;
#end
#declare l = 0;
#while (l<dim/2)
n,
<(dim/2+0.5-dim+l)*s+(dim/2+0.5-dim+l)*a,(dim/2-0.5)*s+(dim/2-0.5)*a,-((dim/2-0.5-(dim/2-0.5))*s+(dim/2-0.5-(dim/2-0.5))*a)>,
#declare l = l+1;
#declare n = n+1;
#end
}
#declare cam_loo = spline {
linear_spline
#declare n = 0;
#while (n<dim)
n, <0,180,0>,
#declare n = n+1;
#end
n, <0,270,0>,
#declare n = n+1;
#declare m = 0;
#while (m<dim/2-1)
n, <0,270,0>,
#declare m = m+1;
#declare n = n+1;
#end
n, <0,360,0>,
//#declare n = n+1;
#declare l = 0;
#while (l<dim/2-1)
n, <0,360,0>,
#declare l = l+1;
#declare n = n+1;
#end
n, <0,360,-90>,
#debug concat(str(n,1,3)," ")
}
#end
#end
Post a reply to this message
|
|