|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Sorry if the subject to this posting is vague. I am not sure of the
technical term for what I am trying to do. Consider the following simple
file:
//==============================================
#declare Pigment = pigment{color rgb <1,1,1>}
#declare Ambient = 0;
#declare Diffuse = .2;
#declare Specular = .8;
sphere {
0, 1
pigment {Pigment}
finish {
ambient Ambient
diffuse Diffuse
specular Specular
}
}
//==============================================
In order to get a better idea of the effect of each of this attributes,
I want to have a loop that produces a range of values of a selected
attribute. There is one place I am stuck in. I want to say something
like:
#declare variable = "Ambient";
at the beginning of the file, and the program would then use all the
other values given, but vary the value of Ambient, say 5 times, and draw
the 5 resulting spheres.
The only way I have come up with so far is rather ugly. I would use:
#if (strcmp(variable, "Ambient") = 0)
...
But it is verbose, and also if I introduce a new variable, I have to
have a new conditional. I really want variable to 'think' it is Ambient
from that point on.
Grateful for any hints.
--
Kaveh
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
You could use an integer to represent the value you want to vary, like this:
#declare VaryAmbient = 1;
#declare VaryDiffuse = 2;
#declare VarySpecular = 3;
#declare WhichValueToVary = VaryAmbient;
#declare Variable = ... // Vary this
// ...
finish {
ambient (WhichValueToVary == VaryAmbient) ? Variable : 0.1;
diffuse (WhichValueToVary == VaryDiffuse) ? Variable : 0.6;
specular (WhichValueToVary == VarySpecular) ? Variable : 1.0;
}
// ...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Johannes Dahlstrom <sad### [at] tkukoulufi> wrote:
> You could use an integer to represent the value you want to vary, like this:
>
> #declare VaryAmbient = 1;
> #declare VaryDiffuse = 2;
> #declare VarySpecular = 3;
>
> #declare WhichValueToVary = VaryAmbient;
>
> #declare Variable = ... // Vary this
>
> // ...
> finish {
> ambient (WhichValueToVary == VaryAmbient) ? Variable : 0.1;
> diffuse (WhichValueToVary == VaryDiffuse) ? Variable : 0.6;
> specular (WhichValueToVary == VarySpecular) ? Variable : 1.0;
> }
> // ...
Thanks Johannes. I haven't come across this construction, and can't find
it in the manual. Can you give me a hint as to where I can find more
information on this?
--
Kaveh
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Kaveh wrote:
> Thanks Johannes. I haven't come across this construction, and can't find
> it in the manual. Can you give me a hint as to where I can find more
> information on this?
>
You mean the ? : ternary operator? Basically, it works like a simple
if/else construct:
#if(<expression>) <do_this> #else <do_that> #end
is the same as:
(<expression>) ? <do_this> : <do_that>
That is, if <expression> returns true, it executes the <do_this> part,
otherwise the <do_that> part.
In the POV manual:
6.1.3.3 Float Operators
http://www.povray.org/documentation/view/137/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Johannes Dahlstrom <sad### [at] tkukoulufi> wrote:
> Kaveh wrote:
>
> > Thanks Johannes. I haven't come across this construction, and can't find
> > it in the manual. Can you give me a hint as to where I can find more
> > information on this?
> >
>
> You mean the ? : ternary operator? Basically, it works like a simple
> if/else construct:
>
> #if(<expression>) <do_this> #else <do_that> #end
>
> is the same as:
>
> (<expression>) ? <do_this> : <do_that>
>
> That is, if <expression> returns true, it executes the <do_this> part,
> otherwise the <do_that> part.
>
> In the POV manual:
> 6.1.3.3 Float Operators
> http://www.povray.org/documentation/view/137/
Got it. Except you had == which according to the manual should be =. I
did a search for == but couldn't find it. I would have guessed == too!
--
Kaveh
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Kaveh wrote:
> Got it. Except you had == which according to the manual should be =. I
> did a search for == but couldn't find it. I would have guessed == too!
>
Oops, sorry... Too much C++ lately, I guess :)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |