POV-Ray : Newsgroups : povray.binaries.images : Ball of Random Boxes : Re: Ball of Random Boxes Server Time
7 Aug 2024 05:15:06 EDT (-0400)
  Re: Ball of Random Boxes  
From: Mark Birch
Date: 24 May 2006 23:05:01
Message: <web.44751e1ca72e66f44daddc090@news.povray.org>
"Janet" <par### [at] attnet> wrote:
> Well, its pretty much what the subject line says. The code can be found here
> http://www.deviantart.com/view/33552164/  It can be modified for the number
> of boxes (n) and the box sizes and size variance too. Also just wanted to
> say all the greeble stuff looks so fun!
> Janet

Nice image & great colours!
But could you have found a harder way to code it?
I've never used a matrix transformation.  I don't know how it works.

This code will do the same thing, just put the box in a good starting
position and let 'rotate' do all the work...

#version 3.6;
// --------------------------------------------------------------
#global_settings{
  assumed_gamma 1.0
  max_trace_level 5
  radiosity{count 35 error_bound 0.1}
}
// --------------------------------------------------------------
#macro RandLH(L,H)
  (rand(R0)*(H-L)+L)
#end
// --------------------------------------------------------------
#declare R0 = seed(1); // random seed
#declare SR = 10; // sphere radius
#declare Bmin = 0.3; // minimum box scale
#declare Bmax = 1.0; // maximum box scale
// --------------------------------------------------------------
union{
  #declare num = 3500;
  #local ca = 0;
  #while(ca<num)
    //box{-0.5, 0.5
    superellipsoid{<0.2, 0.2> scale 0.5
      scale<RandLH(Bmin, Bmax), RandLH(Bmin, Bmax), RandLH(Bmin, Bmax)>
      translate SR*y
      rotate<RandLH(0,180), RandLH(0,360), 0>
    }
    #local ca = ca+1;
  #end
  texture{pigment{color rgb 1} finish{ambient 0 diffuse 1}}
}
// --------------------------------------------------------------
light_source{<-2, 2, 1>*1000 color rgb <1.0, 1.0, 0.5>*2}
light_source{<0, 0, 0> color rgb <0.2, 0.5, 0.5>*2}
camera{
  perspective
  location<0, 0, -50>
  up y*(image_height/image_width)
  right x
  sky y
  look_at <0, 0, 0>
  angle 40
}
// -------------------------------------------------- end of file


Post a reply to this message

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