| 
  | 
For creating a voronoi cell we need nearest neighbours. The simplest way 
to create those is with creating random points on a sphere. For 
constructing a cell that's all that's needed.
top left: intersection of planes
rop right: intersection of isosurface planes
bottom left: noisy isosurface version
bottom right: blob
ingo
---%<------%<------%<---
#include "transforms.inc"
camera {
  perspective angle 11
  location  <0,0,-25>
  look_at   <0,0,  0>
}
light_source{< -300, 3000,   0> rgb <0.3,0.3,0.2>}
light_source{< 3000,  300,-500> rgb .5}
light_source{<  300,-3000,   0> rgb <0.2,0.2,0.4>}
#declare Point = <0,0,0>;
#declare Stream = seed(12);
#declare N=33;
#declare arrNeighbours = array[N];
#for(I,0,N-1)
  #declare arrNeighbours[I] = VRand_On_Sphere(Stream)/2;
#end
intersection{
  #for(I,0,N-1)
    #declare Neighbour=arrNeighbours[I];
    #declare Distance = vlength(Neighbour);
    #declare Normal = vnormalize(Neighbour);
    plane{Normal, Distance pigment{rgb 1}}
  #end 
  translate <-1,1,0>
}
#declare fnNeighbours = array[N];
#for(I,0,N-1)
  #declare Neighbour = arrNeighbours[I];
  #declare Distance = vlength(Neighbour);
  #declare Normal = vnormalize(Neighbour);
  #declare nX = Normal.x;
  #declare nY = Normal.y;
  #declare nZ = Normal.z;
  #declare fnNeighbours[I]=function{(nX*x+nY*y+nZ*z)-Distance};
#end
#declare fnIntersection = function{
  max(
    #for(I,0,N-1,1)
      #if(I>0)
        , fnNeighbours[I](x,y,z)
      #else
        fnNeighbours[I](x,y,z)
      #end
    #end
  )
}
isosurface {
  function{
    fnIntersection(x,y,z)
  }
  contained_by {sphere{0,1.5}}
  max_gradient 2
  pigment{rgb 1}
  translate <1,1,0>
}
isosurface {
  function{
    fnIntersection(x,y,z)-(f_noise3d(x*10, y*10, z*10)*0.1)
  }
  contained_by {sphere{0,1.5}}
  max_gradient 2
  pigment{rgb 1}
  translate <-1,-1,0>
}
blob{
  threshold .40
  sphere{Point,1,1}
  #for(I,0,N-1)
    #declare Neighbour = arrNeighbours[I];
    #declare Distance = vlength(Neighbour);
    #declare Normal = vnormalize(Neighbour);
    sphere{0,1,-0.1 scale <1,0.1,1> Point_At_Trans(Normal) translate 
Normal*Distance}    
  #end
  pigment{rgb 1}
  translate<1,-1,0>
}
#for(I,0,N-1,1)
  sphere{arrNeighbours[I],0.01 pigment{rgb x} translate<-1, 1,0>}
  sphere{arrNeighbours[I],0.01 pigment{rgb x} translate< 1,-1,0>}
  sphere{arrNeighbours[I],0.01 pigment{rgb x} translate< 1, 1,0>}
#end
 Post a reply to this message 
 
Attachments: 
Download 'voro.png' (93 KB)
 
  
Preview of image 'voro.png'
   
   
 | 
  |