|
|
"vinhphunguyen" <nvi### [at] gmailcom> wrote in message
news:web.4852425d5fabdd0ab979a58c0@news.povray.org...
> I just found one case the code does not work well. Imagine that, taking
> your
> simplified example, there is another layered sphere behind this one along
> z
> axis (so that the plane z = 0 does not cut it) and shifted some units
> along x
> axis. In this case, the slice image should not contain the second sphere.
>
> ... snip ...
> #declare grain1 = union{
> difference {
> sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
> sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> }
> ... snip ...
> #declare grain2 = union{
> difference {
> sphere{<2,0,1>, 0.3 pigment {color rgb <1,0,0>}}
> sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
> }
> ... snip ...
This is because you didn't incorporate the cube you mentioned in your first
posting, but you can do this as follows:
#declare grains = union{
object{grain1}
object{grain2}
}
// Add a concrete block around the grains,
// cutting holes where the grains occur.
#declare concreteblock = union{
difference {
box {-2,2 pigment {rgb 1}}
object{grains}
}
object{grains}
}
// Then cut away to expose the inside of the block
difference {
object {concreteblock}
plane {z,0}
cutaway_textures
}
>
> I switched from difference operation to intersection, then the second
> sphere
> disappeared but the first sphere showed only the outermost layer.
>
That sounds about right. Using 'intersection' in place of difference will
just give you the other half of whatever you do the difference/intersection
with. With the camera where it is, this would have given you the outside of
the first sphere and nothing of the second. With the changes above, an
intersection will give you the outside of the white box, unless you move the
camera to <0,0,3.5>, in which case you'll again see the cut surface, but
this time from the opposite side (so the other way round).
Another technique that may simplify this is to use an onion pattern with a
colour map to define each grain rather than actual concentric spheres. This
also enables you to do gradual colour transitions if you wish to.
#declare grain1 = sphere{<0,0,0>, 0.3
pigment {onion
color_map {
[0.0 color <0,0,1>]
[0.1 color <0,0,1>]
[0.1 color <0,1,0>]
[0.2 color <0,1,0>]
[0.2 color <1,0,0>]
[1.0 color <1,0,0>]
}
}
}
If you ever want two grains with the same colour pattern you can scale and
translate one you've already defined. For example:
#declare grain3 = object {grain1 scale 0.6 translate x}
Regards,
Chris B.
Post a reply to this message
|
|