|
|
// Persistence of Vision Ray Tracer Scene
// File: Celtic.pov
// Date: 15-Nov-2000
// Author: Mike Williams
// Generates "celtic knot" shapes
// --- Parameters ----
#declare R2=0.5; // thickness of tube (sensible values are 0.2 to 0.8)
#declare WW=14; // number of cells horizontally (must be even)
#declare HH=10; // number of cells vertically (must be even)
#declare Flaws=15; // number of flaws (zero gives a plain weave)
#declare SEED=1235; // random seed
// --- Declarations of components ---
#declare A = intersection
{ torus {1,R2 rotate x*90 translate <1,-1,0>}
box {-1,1}
scale 0.5
}
#declare B = object { A rotate z*270 }
#declare C = object { A rotate z*90 }
#declare D = object { A rotate z*180 }
#declare E = union { object {A} object {D} }
#declare F = union { object {B} object {C} }
#declare G1 =
intersection
{ torus {1,R2 translate <-1,0,0>}
plane {-x,1}
plane {x,-1 rotate y*30}
scale 0.5
translate z*-0.5
}
#declare G2 =
intersection
{ torus {1,R2 translate <0,0,1.7>}
plane {-x,1 rotate 30*y}
plane {x,1 rotate -30*y}
scale 0.5
translate z*-0.5
}
#declare G3 = union {object {G1} object {G2} object {G1 scale <-1,1,1>}}
#declare G = union {object {G3} object {G3 rotate <180,0,90>}}
#declare H = object {G rotate y*180}
// --- create the Celtic control array ---
#declare Celtic = array[WW][HH]
#declare Y=1;
#while (Y<HH-1)
#declare X=1;
#while (X<WW-1)
#declare XY = X+Y;
#if (int(XY/2)*2 = XY)
#declare Celtic[X][Y]=0;
#else
#declare Celtic[X][Y]=1;
#end
#declare X=X+1;
#end
#declare Y=Y+1;
#end
#declare R=seed(SEED);
#declare Flaw=0;
#while (Flaw < Flaws)
#declare Fx=int(rand(R)*(WW-2))+1;
#declare Fy=int(rand(R)*(HH-2))+1;
#declare Celtic[Fx][Fy] = 2;
#declare Celtic[WW-1-Fx][HH-1-Fy] = 2;
#declare Celtic[Fx][HH-1-Fy] = 3;
#declare Celtic[WW-1-Fx][Fy] = 3;
#declare Flaw = Flaw + 1;
#end
// --- Generate the Knot object ---
#declare Knot = union {
#declare X=1;
#while (X<WW-1)
object {A translate <X,0,0>}
object {B translate <X+1,0,0>}
object {C translate <X,-HH+1,0>}
object {D translate <X+1,-HH+1,0>}
#declare X=X+2;
#end
#declare Y=1;
#while (Y<HH-1)
object {A translate <0,-Y,0>}
object {C translate <0,-Y-1,0>}
object {B translate <WW-1,-Y,0>}
object {D translate <WW-1,-Y-1,0>}
#declare Y=Y+2;
#end
#declare Y=1;
#while (Y<HH-1)
#declare X=1;
#while (X<WW-1)
#if (Celtic[X][Y]=0)
object {G translate <X,-Y,0>}
#end
#if (Celtic[X][Y]=1)
object {H translate <X,-Y,0>}
#end
#if (Celtic[X][Y]=2)
object {E translate <X,-Y,0>}
#end
#if (Celtic[X][Y]=3)
object {F translate <X,-Y,0>}
#end
#declare X=X+1;
#end
#declare Y=Y+1;
#end
translate <-(WW-1)/2,(HH-1)/2,0>
}
// --- Environment ---
camera { location <0, 0, -11> look_at <0, 0, 0>}
sky_sphere { pigment {
gradient y
color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }
}
}
light_source {<-100,200,-100> colour rgb 1.5}
// --- Invoke the knot and texture it ---
object {Knot
pigment {rgb <1,1,.5>}
finish {
brilliance 1.5
ambient 0.1
metallic 1
specular 0.4
roughness 0.02
}
}
Post a reply to this message
|
|