POV-Ray : Newsgroups : povray.newusers : How to get preserve color through an intersection call? : How to get preserve color through an intersection call? Server Time
4 Jul 2024 14:20:09 EDT (-0400)
  How to get preserve color through an intersection call?  
From: Brad
Date: 3 Oct 2010 03:45:00
Message: <web.4ca833709cb34848881e51860@news.povray.org>
Hi, I've been playing around with POVRAY tutorials the past day and a half and
really enjoying the program. Today I decided I would try to make a "disco ball"
formed by a spherical shell with holes in it, each hole being filled with a
transparent material of varying color.  However, I'm having trouble getting it
to work with the variable color. Let me show you my code to show you what I
mean:

global_settings {max_trace_level 60}

#declare shell = difference{
sphere{<0,0,0> 6}
sphere{<0,0,0> 5}}

light_source{<100,0,0> color rgb <1,1,1>}

light_source{<0,0,0> color rgb <1,1,1>}

camera{location <10,1,1> look_at<0,0,0>}



// just a bunch of cylinders uniformly distributed on a sphere with 30 degrees
// separation in the theta/phi angular coordinates

#declare bunch_of_cylinders= union{cylinder {<0,0,0>,< 0.0 , 0.0 , 10.0 >0.5 tex
ture { pigment { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 5.0 , 0.0 , 8.66025403784 >0.5 texture { pigment { color rgb
 < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 8.66025403784 , 0.0 , 5.0 >0.5 texture { pigment { color rgb
 < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 10.0 , 0.0 , 6.12303176911e-16 >0.5 texture { pigment { colo
r rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 8.66025403784 , 0.0 , -5.0 >0.5 texture { pigment { color rg
b < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 5.0 , 0.0 , -8.66025403784 >0.5 texture { pigment { color rg
b < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 5.66549845232e-15 , 0.0 , -10.0 >0.5 texture { pigment { col
or rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 0.0 , 0.0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 1
, 0 >}}}
cylinder {<0,0,0>,< 4.33012701892 , 2.5 , 8.66025403784 >0.5 texture { pigment {
 color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 7.5 , 4.33012701892 , 5.0 >0.5 texture { pigment { color rgb
 < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 8.66025403784 , 5.0 , 6.12303176911e-16 >0.5 texture { pigme
nt { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 7.5 , 4.33012701892 , -5.0 >0.5 texture { pigment { color rg
b < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 4.33012701892 , 2.5 , -8.66025403784 >0.5 texture { pigment
{ color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 4.90646558481e-15 , 2.83274922616e-15 , -10.0 >0.5 texture {
 pigment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 0.0 , 0.0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 0
, 1 >}}}
cylinder {<0,0,0>,< 2.5 , 4.33012701892 , 8.66025403784 >0.5 texture { pigment {
 color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 4.33012701892 , 7.5 , 5.0 >0.5 texture { pigment { color rgb
 < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 5.0 , 8.66025403784 , 6.12303176911e-16 >0.5 texture { pigme
nt { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 4.33012701892 , 7.5 , -5.0 >0.5 texture { pigment { color rg
b < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 2.5 , 4.33012701892 , -8.66025403784 >0.5 texture { pigment
{ color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 2.83274922616e-15 , 4.90646558481e-15 , -10.0 >0.5 texture {
 pigment { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 0.0 , 0.0 , 10.0 >0.5 texture { pigment { color rgb < 1 , 0
, 0 >}}}
cylinder {<0,0,0>,< 3.06151588456e-16 , 5.0 , 8.66025403784 >0.5 texture { pigme
nt { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 5.30270106023e-16 , 8.66025403784 , 5.0 >0.5 texture { pigme
nt { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 6.12303176911e-16 , 10.0 , 6.12303176911e-16 >0.5 texture {
pigment { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 5.30270106023e-16 , 8.66025403784 , -5.0 >0.5 texture { pigm
ent { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 3.06151588456e-16 , 5.0 , -8.66025403784 >0.5 texture { pigm
ent { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 3.46900270114e-31 , 5.66549845232e-15 , -10.0 >0.5 texture {
 pigment { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -0 , 0.0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 1 ,
 0 >}}}
cylinder {<0,0,0>,< -2.5 , 4.33012701892 , 8.66025403784 >0.5 texture { pigment
{ color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -4.33012701892 , 7.5 , 5.0 >0.5 texture { pigment { color rg
b < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -5.0 , 8.66025403784 , 6.12303176911e-16 >0.5 texture { pigm
ent { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -4.33012701892 , 7.5 , -5.0 >0.5 texture { pigment { color r
gb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -2.5 , 4.33012701892 , -8.66025403784 >0.5 texture { pigment
 { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -2.83274922616e-15 , 4.90646558481e-15 , -10.0 >0.5 texture
{ pigment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -0 , 0.0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 0 ,
 1 >}}}
cylinder {<0,0,0>,< -4.33012701892 , 2.5 , 8.66025403784 >0.5 texture { pigment
{ color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -7.5 , 4.33012701892 , 5.0 >0.5 texture { pigment { color rg
b < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -8.66025403784 , 5.0 , 6.12303176911e-16 >0.5 texture { pigm
ent { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -7.5 , 4.33012701892 , -5.0 >0.5 texture { pigment { color r
gb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -4.33012701892 , 2.5 , -8.66025403784 >0.5 texture { pigment
 { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -4.90646558481e-15 , 2.83274922616e-15 , -10.0 >0.5 texture
{ pigment { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -0 , 0.0 , 10.0 >0.5 texture { pigment { color rgb < 1 , 0 ,
 0 >}}}
cylinder {<0,0,0>,< -5.0 , 2.83274922616e-15 , 8.66025403784 >0.5 texture { pigm
ent { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -8.66025403784 , 4.90646558481e-15 , 5.0 >0.5 texture { pigm
ent { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -10.0 , 5.66549845232e-15 , 6.12303176911e-16 >0.5 texture {
 pigment { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -8.66025403784 , 4.90646558481e-15 , -5.0 >0.5 texture { pig
ment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -5.0 , 2.83274922616e-15 , -8.66025403784 >0.5 texture { pig
ment { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -5.66549845232e-15 , 3.20978727133e-30 , -10.0 >0.5 texture
{ pigment { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -0 , -0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 1 ,
0 >}}}
cylinder {<0,0,0>,< -4.33012701892 , -2.5 , 8.66025403784 >0.5 texture { pigment
 { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -7.5 , -4.33012701892 , 5.0 >0.5 texture { pigment { color r
gb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -8.66025403784 , -5.0 , 6.12303176911e-16 >0.5 texture { pig
ment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -7.5 , -4.33012701892 , -5.0 >0.5 texture { pigment { color
rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -4.33012701892 , -2.5 , -8.66025403784 >0.5 texture { pigmen
t { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -4.90646558481e-15 , -2.83274922616e-15 , -10.0 >0.5 texture
 { pigment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -0 , -0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 0 ,
1 >}}}
cylinder {<0,0,0>,< -2.5 , -4.33012701892 , 8.66025403784 >0.5 texture { pigment
 { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -4.33012701892 , -7.5 , 5.0 >0.5 texture { pigment { color r
gb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -5.0 , -8.66025403784 , 6.12303176911e-16 >0.5 texture { pig
ment { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -4.33012701892 , -7.5 , -5.0 >0.5 texture { pigment { color
rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -2.5 , -4.33012701892 , -8.66025403784 >0.5 texture { pigmen
t { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -2.83274922616e-15 , -4.90646558481e-15 , -10.0 >0.5 texture
 { pigment { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -0 , -0 , 10.0 >0.5 texture { pigment { color rgb < 1 , 0 ,
0 >}}}
cylinder {<0,0,0>,< -9.18454765367e-16 , -5.0 , 8.66025403784 >0.5 texture { pig
ment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -1.59081031807e-15 , -8.66025403784 , 5.0 >0.5 texture { pig
ment { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -1.83690953073e-15 , -10.0 , 6.12303176911e-16 >0.5 texture
{ pigment { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< -1.59081031807e-15 , -8.66025403784 , -5.0 >0.5 texture { pi
gment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< -9.18454765367e-16 , -5.0 , -8.66025403784 >0.5 texture { pi
gment { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< -1.04070081034e-30 , -5.66549845232e-15 , -10.0 >0.5 texture
 { pigment { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 0.0 , -0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 1 ,
 0 >}}}
cylinder {<0,0,0>,< 2.5 , -4.33012701892 , 8.66025403784 >0.5 texture { pigment
{ color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 4.33012701892 , -7.5 , 5.0 >0.5 texture { pigment { color rg
b < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 5.0 , -8.66025403784 , 6.12303176911e-16 >0.5 texture { pigm
ent { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 4.33012701892 , -7.5 , -5.0 >0.5 texture { pigment { color r
gb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 2.5 , -4.33012701892 , -8.66025403784 >0.5 texture { pigment
 { color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 2.83274922616e-15 , -4.90646558481e-15 , -10.0 >0.5 texture
{ pigment { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 0.0 , -0 , 10.0 >0.5 texture { pigment { color rgb < 0 , 0 ,
 1 >}}}
cylinder {<0,0,0>,< 4.33012701892 , -2.5 , 8.66025403784 >0.5 texture { pigment
{ color rgb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 7.5 , -4.33012701892 , 5.0 >0.5 texture { pigment { color rg
b < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 8.66025403784 , -5.0 , 6.12303176911e-16 >0.5 texture { pigm
ent { color rgb < 0 , 0 , 1 >}}}
cylinder {<0,0,0>,< 7.5 , -4.33012701892 , -5.0 >0.5 texture { pigment { color r
gb < 1 , 0 , 0 >}}}
cylinder {<0,0,0>,< 4.33012701892 , -2.5 , -8.66025403784 >0.5 texture { pigment
 { color rgb < 0 , 1 , 0 >}}}
cylinder {<0,0,0>,< 4.90646558481e-15 , -2.83274922616e-15 , -10.0 >0.5 texture
{ pigment { color rgb < 0 , 0 , 1 >}}}
}


//object{bunch_of_cylinders}


// this is how I generate the shape of the material that will fill the holes

#declare cutouts =
intersection{
object{shell}
object{bunch_of_cylinders}
}

// this is how i generate a spherical shell with holes in it

#declare shell_with_cylindercutouts = difference{
object{shell}
object{bunch_of_cylinders}
}

// and this is putting the spherical shell with holes in it with the filled
//holes

union{
object{shell_with_cylindercutouts texture {pigment{color rgb<0,0,0>}}}
object{cutouts}}


The problem with the above code is the last line. POVRAY doesn't like that
"cutouts" doesn't have a color. But of course I want cutouts to have the color
of "bunch_of_cylinders" from which it was built. From my definition of cutouts I
don't specify any color, but I imagine there's a way for me to choose which
color from the intersection gets picked up by the defined object?

I hope that I'm making sense. I appreciate any help I can get!

Thanks.
Brad


Post a reply to this message

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