|
|
Tim Nikias wrote:
> I think it looks really nice,
Thanks! :)
> ever thought about making a bathtub with foam?
Foam would be nice, but I'm not sure how quick it would
be :-) Still, the macro doesn't seem to hang up the render
outside the bubble areas.. I think perhaps the right way
to do it might be to generate a bunch of positions and
radii which form a sort of skin over where the foam is
to be, perhaps one or two layers of bubbles, and then
put some texture beneath that (which won't really be
seen in detail anyhow, hopefully) in order to cut down
on the max_trace_level setting needed (because that
would get really high with large solid chunks of foam
made of all these transparent bubbles.)
It would be necessary to work up something to generate
the positions and radii appropriately - but that shouldn't
be too hard. One problem is that the macro (currently) fails
to construct the appropriate disc between two bubbles if the
center of one bubble falls inside the other.
Ryan Mooney wrote:
> have you or will you post the macro for public view... ???
I thought I would wait a bit until I fixed up some uglinesses,
but since that may take a while, and since I have no shame about
my bad pov-code, and since it's even possible if I post that it
someone else will make it nicer ... here it is!
As is, it requires version 3.5 (for conserve_energy in the
texture definition, and for a transform macro used at one
point, but neither of these are major problems to change.)
You'll notice I have two pretty much identical macros bubchop
and bubchop2. They started off different ...
Also, I have been too lazy to find if there's a function which
will return the length of an array, so I include that as a
parameter, which kind of smells funny, IMHO, but never mind ;-)
It expects an array definition like this
#declare TheBubbles = array[12] {
-2.5, 1.5, 0, 3.2
2.5, 1.5, 0, 3.5
0, -1, 0, 3.4
}
where each four elements are center.x, center.y, center.z, radius,
and then you call it with
bubs(TheBubbles,12)
To change the texture, just edit or re-declare the BubTex definition.
8<-----C-U-T---H-E-R-E-----
#include "shapes.inc"
#include "transforms.inc"
#macro bubchop(p1,r1,p2,r2)
#local vl = vlength(p2 - p1);
#local iptscale = abs((r1^2 - r2^2 + vl^2)/(2*vl));
#local ipt = vnormalize(p2 - p1)* iptscale;
cylinder {
(r2+r1)*vnormalize(ipt),0,sqrt(abs(r1^2-iptscale^2))
translate p1 + 999*ipt/1000
}
#end
#macro bubchop2(p1,r1,p2,r2)
#local vl = vlength(p2 - p1);
#local iptscale = abs((r1^2 - r2^2 + vl^2)/(2*vl));
#local ipt = vnormalize(p2 - p1)* iptscale;
cylinder {
(r2+r1)*vnormalize(ipt),0,abs(r1^2-iptscale^2)
translate p1 + 999/1000*ipt
}
#end
#macro bubring(p1,r1,p2,r2)
#local vl = vlength(p2 - p1);
#local iptscale = abs((r1^2 - r2^2 + vl^2)/(2*vl));
#local ipt = vnormalize(p2 - p1)* iptscale;
object {
torus {
sqrt(abs(r1^2-iptscale^2)),
sqrt(abs(r1^2-iptscale^2))/55
Point_At_Trans(ipt)
translate p1 + ipt
}
}
#end
#macro bubdiff2(arr,arrlen,bubndx)
#local ndx = 0;
#while (ndx < arrlen-3)
#if (ndx!=bubndx)
//#if
(vlength(<arr[ndx],arr[ndx+1],arr[ndx+2]>-<arr[bubndx],arr[bubndx+1],arr[bubndx+2] >)
> arr[bubndx+3])
#if
(vlength(<arr[ndx],arr[ndx+1],arr[ndx+2]>-<arr[bubndx],arr[bubndx+1],arr[bubndx+2] >)
< (arr[ndx+3]+arr[bubndx+3]))
// #debug "\n2: adding one..."
#local empty=0;
bubchop2(
< arr[bubndx],arr[bubndx+1],arr[bubndx+2] >,
arr[bubndx+3],
< arr[ndx],arr[ndx+1],arr[ndx+2] >,
arr[ndx+3]
)
#end
#end
#local ndx = ndx + 4;
#end
#end
#macro bubrings(arr,arrlen,bubndx)
#local ndx = bubndx+4;
#local empty = 1;
#while (ndx < arrlen-3)
#if (ndx!=bubndx)
#if
(vlength(<arr[ndx],arr[ndx+1],arr[ndx+2]>-<arr[bubndx],arr[bubndx+1],arr[bubndx+2] >)
< (arr[ndx+3]+arr[bubndx+3]))
// #debug "\nringing one..."
#local empty=0;
bubring(
< arr[bubndx],arr[bubndx+1],arr[bubndx+2] >,
arr[bubndx+3],
< arr[ndx],arr[ndx+1],arr[ndx+2] >,
arr[ndx+3]
)
#end
#end
#local ndx = ndx + 4;
#end
#if (empty)
sphere {-10000,0.00001}
#end
#end
#macro bubdiff(arr,arrlen,bubndx)
difference {
sphere {
<arr[bubndx],arr[bubndx+1],arr[bubndx+2]>, arr[bubndx+3]*999/1000
}
#local ndx = 0;
#local empty = 1;
#while (ndx < arrlen-3)
#if (ndx!=bubndx)
#if
(vlength(<arr[ndx],arr[ndx+1],arr[ndx+2]>-<arr[bubndx],arr[bubndx+1],arr[bubndx+2] >)
< (arr[ndx+3]+arr[bubndx+3]))
// #debug "\nadding one..."
#local empty=0;
bubchop(
< arr[bubndx],arr[bubndx+1],arr[bubndx+2] >,
arr[bubndx+3],
< arr[ndx],arr[ndx+1],arr[ndx+2] >,
arr[ndx+3]
)
#end
#end
#local ndx = ndx + 4;
#end
#if (empty)
sphere {-10000,0.00001}
#end
}
#end
#macro bubs(arr,arrlen)
#local ndx=0;
merge {
#while (ndx < arrlen-3)
difference {
merge {
sphere {
<arr[ndx],arr[ndx+1],arr[ndx+2]> arr[ndx+3]
}
bubrings(arr,arrlen,ndx)
}
bubdiff(arr,arrlen,ndx)
bubdiff2(arr,arrlen,ndx)
bounded_by {
sphere {
<arr[ndx],arr[ndx+1],arr[ndx+2]> arr[ndx+3]*1000/999
}
}
}
#local ndx = ndx+4;
#end
}
#end
#declare BubTex = texture {
pigment {
bozo
octaves 3
turbulence 0.6
color_map {
[0.25 rgbft<1,0.7,0.9,0.13,0.83>]
[0.3 rgbft<0.75,0.95,1,0.1,0.89>]
[0.65 rgbft<0.69,1,0.96,0.01,0.99>]
[0.9 rgbft<0.9,0.7,0.98,0.09,0.89>]
}
scale 5.6
}
finish { ambient 0 diffuse 0 specular 0.7 roughness 0.001
reflection { 0.2,0.285 fresnel on }
irid {0.2 thickness 0.43 turbulence 0.15 }
conserve_energy
}
}
8<-----C-U-T---H-E-R-E-----
As I've implied, it's really not finished yet, and there are
no doubt many fixes and improvements to be made... which anyone
is welcome to do (so long as they post them back to
news.povray.org! ;-)
- Pete.
Post a reply to this message
|
|