coolray.org FAQ Contact Us
CoolRay Banner
CoolRay / Documentation
PreviousUpNext

F. Document Scenes

//
// RayLogo.ray - CoolRay Scene Description File
//
// This sample Scene demonstrates how a set of triangles
// can create a solid object. This is possible due to the
// special CSG alogirithm used in CoolRay. This allows even
// the usage of flat object like a Triangle to create solid
// primitives.
// A for loop is used to subtract 4 boxes from the pyramid
// and so creating a 'sliced' pyramid. Additionally a sphere
// is cut out of the pyramid.
//
scene RayLogo;

meta 
  author   "Marcus Bürgel"
  date     "2000-03-25"
  version  1.0.0

Scene {

  StrategySimple { }
  //StrategyAntialiasUniform { }

  PerspectiveCamera {
    location := <0, 4, -9>;
    look_at := <-1.7, 0.5, 0.5>;
    angle := 45;
  }

  World {
    var h :double;
    var pyramidTexture :Texture;
    var glassFinish :Finish;
    var c1 :Color;
    var c2 :Color;
    var c3 :Color;
    
    c1 := rgbt <1, 1, 1, 0.95>;
    c2 := rgbt <1, 1, 1, 0.95>;
    c3 := rgbt <1, 1, 1, 0.95>;

    glassFinish := Finish {
      ambient := 0.05;
      diffuse := 0.4;
      refraction := 1.0;
      ior := 1.5;
      specular := 0.7;
      specular_size := 0.002;
      reflection := 0.3;
    }
    pyramidTexture := SimpleTexture {
      XYZPigment {
        OnionPattern {
          //direction := <1, 0, 0>;
          noise := 0.3;
          turbulence := 1.6;
          octaves := 3;
          omega := 0.5;
          lambda := 3.0;
        }
        ColorMapList {
          ColorMapListEntry { value := 0.0; color :=  rgb <1, 0.78, 0.6>; }
          ColorMapListEntry { value := 0.5; color :=  rgb <0.75, 0.5, 0.3>; }
          ColorMapListEntry { value := 1.0; color :=  rgb <1, 0.78, 0.6>; }
        }
      }
      TransformationList {
        Scale { scale := <0.5, 0.5, 0.5>; }
        Translate { translate := <0, 1, 0>; }
      }
    } // SimpleTexture

    background_color := rgb <0.1, 0.05, 0.02>;

    PointLight {
      location := <-5, 6, -5>;
      color := rgb <1, 1, 1>;
      fade_power := 2;
      fade_distance := 7;
    }
    PointLight {
      location := <4, 5, -6>;
      color := rgb <0.6, 0.6, 0.6>;
      fade_power := 2;
      fade_distance := 7;
    }

    // height
    h := 1.225;

    Union {
      Difference {
        var i:integer;
        var k:double;

        // The Union forms the solid pyramid out of the flat triangles
        Union {
          Triangle {
            point1 := < 0, 0, 1>;
            point2 := <-0.866, 0, -0.5>;
            point3 := < 0.866, 0, -0.5>;
          }
          Triangle {
            point1 := <-0.866, 0, -0.5>;
            point2 := < 0, 0, 1>;
            point3 := <0, h, 0>;
          }
          Triangle {
            point1 := < 0, 0, 1>;
            point2 := < 0.866, 0, -0.5>;
            point3 := <0, h, 0>;
          }
          Triangle {
            point1 := < 0.866, 0, -0.5>;
            point2 := <-0.866, 0, -0.5>;
            point3 := <0, h, 0>;
          }
        } // Union
        k := 0;
        for i := 0 to 10 do {
          Box {
            point1 := <-1, i*0.1+0.08+k, -1>;
            point2 := <1, (i+1)*0.1, 1>;
          }
          k := k - 0.005;
        }
        Sphere {
          center := <0, 0.47, -0.3>;
          radius := 0.30;
        }
      } // Difference

      Difference {
        Sphere { radius := 0.27; }
        Sphere { radius := 0.26; }
        TransformationList {
          Translate { translate := <0, 0.47, -0.3>; }
        }
        SimpleTexture {
          SolidColorPigment {
            color := c3;
          }
          finish := glassFinish;
        } // SimpleTexture
      }

      Difference {
        Sphere { radius := 0.27; }
        Sphere { radius := 0.26; }
        TransformationList {
          Translate { translate := <0, 0.7, -1.3>; }
        }
        SimpleTexture {
          SolidColorPigment {
            color := c2;
          }
          finish := glassFinish;
        } // SimpleTexture
      }

      Difference {
        Sphere { radius := 0.27; }
        Sphere { radius := 0.26; }
        TransformationList {
          Translate { translate := <0, 0.8, -2.3>; }
        }
        SimpleTexture {
          SolidColorPigment {
            color := c1;
          }
          finish := glassFinish;
        } // SimpleTexture
      }

      texture := pyramidTexture;

      TransformationList {
        Scale { scale := <2, 2, 2>; }
        Rotate { rotate := <0, 40, 0>; }
        Translate { translate := <0.5, 0.5, 0>; }
      }

    } // Union

    Plane { 
      normal := <0, 1, 0>;
      distance := -0.001;
      SimpleTexture {
        XYZPigment {
          CheckerPattern {
            size := 2;
            TransformationList {
              Rotate {
                rotate := <0, -20, 0>;
              }
            }
          }
          SimpleColorMap {
            color1 :=  rgb <1, 1, 1>;
            color2 :=  rgb <0.15, 0.15, 0.15>;
          }
        }
        Finish {
          ambient := 0.1;
          diffuse := 0.7;
          reflection := 0.3;
        }
      } // SimpleTexture
    } // Plane

  } // World

} // Scene
Example 16: RayLogo and how it looks like
//
// SmallLogo.ray - CoolRay Scene Description File
//
scene SmallLogo;

meta 
  author   "Stefan Michel & Marcus Buergel"
  date     "2000-04-29"
  version  1.0.0

Scene {

  StrategySimple { }
  //StrategyAntialiasUniform { }

  PerspectiveCamera {
    location := <0, 2, -5>;
    look_at := <0, 0.5, 0.5>;
    angle := 45;
  }

  World {
    var h :double;
    var pyramidTexture :Texture;
    var glassFinish :Finish;
    var c1 :Color;
    var c2 :Color;
    var c3 :Color;
    
    c1 := rgbt <1, 1, 1, 0.95>;
    c2 := rgbt <1, 1, 1, 0.95>;
    c3 := rgbt <1, 1, 1, 0.95>;

    glassFinish := Finish {
      ambient := 0.05;
      diffuse := 0.4;
      refraction := 1.0;
      ior := 1.5;
      specular := 0.7;
      specular_size := 0.002;
      reflection := 0.3;
    }
    pyramidTexture := SimpleTexture {
      XYZPigment {
        OnionPattern {
          //direction := <1, 0, 0>;
          noise := 0.3;
          turbulence := 1.6;
          octaves := 3;
          omega := 0.5;
          lambda := 3.0;
        }
        ColorMapList {
          ColorMapListEntry { value := 0.0; color :=  rgb <1, 0.78, 0.6>; }
          ColorMapListEntry { value := 0.5; color :=  rgb <0.75, 0.5, 0.3>; }
          ColorMapListEntry { value := 1.0; color :=  rgb <1, 0.78, 0.6>; }
        }
      }
      TransformationList {
        Scale { scale := <0.5, 0.5, 0.5>; }
        Translate { translate := <0, 1, 0>; }
      }
    } // SimpleTexture

    //background_color := rgb <0.1, 0.05, 0.02>;
    background_color := rgb <1, 1, 1>;
    

    PointLight {
      location := <-5, 6, -5>;
      color := rgb <1, 1, 1>;
      fade_power := 2;
      fade_distance := 7;
    }
    PointLight {
      location := <4, 5, -6>;
      color := rgb <0.6, 0.6, 0.6>;
      fade_power := 2;
      fade_distance := 7;
    }

    // height
    h := 1.225;

    Union {
      Difference {
        var i:integer;
        var k:double;

        // The Union forms the solid pyramid out of the flat triangles
        Union {
          Triangle {
            point1 := < 0, 0, 1>;
            point2 := <-0.866, 0, -0.5>;
            point3 := < 0.866, 0, -0.5>;
          }
          Triangle {
            point1 := <-0.866, 0, -0.5>;
            point2 := < 0, 0, 1>;
            point3 := <0, h, 0>;
          }
          Triangle {
            point1 := < 0, 0, 1>;
            point2 := < 0.866, 0, -0.5>;
            point3 := <0, h, 0>;
          }
          Triangle {
            point1 := < 0.866, 0, -0.5>;
            point2 := <-0.866, 0, -0.5>;
            point3 := <0, h, 0>;
          }
        } // Union
        k := 0;
        for i := 0 to 10 do {
          Box {
            point1 := <-1, i*0.1+0.08+k, -1>;
            point2 := <1, (i+1)*0.1, 1>;
          }
          k := k - 0.005;
        }
        Sphere {
          center := <0, 0.47, -0.3>;
          radius := 0.30;
        }
      } // Difference

      texture := pyramidTexture;

      Rotate {
        rotate := <0,@@,0>;
      }

    } // Union

  } // World

} // Scene
Example 17: SmallLogo and how it looks like

PreviousUpNext
You are visitor No.

counter

Copyright (c) 2001 Stefan Michel, All Rights Reserved.
Last modified: