POV-Ray : Newsgroups : povray.general : looking for sample code if nested #if #else #etc : Re: looking for sample code if nested #if #else #etc Server Time
26 Apr 2024 04:11:34 EDT (-0400)
  Re: looking for sample code if nested #if #else #etc  
From: Kenneth
Date: 28 Dec 2016 17:05:00
Message: <web.5864362d36394540883fb31c0@news.povray.org>
dick balaska <dic### [at] buckosoftcom> wrote:
> I could have sworn I saw in the include menu samples (or somewhere in
> the distribution) a wab of code like:
> #if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end
> #if (yfoo=1) ybar1 #else #if (yfoo=2) ybar2 #end #end
> #if (zfoo=1) zbar1 #else #if (zfoo=2) zbar2 #end #end
>
> ...
>
> Anyway, my mighty povclipse parser threw up on that. I said "huh, I'll
> have to get back to that" but I didn't make note of where I saw it.
>

I just tried this on my Windows 7 (64-bit) machine, using POV-ray v3.7, and it
works OK, no problems(!) I used only one of the three code lines...

              #if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end

.... but if it works for one, it should work for all three. (I don't *think* I've
ever used such a construct, though-- an #if(...)/#end inside of an #else(...) --
but it works on my system.)

Try this:

#version 3.7
global_settings {assumed_gamma 1.0}

camera {
  perspective
  location  <0, 1, -4>
  look_at   <0, 0,  0>
  right     x*image_width/image_height
  angle 67
}

light_source {
  0*x
  color rgb <1,1,1>
  translate <20, 40, -20>
}

#declare xfoo = 1; // 1 or 2

#declare xbar1 =
sphere {0,1 pigment {srgb <.1,.5,.9>} finish {ambient .1 diffuse .9}} // BLUE

#declare xbar2 =
sphere {0,1 pigment {srgb <.5,.5,.5>} finish {ambient .1 diffuse .9}} // GREY

#if (xfoo=1) xbar1 #else #if (xfoo=2) xbar2 #end #end


Post a reply to this message

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