#switch Befehl, need help!

#switch Befehl, need help!

Post by petjoj » Thu, 29 Jan 2004 00:38:20


Wie krieg ich es hin, das die 6 Kugeln abwechselnd rot bzw. gr sind?

#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"
camera { location <0, 5 , -10>
look_at <1 , 1 , 1> }
light_source {<-0,5,-10> color White}
plane { y , -3.0 pigment { checker color White color Black } }

#declare Ball = sphere{<0,0,0>,0.5}

#declare Nr = -2.5;
#declare EndNr = 2.5;

#while (Nr< EndNr+1)
object{Ball translate<Nr,0,0>}
#declare Nr = Nr + 1;

#switch(mod(Nr + EndNr , 2))
#case(0) object{Ball { pigment { Green } }
#break
#case(1) object{Ball { pigment { Red } }
#break
#end
 
 
 

#switch Befehl, need help!

Post by Marc Rot » Thu, 29 Jan 2004 01:19:20

#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"

camera {
location <0, 5 , -10>
look_at <1 , 1 , 1>
}
light_source { <-0,5,-10> color White }
plane { y , -3.0 pigment { checker color White color Black } }
#declare Ball_green = sphere { <0,0,0>, 0.5 pigment { Green } }
#declare Ball_red = sphere { <0,0,0>, 0.5 pigment { Red } }

#declare n = 0;
#while (n<3)
object { Ball_green translate 2*n*x }
object { Ball_red translate (2*n+1)*x }
#declare n = n+1;
#end

das we eine mlichkeit :D
bis dann,
Marc