/*A demonstration of light reflection.
by Henri Sivonen
30 Sep 1998
--
1 Oct 1998 and 2 Oct 1998
Added animation option
--
2 Oct 1998
First release
--
3 Oct 1998
Added crand 0 to the floor finish
This release
--
You may not claim this scene as your work as a whole.
You may use portions of this code in your own scenes fully copyrighted to yourself. In such case no crediting or payment regarding code copied from this file is necessary.
This permission does NOT extend to other works, which do not contain this notice, viewable on the author's Web site.
Permissions regarding the include files used in this scene are listed in POVLEGAL.DOC.
*/


#include "colors.inc"
#include "stones.inc"
#include "woods.inc"

//the amount of reflection
#local floor_reflection = .5;

union{
    //floor
    plane{
        y,0
        texture{T_Grnt20
            finish{
                crand 0 //added for animation, not used is the stills
                reflection floor_reflection
            }
            scale .2
            translate <2.3434,4.334,.3432>
        }
        no_shadow
        hollow
    }
    //walls
    plane{
        z,1
        texture{T_Wood7
            rotate <89,1,1>
            scale .1
        }
        hollow
    }
    plane{
        x,1
        texture{T_Wood7
            rotate <89,1,1>
            scale .1
        }
        hollow
    }
    clipped_by{
        plane{
            <-1,0,-1>,.45
        }
    }
}

//fill light
light_source{
    <-1,1,-1>
    color rgb .5
    media_interaction off
    media_attenuation off
}

#local spot_location = <0,1,-1.5>;

/*uncomment for animation, clock = 0...1
#if (clock < .2)
    #local first_clock = clock*5;
    #declare first_rotate = <-65+10*first_clock,0,0>;
    #declare second_rotate = <0,40-10 *first_clock,0>;
#end
#if ((clock >= .2)&(clock < .5))
    #local second_clock = (clock-.2)/.3;
    #declare first_rotate = <-55,0,0>;
    #declare second_rotate = <0,30-30*second_clock,0>;
#end
#if ((clock >= .5)&(clock < .7))
    #local third_clock = (clock-.5)/.2;
    #declare first_rotate = <-55-20*third_clock,0,0>;
    #declare second_rotate = <0,0,0>;
#end
#if (clock >= .7)
    #local fourth_clock = (clock-.7)/.3;
    #declare first_rotate = <-75+10*fourth_clock,0,0>;
    #declare second_rotate = <0,0+40*fourth_clock,0>;
#end
*/


/*comment the following two declare out for animation*/
#declare first_rotate = <-55,0,0>;
#declare second_rotate = <0,10,0>;


//primary spotlight
light_source{
    <0,0,0>
    color rgb 1
    spotlight
    point_at <0,-1,0>
    radius 5
    falloff 8
    tightness .5
    rotate first_rotate
    rotate second_rotate
    translate spot_location
}

//mirrored spotlight
light_source{
    <0,0,0>
    color rgb floor_reflection
    spotlight
    point_at <0,-1,0>
    radius 5
    falloff 8
    tightness .5
    rotate first_rotate
    rotate second_rotate
    translate spot_location
    scale <1,-1,1> //mirror about the floor
}

//reflection demonstration cylinder
cylinder{
    <-.3,-.3,.5>, //extend through the floor
    <-.3,.3,.5>,
    .2
    texture{T_Grnt16
        rotate <90,2,1>
    }
}

//overly scattering media for visualization of the spotlight
media{
    scattering{
        1,
        rgb .75
        extinction .25
    }
    intervals 10
    samples 1,2
    /*values used for the title picture
    intervals 20
    samples 2,5
    */

}

//a stick for blocking the spotlight partially
cylinder{
    <0,0,0>,
    <0,0,-1.1>,
    .025
    texture{T_Wood1}
    rotate <10,0,0>
    rotate <0,40,0>
    translate <.25,.25,-.4>
}

//mirrored stick
cylinder{
    <0,0,0>,
    <0,0,-1.1>,
    .025
    texture{T_Wood1}
    rotate <10,0,0>
    rotate <0,40,0>
    translate <.25,.25,-.4>
    scale <1,-1,1> //mirror about the floor
}

camera{
    location <-1,1,-1>
    look_at <1,0,1>
}