POV-Ray : Newsgroups : povray.advanced-users : Trace() and memory : Re: Trace() and memory Server Time
29 Jul 2024 14:16:26 EDT (-0400)
  Re: Trace() and memory  
From:
Date: 12 Dec 2001 07:37:47
Message: <rpje1uknmu0c8ip0530f6dfje5o8hbv0p8@4ax.com>
On Wed, 12 Dec 2001 12:55:37 +0100, Tim Nikias <Tim### [at] gmxde> wrote:

> I wasn't literary speaking about "spheres on planes". Take any object, and
> any environment. Use trace to place the object anywhere. Now, when I
> want to place the next object, it should also consider the new object I just
> placed. And this goes on and on, perhaps inside a loop?

you want something like this ?

#local Base=box{<-1,-1,-1><1,0,1> pigment{granite}}
#local Count=100;
#local Spheres=array[Count];
#local Counter=0;
#local rs=seed(0);
#local R=.1;
#while (Counter<Count)
  #local Found=no;
  #while (!Found)
    #local Start=2*<2*rand(rs)-1,rand(rs),2*rand(rs)-1>;
    #local Dir=<2*rand(rs)-1,rand(rs),2*rand(rs)-1>;
    #local Dir=vnormalize(Dir-Start);
    #local Norm=<0,0,0>;
    #local Intersection=trace(Base,Start,Dir,Norm);
    #if(vlength(Norm)>0)
      #local Center=Intersection+Norm*R;
      #if(Center.y>=R)
        #local Bad=no;
        #local Temp=0;
        #while (Temp<Counter)
          #if(vlength(Spheres[Temp]-Center)<2*R)
            #local Bad=yes;
          #end
          #local Temp=Temp+1;
        #end
        #if(!Bad)
          #local Found=yes;
          #local Spheres[Counter]=Center;
          #local Base=union{
            object{Base}
            sphere{
              Center
              R
              pigment{color rgb .5+.5*<rand(rs)rand(rs)rand(rs)>}
            }
          }
        #end
      #end
    #end
  #end
  #local Counter=Counter+1;
#end

object{Base no_shadow}
camera{
  location <2,2,-3>
  right x*image_width/image_height
  up y
  look_at <0,.5,0>
}
light_source{ y*100 color rgb 1}

ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)&_((x+y)*.7,z,.1)&_((x+y+2)*.7,z,.1)&_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35


Post a reply to this message

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