POV-Ray : Newsgroups : povray.newusers : repeat an object with different scaling and position : Re: repeat an object with different scaling and position Server Time
29 Jul 2024 00:22:56 EDT (-0400)
  Re: repeat an object with different scaling and position  
From: Nikolaj K  Holm
Date: 15 Mar 2007 09:44:02
Message: <45f95bb2$1@news.povray.org>
"Christian Froeschlin" <chr### [at] chrfrde> skrev i en meddelelse 
news:45f8515a$1@news.povray.org...
> Nikolaj K. Holm wrote:
>
>> I'm quite new in povray, so I tried to search the list for this but 
>> without any luck. Here we go..
>>
>> I have an object - a sphere - which I want to have repeated at different 
>> sizes and at different positions to simulate bubbles in water. I got the 
>> water and a single bubble looking the way I want but is there a simpler 
>> way to repeat this object making the scale and position changing at 
>> random?
>
> Actually, your search could have turned up my recent
> sparkling water experiments:
>
>
http://news.povray.org/povray.binaries.images/message/%3C45d0d486%40news.povray.org%3E/#%3C45d0d486%40news.povray.org%3E
>
> Here is a snippet of SDL to show how I generated the bubble object
> which is to be subtracted from the liquid). Note that all bubbles
> form one blob object, which renders a lot faster but is not really
> perceptibly different from using individual bubbles.
>
> #declare GLASS_RADIUS   = 0.70;
> #declare WATER_LEVEL    = 2.80;
> #declare BUBBLE_COUNT   = 600;
> #declare BUBBLE_RADIUS  = 0.03;
>
> #declare R = seed(42);
>
> #declare BUBBLE_SHAPE = blob
> {
>   #local i = 0;
>   #while (i < BUBBLE_COUNT)
>     #local phi = 2*pi*rand(R);
>     #local d   = rand(R) * GLASS_RADIUS;
>     #if (d > GLASS_RADIUS)
>       #local d = GLASS_RADIUS; /* 50% of bubbles at rim */
>     #end
>     #local h   = rand(R) * WATER_LEVEL;
>     #local r   = 0.5 + 0.5 * rand(R);
>     #local r   = r * r * BUBBLE_RADIUS; /* More small bubbles */
>
>     sphere {d*<cos(phi),0,sin(phi)> + h*y,r,1}
>
>     #local i = i + 1;
>   #end
>   threshold 0.6
> }

Thanks a lot - don't know why it didn't came up in my search. Guess it 
depends on what you type in as search terms ;-)
Anyway - it works fine, so I'm one happy little ray-tracer now :o)


Post a reply to this message

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