POV-Ray : Newsgroups : povray.newusers : #declare/Object coloring question Server Time
26 Nov 2024 23:42:09 EST (-0500)
  #declare/Object coloring question (Message 1 to 7 of 7)  
From: Brent G
Subject: #declare/Object coloring question
Date: 17 Sep 2003 14:54:17
Message: <3f68add9$1@news.povray.org>
Here's what I have:
//start
#declare MyTorus = union {
         #while (I<N)
                 torus {2,0.1 rotate <90,0,0> rotate<0, I*360/N,0>}
                 #declare I=I+1;
         #end
         light_source{<0,1,1> rgb <1,0.75,0>}
         texture {
                 pigment {
                         color rgb <0.8,0.8,1.0>
                 }
                 finish{
                         diffuse 0.3
                         ambient 0.0
                         specular 0.6
                         reflection {
                                 0.8
                                 metallic
                         }
                         conserve_energy
                 }
         }
}

object{ MyTorus scale<.5,.5,.5> translate<0,1.25,0> }
//end


Is there anyway to chage the MyTorus (yes almost directly from the 
examples :)) to allow me to specify what color I want the lightsource in 
the object declaration?


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: #declare/Object coloring question
Date: 17 Sep 2003 15:09:37
Message: <3f68b171@news.povray.org>
I'm not quiet sure what you're after. The rgb in the
lightsource-brackets describes the Red, Green
and Blue componentes of the lightsource's color.
rgb <1,1,1> is white, rgb<0,0,0> is black.
The rgb in in the pigment-brackets belongs to
all torii, so changing that will change the color
of the torii.

Aside of that, it might be better to take the lightsource
out of the union and place it into the scene by itself,
unless you're after something specific.

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de


> Here's what I have:
> //start
> #declare MyTorus = union {
>          #while (I<N)
>                  torus {2,0.1 rotate <90,0,0> rotate<0, I*360/N,0>}
>                  #declare I=I+1;
>          #end
>          light_source{<0,1,1> rgb <1,0.75,0>}
>          texture {
>                  pigment {
>                          color rgb <0.8,0.8,1.0>
>                  }
>                  finish{
>                          diffuse 0.3
>                          ambient 0.0
>                          specular 0.6
>                          reflection {
>                                  0.8
>                                  metallic
>                          }
>                          conserve_energy
>                  }
>          }
> }
>
> object{ MyTorus scale<.5,.5,.5> translate<0,1.25,0> }
> //end
>
>
> Is there anyway to chage the MyTorus (yes almost directly from the
> examples :)) to allow me to specify what color I want the lightsource in
> the object declaration?
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.518 / Virus Database: 316 - Release Date: 11.09.2003


Post a reply to this message

From: Brent G
Subject: Re: #declare/Object coloring question
Date: 17 Sep 2003 15:13:31
Message: <3f68b25b$1@news.povray.org>
Tim Nikias v2.0 wrote:

> I'm not quiet sure what you're after. The rgb in the
> lightsource-brackets describes the Red, Green
> and Blue componentes of the lightsource's color.
> rgb <1,1,1> is white, rgb<0,0,0> is black.
> The rgb in in the pigment-brackets belongs to
> all torii, so changing that will change the color
> of the torii.
> 
> Aside of that, it might be better to take the lightsource
> out of the union and place it into the scene by itself,
> unless you're after something specific.
> 

What I was going for is that instead of having to put 50 copies of that 
in my scene, I could write it once, then use object to make the copies. 
   The particular thing I was going after was a different color 
lightsource in the middle of each torus. so I could do like:

object{ MyTorus scale<.5,.5,.5> translate<4,1.25,0> Blue }
object{ MyTorus scale<.5,.5,.5> translate<0,1.25,0> Red }
object{ MyTorus scale<.5,.5,.5> translate<-4,1.25,0> Orange}

etc, so that one would have a red lightsource, one blue, and then orange


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: #declare/Object coloring question
Date: 17 Sep 2003 15:17:52
Message: <3f68b360$1@news.povray.org>
Hm. Then I'd make it a macro:

#macro MyTorus_Macro(Light_Color)
#declare MyTorus=[...]
[In the lightsource, put "rgb Light_Color"]
object{MyTorus}
#end

MyTorus_Macro(Blue)
MyTorus_Macro(Orange)

If you'd want to move it around, you can just add
another parameter to the macor:

#macro MyTorus_Macro(Light_Color,Position)
#declare MyTorus=[...]
object{MyTorus translate Position}
#end

Regards,
Tim
-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: no_lights (@) digitaltwilight.de


>
> > I'm not quiet sure what you're after. The rgb in the
> > lightsource-brackets describes the Red, Green
> > and Blue componentes of the lightsource's color.
> > rgb <1,1,1> is white, rgb<0,0,0> is black.
> > The rgb in in the pigment-brackets belongs to
> > all torii, so changing that will change the color
> > of the torii.
> >
> > Aside of that, it might be better to take the lightsource
> > out of the union and place it into the scene by itself,
> > unless you're after something specific.
> >
>
> What I was going for is that instead of having to put 50 copies of that
> in my scene, I could write it once, then use object to make the copies.
>    The particular thing I was going after was a different color
> lightsource in the middle of each torus. so I could do like:
>
> object{ MyTorus scale<.5,.5,.5> translate<4,1.25,0> Blue }
> object{ MyTorus scale<.5,.5,.5> translate<0,1.25,0> Red }
> object{ MyTorus scale<.5,.5,.5> translate<-4,1.25,0> Orange}
>
> etc, so that one would have a red lightsource, one blue, and then orange
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.518 / Virus Database: 316 - Release Date: 11.09.2003


Post a reply to this message

From: Brent G
Subject: Re: #declare/Object coloring question
Date: 17 Sep 2003 15:46:51
Message: <3f68ba2b$1@news.povray.org>
Tim Nikias v2.0 wrote:

> Hm. Then I'd make it a macro:
> 
> #macro MyTorus_Macro(Light_Color)
> #declare MyTorus=[...]
> [In the lightsource, put "rgb Light_Color"]
> object{MyTorus}
> #end
> 
> MyTorus_Macro(Blue)
> MyTorus_Macro(Orange)
> 
> If you'd want to move it around, you can just add
> another parameter to the macor:
> 
> #macro MyTorus_Macro(Light_Color,Position)
> #declare MyTorus=[...]
> object{MyTorus translate Position}
> #end
> 
> Regards,
> Tim

Ah, thanks, that works wonderfully :) (yay my (with some help) macro)


Post a reply to this message

From: Brent G
Subject: The macro itself :)
Date: 18 Sep 2003 15:11:15
Message: <3f6a0353@news.povray.org>
#macro MyTorus_Macro(Light_Color,Position)
#declare I=0;
#declare N=10;
#declare MyTorus = union {
         #while (I<N)
                 torus {1,0.1 rotate <90,0,0> rotate<0, I*360/N,0>}
                 #declare I=I+1;
         #end
         light_source{<0,.5,.5> rgb Light_Color}
         texture {
                 pigment {
                         color rgb <0.8,0.8,1.0>
                 }
                 finish{
                         diffuse 0.3
                         ambient 0.0
                         specular 0.6
                         reflection {
                                 0.8
                                 metallic
                         }
                         conserve_energy
                 }
         }
}
object{ MyTorus scale<.5,.5,.5> translate Position }
#end


//Call the macro with Color,Translate Position
MyTorus_Macro(Blue,<-1,.5,.7>)
MyTorus_Macro(Orange,<1,.5,0>)


Post a reply to this message

From:
Subject: Re: The macro itself :)
Date: 18 Sep 2003 16:45:09
Message: <3f6a1955$1@news.povray.org>
Declaration of MyTorus is not neccessary (and #local instead of
#declare would avoid introduction/overwriting of variables in the
main scene). My favourite method is like this:



#macro MyTorusMacro (LightColor)

#local I = 0;
#local N = 10;

union {

  // ... whatever ...

  // *no* closing brace! This makes application of *all* object
  // modifiers possible in the main scene, even bounded_by, no_image.
  // 'Match Brace' in the Search menu (and human readers) will *not*
  // be irritated by this omission if the brace appears in a comment
  // instead of beeing omitted completely, like in the following line:

  // "}" of union omitted to allow application of modifiers!

#end// macro MyTorusMacro



Call such macros in this way:

MyTorusMacro (Blue) /*{*/ scale ... rotate ... translate ... }



The commented-out opening brace isn't neccessary for parsing but
avoids irritation of 'Match Brace'. Normally I would call it a
bug to match a brace within a comment or inside a string with a
brace outside; in this case although I'm quite happy with this
behaviour.

   Sputnik


Post a reply to this message

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