POV-Ray : Newsgroups : povray.animations : nice recursive macro for a group of spheres based animation Server Time: 20 Jun 2019 19:50:49 GMT
  nice recursive macro for a group of spheres based animation (Message 1 to 1 of 1)  
From: rodv92
Subject: nice recursive macro for a group of spheres based animation
Date: 30 Sep 2013 21:55:00
Message: <web.5249f232c8b9fe235d50475e0@news.povray.org>
Hello group, I discovered the power of recursive functions to create a complex
topology made only with spheres. enjoy !!

http://www.youtube.com/watch?v=e2-g8nUWMvs

here is the code snippet if you wanna play with it :


  #include "colors.inc"    // The include files contain
  #include "stones.inc"    // pre-defined scene elements
  #include "textures.inc"    // pre-defined scene elements
  #include "shapes.inc"
  #include "glass.inc"
  #include "metals.inc"



#macro
sphere_fac(rec_depth,number_of_spheres,scaling_factor,ix,iy,iz,tx,ty,tz,rotx,roty,rotz,cr,cg,cb)


#local lrec_depth = rec_depth*0.8;
#local lscaling_factor = scaling_factor*0.95;

#local lix = 20*cos(lrec_depth*0.1*pi) + ix/(lrec_depth+1);
#local liy = 20*cos(lrec_depth*0.1*pi) + iy/(lrec_depth+1);
#local liz = 20*cos(lrec_depth*0.1*pi) + iz/(lrec_depth+1);


#local ltx = (10*sin(lrec_depth*0.1*pi) + (tx+lix))/(lrec_depth+1);
#local lty = (10*sin(lrec_depth*0.1*pi) + (ty+liy))/(lrec_depth+1);
#local ltz = (10*sin(lrec_depth*0.1*pi) + (tz+liz))/(lrec_depth+1);


#local lrotx = 40*cos(lrec_depth*0.2*pi) + rotx + lix + ltx;
#local lroty = 30*cos(lrec_depth*0.2*pi) + roty + liy + lty;
#local lrotz = 20*cos(lrec_depth*0.2*pi) + rotz + liz + ltz;



#local lcr = 2*cos(lrec_depth*0.2*pi + cr);
#local lcg = 2*sin(lrec_depth*0.3*pi + cg);
#local lcb = 2*cos(lrec_depth*0.2*pi + cb);


sphere { <lix,liy,liz>, 1

         texture { pigment{ rgb< lcr, lcg, lcb>}
                   finish { phong 1 reflection{ 0.00 metallic 0.00} }
                 } // end of texture

          scale lscaling_factor  rotate <lrotx,lroty,lrotz>  translate
<ltx,lty,ltz>
       }  // end of sphere -----------------------------------



 #if (lrec_depth > 1)

sphere_fac(lrec_depth,1,lscaling_factor,lix,liy,liz,ltx,lty,ltz,lrotx,lroty,lrotz,lcr,lcg,lcb)
 #end


#end


// perspective (default) camera
camera {
  location  <0.0, 2.0, -5.0>*25*(1.5-clock)
  look_at   <0.0, 0.0,  0.0>
  right     x*image_width/image_height
}


  background{rgb 1}
// create a regular point light source
light_source {
  0*x                  // light's position (translated below)
  color rgb <1,1,1>    // light's color
  translate  <0.0, 2.0, -5.0>*20*(1.5-clock)
}


#declare A = -100;
#while(A <= 100)


#declare B = -100;
#while(B <= 100)


#declare C = -100;
#while(C <= 100)


sphere_fac(20*clock,1,0.8, C,B,C, A,A,C, C,B,B, A,B,C)


#declare C = C + 8;

#end

#declare B = B + 8;

#end

#declare A = A + 8;

#end


Post a reply to this message

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