POV-Ray : Newsgroups : povray.newusers : Problem with variables : Problem with variables Server Time
4 Sep 2024 16:14:35 EDT (-0400)
  Problem with variables  
From: Kaveh
Date: 27 Oct 2002 07:11:43
Message: <1fkpnlf.dx0416mokegiN%kaveh@delete_this.focalimage.com>
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

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