Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
    POV-Ray Examples - How To Make Objects for POV-Ray
Italiano Italiano
Français français
Deutsch Deutsch

Home
- POV-Ray Tutorial
  - POV-Ray Examples
   Index of Content
  - Geometry
  - Architecture
    - House
    - Roof
    - Tower
    - Castle
    - Window + Door
    - Stairs
    - Pyramid
    - Columns
    - Arch
    - Fences
    - Furnitur
    - Household
  - Engineering
                                       
 
Roof

Roof

Objects: "box", "cylinder", "plane".
Methods: "#declare", "union", "intersection", "macro", "while".
The Construction of a Roof
by intensive use of "macro".
An include file to use this object as a read-made object
you can find at my POV-Ray Objects page.
Step 1:
A flat box and a bundle of cylinders
The roofing tiles are simulated by a parallel cylinders placed by a while loop, textured with stripes.
Example roof part1 600x450
Step 2:
Cutting off diagonally
The part of the roof after being rotated and translated to its final position is cut off by two diagonal planes to its final shape.
#macro Roof_quarter
    ( RAngle,  // roof angle
      RLen,    // roof length
      RWidth,  // roof width
      ROver,   // overhang
      RRCyl,   // radius cylinders
      RCylDist // distance cylinders
    )//--------------------------
 #local RSteep = // roof steep len
  sqrt( pow(RLen,2)
       +pow(RLen*tan(radians(RAngle)),2));
//----------------------------------------
intersection{ //a box with cylinders
 union{
  box {<-ROver,0,-ROver>,
       < RSteep,0.01,RWidth+ROver>
       texture{Roof2}}
   #declare Nr = 0;     // start
   #declare EndNr =
           (RWidth+2*ROver)/RCylDist;
   #while (Nr< EndNr)
   cylinder {<-ROver-0.01,0,0>,
             <RSteep,0,0>, RRCyl
             texture{Roof1}
   translate<0,0,-ROver+Nr*RCylDist>}
   #declare Nr = Nr + 1;    // next Nr
   #end // --------------- end of the loop
  rotate<0,0,RAngle>}// end of union
 //cut off by diagonal planes:
 plane{<1,0,0>, 0  rotate<0, 45,0>
       texture{Roof1}}
 plane{<1,0,0>, 0  rotate<0,-45,0>
       translate<0,0,RWidth>
       texture{Roof1}}

 bounded_by{
  box{<-ROver     ,-RRCyl,-ROver>,
      <RLen+RSteep, RRCyl,RWidth+2*ROver>}
      rotate<0,0,RAngle> }
 }//--------- end of intersection
#end // end of macro


//-------------------------------------
Example roof part1 600x450
Roof part I:
scene description for POV-Ray:
".txt" file oder ".pov" file
Step 3:
Placing the 4 quarters of the roof
After this all borders between these parts are covered by cylinders, which simulate the tiled ridge.
Example roof part2 600x450
// -------------------------- macro RoofHeight(...)-------
#macro RoofHeight(Len,Angle)
 Len*tan(radians(Angle))
#end
// -------------------------- macro RoofDiag(...)---------
#macro RoofDiag (ROver, R_Len, R_Angle, RoCyl_R)
 #local RXOver =  ROver*cos(radians(RoofAngle));
 #local RYOver =  ROver*sin(radians(RoofAngle));
  cylinder{<-RXOver,-RYOver,-RXOver>,
           <R_Len,RoofHeight(R_Len,R_Angle),R_Len>,
           1.2*RoCyl_R
           texture{Roof1 rotate<0,-45,R_Angle>}}
#end // end of macro

// --------------------------- macro Roof(...) -----------
#macro Roof (RoAngle1, // roof angle
             RoLen_X11,// lenght in x
             RoLen_X12,// lenght in z
             RoWideZ11,// width x parts
             RoWideZ12,// width z parts
             RoOver,   // overhang
             R_Cyl,    // radius cylinders
             Cyl_D)    // distance cylinders
 union{
 object{ Roof_quarter(RoAngle1,RoLen_X11,RoWideZ11,
                      RoOver,R_Cyl,Cyl_D)
                           translate<        0,0,0>}
 object{ Roof_quarter(RoAngle1,RoLen_X11,RoWideZ11,
                      RoOver,R_Cyl,Cyl_D)
         scale<-1,1,1>  translate<RoWideZ12,0,0>}
 object{ Roof_quarter(RoAngle1,RoLen_X12,RoWideZ12,
                      RoOver,R_Cyl,Cyl_D)
         rotate<0, 90,0>translate<0.00,0,RoWideZ11>}
 object{ Roof_quarter(RoAngle1,RoLen_X12,RoWideZ12,
                      RoOver,R_Cyl,Cyl_D)
         rotate<0,-90,0>translate<RoWideZ12,0,0>}
 union{
  object{ RoofDiag (RoOver, RoLen_X11, RoAngle1, R_Cyl)
                             translate<       0,0,0>}
  object{ RoofDiag (RoOver, RoLen_X11, RoAngle1, R_Cyl)
          rotate<0,-90,0> translate<RoWideZ12,0,0>}
  object{ RoofDiag (RoOver, RoLen_X11, RoAngle1, R_Cyl)
          rotate<0,180,0> translate<RoWideZ12,0,RoWideZ11>}
  object{ RoofDiag (RoOver, RoLen_X11, RoAngle1, R_Cyl)
          rotate<0, 90,0> translate<        0,0,RoWideZ11>}

  cylinder{<0,0,0>,<0,0,RoWideZ11-RoWideZ12>,1.2*R_Cyl
           translate<RoLen_X11,
                        RoHeight(RoLen_X11,
                        RoAngle1),RoLen_X12>
            texture{Roof1 rotate<0,90,0>}
          }// end of cylinder
 translate<0,0.05,0>}
} #end // -----------------end of Roof(...) macro ------
Roof macro:
scene description for POV-Ray:
".txt" file oder ".pov" file
Ready-made POV-Ray objects as
include files and example files you'll find
at the POV-Ray Objects Page
top

© Friedrich A. Lohmüller, 2006
www.f-lohmueller.de