Beschreibungen und Beispiele zum Raytracer POV-Ray von Friedrich A. Lohmüller
    Bedingte Anweisungen - Anwendungen -
English English English

Home
- POV-Ray Tutorial

  - Bedingte
    Anweisungen

  Verzweigungen
   #if(...) ... #else ... #end
    - in Schleifen
    - in Macros
    - in Animationen
    - Ein-/Ausschalten von Teilen
   #switch(...) #case(..) ...
          #range(..) ... #end
    > Auswahl-Listen

  Existenz-Überprüfungen
   #ifdef(...) #ifndef(...)
    - Check in Include-Dateien
    - Defaults in Include-Dateien

  Schleifen
  Prechecked, Postchecked,
  Count-controlled, Early-Exit
   #while(...)... #end
   #for(...)... #end
    - Beispiele:
    - Schleifen in POV-Ray
    - Schleifen, Sinus, Kosinus
                                       

Verzweigungen mit Auswahl-Listen              

Dieses Beispiel für den Gebrauch von Auswahl-Listen mit #switch in einem Makro soll demonstrieren wie etwa ein kompleter Texturensatz für Autos definiert werden kann:

#macro Car_Body_Texture_Set(Texture_Number)
#switch(Texture_Number)
#case (1)
 #declare Car_Body_Texture =
 texture{ pigment{ color rgb<1,0.96,0.94>*0.7}
  finish{ phong 1 reflection{.35,metallic .5}}
        } // end of texture
 #declare Car_Top_Texture =
 texture{ pigment{ color  rgb<1,1,1>*1.2}
          finish { phong 0.6}
        } // end of texture
 #declare Car_Seat_Texture =
 texture{ pigment{ color rgb<1,0.90,0.85>*1.3}
        } // end of texture
 #declare Car_Inside_Texture=
 texture{ Car_Seat_Texture }
 #declare Bumper_Metal_Texture =
 texture{ Car_Body_Texture }
#break //---------------------------------
#case (2)
 #declare Car_Body_Texture =
 texture{ pigment{ color rgb<0.9,0.7,1>*1.2}
  finish{ phong 1 reflection{.35,metallic .5}}
        } // end of texture
 #declare Car_Top_Texture =

  // ... snip!

 #declare Bumper_Metal_Texture =
 texture{ Car_Body_Texture }
#break //---------------------------------
#else // all other numbers
 #declare Car_Body_Texture =
 texture{ pigment{ color rgb<1,1,1>*1.2}
  finish{ phong 1 reflection{.35,metallic .5}}
        } // end of texture
 #declare Car_Top_Texture =

  // ... snip!

 #declare Bumper_Metal_Texture =
 texture{ Polished_Chrome }
 #break //---------------------------------
#end // end of switch
#end // end of macro -------------------------
//--------------------------------------------
// Aufrufe
Car_Body_Texture_Set(0)
#include "Car_01.inc"
object{ Car_01(-10, //Front_Wheel_Angle,
                0,//Coupe_ON:0=hardtop;1=coupé
                Car_Body_Texture, //
                Car_Top_Texture, //
                Car_Seat_Texture, //
                Car_Inside_Texture, //
                Wheel_Rubber_Texture, //
                Wheel_Metal_Texture, //
                Bumper_Metal_Texture, //
                Chassis_Inside_Texture //
              ) //----------------------
        rotate<0, 90,0>
        translate<-4.3,0,3>}
//--------------------------------------------
Car_Body_Texture_Set(1)
#include "Car_01.inc"
object{ Car_01(-10, //Front_Wheel_Angle,
                1,//Coupe_ON:0=hardtop;1=coupé
                Car_Body_Texture, //
 // ... snip!
              ) //----------------------
        rotate<0,70,0>
        translate<0,0,3>}
//--------------------------------------------
Car_Body_Texture_Set(2)
#include "Car_01.inc"
object{ Car_01(-10, //Front_Wheel_Angle,
                1,//Coupe_ON:0=hardtop;1=coupé
                Car_Body_Texture, //
 // ... snip!
              ) //-------------------------
        rotate<0,65,0>
        translate<4,0,3>}
//----------------------------------------
#if ... #else ... #end

top

 
© Friedrich A. Lohmüller, 2010
homepage:www.f-lohmueller.de