POV-Ray : Newsgroups : povray.text.scene-files : 3D Truchet tile source code Server Time
28 Jul 2024 12:23:21 EDT (-0400)
  3D Truchet tile source code (Message 1 to 1 of 1)  
From: hall
Subject: 3D Truchet tile source code
Date: 12 Apr 2000 23:52:39
Message: <38f54487@news.povray.org>
// code by Quadhall, April, 2000
#version unofficial MegaPOV 0.4;

#declare n=
pigment
 {
  function(z)
  color_map
   {
    [0.000 color rgb <1,0,0>]
    [0.125 color rgb <1,1,0>]
    [0.250 color rgb <1,0,0>]
    [0.375 color rgb <1,1,0>]
    [0.500 color rgb <1,0,0>]
    [0.625 color rgb <1,1,0>]
    [0.750 color rgb <1,0,0>]
    [0.875 color rgb <1,1,0>]
    [1.000 color rgb <1,0,0>]
   }// end color_map
  warp
   {
    toroidal
    orientation <0,1,0>
    dist_exp 0
    major_radius 0.5
   }
 }// end pigment

#declare m=
texture


   pigment{n}
   finish{ambient .20}
 }//end texture

#declare one=sphere{0 .03}
#declare three=
union
 {
  #declare two=0;
  #while (two<360)
   object{one translate <.5,0,0> rotate<0,two,0>}
   #declare two=two+3.75;
  #end
  torus{0.5,0.003 translate <0,.04,0>  pigment{color rgb 1} finish{ambient
.5} }
  torus{0.5,0.003 translate <0,-.04,0> pigment{color rgb 1} finish{ambient
.5} }
  torus{0.460,0.003 pigment{color rgb 1} finish{ambient .5} }
  torus{0.540,0.003 pigment{color rgb 1} finish{ambient .5} }
 }

//this creates a toroidal object, major radius .5 centered at the origin
#declare pre_a=object{three texture{m}}



#declare a=object{pre_a}
#declare b=box{<0,1,0>,<1,-1,1> texture{m}}
#declare c=intersection{object{a}object{b}}
#declare d=object{c translate <-.5,0,-.5>}
#declare e=box{<0,.055,0>,<-.55,-.055,-.55> pigment{color rgb 1}}
#declare f=intersection{object{a}object{e} translate <.5,0,.5>}
#declare g=object{f rotate <-90,0,0>}
#declare h=object{f rotate <0,0,-90>}
//i is the tiling object-->there is a left-handed and a right handed version
//of the tiling object (didn't check to see if i is left or right).  To get
the
//other handed version, simply do a scale <-1,1,1>
#declare i=union{object{d}object{g}object{h}}


// the code below places copies of the cube_tile at the points of a cubic
lattice,
// and randomly rotates (in 90 degree increments) the copies in two
directions.
#declare seed1=seed(0);
#declare seed2=seed(256);

#declare j=0;
#while(j<6)
 #declare k=0;
 #while(k<6)
  #declare l=0;
  #while(l<6)
   #declare yrotation=(int(rand(seed1)*3.999))*90;
   #declare xrotation=(int(rand(seed2)*3.999))*90;
   object{i rotate y*yrotation rotate x*xrotation translate <j,k,l>}
   #declare l=l+1;
  #end
  #declare k=k+1;
 #end
 #declare j=j+1;
#end

fog {fog_type 1 distance 3 color rgb 0}

camera{location <0,0,0> look_at <1,1,1>}

light_source{ <0,0,-1> color rgb 1}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.