POV-Ray : Newsgroups : povray.text.scene-files : Sphere made of Cubes : Re: Sphere made of Cubes Server Time
1 Jul 2024 02:48:21 EDT (-0400)
  Re: Sphere made of Cubes  
From: Pandora
Date: 6 Aug 2002 21:10:07
Message: <3d50736f@news.povray.org>
As all the cubes in your sphere have the same pigment and finish, you can
wrap the whole object in a union {...} and apply the pigment and finish to
that. See below :

// object

#declare r = seed(1);
#declare r2 = seed(2);

union {
 #declare zloop = -20;
 #while (zloop < 21)
   #declare yloop = -20;
   #while (yloop < 21)
     #declare xloop = -20;
     #while (xloop < 21)
      #declare s = cos(abs(xloop)/20) + cos(abs(yloop)/20) +
 cos(abs(zloop)/20);
       #if ((s > 2.54) & (s < 2.58))
         box {
           -0.45, 0.45
           rotate <rand(r2)*90, rand(r2)*90, rand(r2)*90>
           translate <xloop, yloop + 21, zloop>
         }
       #end
       #declare xloop = xloop + 1;
     #end
     #declare yloop = yloop + 1;
   #end
   #declare zloop = zloop + 1;
 #end
 pigment {
  color White
 }
 finish {
  specular 1
  roughness 1/200
  reflection 1/4
 }
}

Of course, if you, subsequently, want to apply a different pigment and
finish to each cube, your code is superior...

--
Pandora/Scott Hill/[::O:M:C::]Scorpion
Software Engineer.
http://www.pandora-software.com


Post a reply to this message

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