// ====================================== // XIXe Paris street lamp // ----------------------------------------- // Made for Persistence of vision 3.6 //========================================== // Copyright 1998-2004 Gilles Tran http://www.oyonale.com // ----------------------------------------- // This work is licensed under the Creative Commons Attribution License. // To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ // or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. // You are free: // - to copy, distribute, display, and perform the work // - to make derivative works // - to make commercial use of the work // Under the following conditions: // - Attribution. You must give the original author credit. // - For any reuse or distribution, you must make clear to others the license terms of this work. // - Any of these conditions can be waived if you get permission from the copyright holder. // Your fair use and other rights are in no way affected by the above. //========================================== #include "colors.inc" #include "textures.inc" // ====================================== // MakeStreetLamp macro // ====================================== // This macro creates a street lamp such as the ones you could find in Paris // in the XIXe century. It's a totally imaginary model though. // This lamp is used in the pictures "Mouseless" and "Learning to fly". // It can be turned on and off (Light_OK variable) // It can have a halo within and around the head of the lamp (not too realistic I fear) // #macro MakeStreetLamp(Type_Lamp,Light_OK,C_Light,Area_OK,Halo_OK,Halo_Size,Halo_Turb,Halo_Strength,Fade_Distance,T_Glass,T_Paint) //#declare Type_Lamp=1; // 1=complex 2=simple 3=no post (test purpose) //#declare Light_OK=1; // 0=light off 1=light on //#declare C_Light=rgb<0.8,0.9,1.3>; // light color //#declare Area_OK=0; // 0=area light off 1=area light on //#declare Halo_OK=1; // 0=halo off 1=halo on //#declare Halo_Size=6; // outer halo size //#declare Halo_Turb=0.1; // outer halo turbulence //#declare Halo_Strength=0.7; // inner and outer halo intensity (outer halo is 50% inner halo intensity) //#declare Fade_Distance=200; // light fade distance //#declare T_Glass=texture{pigment{Clear} finish{ambient 0 diffuse 0}} // glass texture //#declare T_Paint=texture{pigment{ForestGreen*0.3} finish{ambient 0.1 specular 1 roughness 0.05}} // paint texture //#declare SideDeco = height_field{gif "sidedeco.gif"} // decoration for lamp sides //#declare SideDeco = box{0,<1,0.1,1>} // minimum side decoration #local eHeadLamp=0.25; #local eHeadLamp2=0.17; #local rHeadLamp1=1.6; #local rHeadLamp2=2.3; #local rHeadLamp3=1.6; #local yHeadLamp2=5; #local yHeadLamp3=7; #local yArmLamp=1.5; //================================ // Lamp glass //================================ #local rTL1=rHeadLamp1-eHeadLamp2; #local rTL2=rHeadLamp2-eHeadLamp2; #local rTL3=rHeadLamp3; #local yTL1=eHeadLamp; #local yTL2=yHeadLamp2; #local yTL3=yHeadLamp3; #local DensityLamp=density { boxed color_map{ [0.0 Black] [1.0 C_Light*Halo_Strength] } } #local mediaLamp=media { emission Halo_Strength intervals 5 samples 1, 5 confidence 0.9999 variance 1/10 density {DensityLamp} scale translate y*yTL3*0.5 } #local DensityHalo=density { spherical turbulence Halo_Turb color_map{ [0.0 Black] [1.0 C_Light*Halo_Strength*.5] } } #local mediaHalo=media { emission Halo_Strength*0.5 intervals 5 samples 1, 5 confidence 0.9999 variance 1/10 density {DensityHalo} } #declare LampHalo=sphere{ 0,1 texture{pigment{Clear} finish{ambient 0 diffuse 0}} interior{media{mediaHalo}} hollow no_shadow scale <1,1.3,1>*Halo_Size translate y*yTL3*0.5 } #local GlassLamp=difference{ box{<-rTL2,0,-rTL2>,} plane{x,0 rotate -z*degrees(atan2(rTL2-rTL3,yTL3-yTL2)) translate <-rTL2,yTL2,0>} plane{x,0 rotate z*degrees(atan2(rTL2-rTL1,yTL2-yTL1)) translate <-rTL2,yTL2,0>} union{ plane{x,0 rotate -z*degrees(atan2(rTL2-rTL3,yTL3-yTL2)) translate <-rTL2,yTL2,0>} plane{x,0 rotate z*degrees(atan2(rTL2-rTL1,yTL2-yTL1)) translate <-rTL2,yTL2,0>} rotate y*-90 } union{ plane{x,0 rotate -z*degrees(atan2(rTL2-rTL3,yTL3-yTL2)) translate <-rTL2,yTL2,0>} plane{x,0 rotate z*degrees(atan2(rTL2-rTL1,yTL2-yTL1)) translate <-rTL2,yTL2,0>} rotate y*180 } union{ plane{x,0 rotate -z*degrees(atan2(rTL2-rTL3,yTL3-yTL2)) translate <-rTL2,yTL2,0>} plane{x,0 rotate z*degrees(atan2(rTL2-rTL1,yTL2-yTL1)) translate <-rTL2,yTL2,0>} rotate y*270 } texture{T_Glass} #if (Halo_OK>0) interior{media{mediaLamp}} #end hollow no_shadow translate -y*yTL3*0.5 scale 1.2 translate y*yTL3*0.5 } //================================ // Montant Head Lampadaire //================================ #local MontantHeadLamp=union{ cylinder{<-rHeadLamp1+eHeadLamp2,0,-rHeadLamp1+eHeadLamp2>,<-rHeadLamp2,yHeadLamp2+eHeadLamp+eHeadLamp2*1.5,-rHeadLamp2>,eHeadLamp2} cylinder{<-rHeadLamp2+eHeadLamp2,yHeadLamp2,-rHeadLamp2+eHeadLamp2>,<-rHeadLamp3,yHeadLamp3+eHeadLamp+eHeadLamp2*1.5,-rHeadLamp3>,eHeadLamp2} sphere{0,1 translate y scale eHeadLamp2*1.5 translate <-rHeadLamp2,yHeadLamp2+eHeadLamp,-rHeadLamp2>} sphere{0,1 translate y scale eHeadLamp2*1.5 translate <-rHeadLamp3,yHeadLamp3+eHeadLamp,-rHeadLamp3>} } //================================ //Decorative leaf //================================ #local Leaf=intersection{ difference{sphere{0,1}sphere{0,0.99}} plane{z,0 rotate y*20 inverse} plane{z,0 rotate -y*20} translate <-0.2,1,0> rotate z*70 } //================================ // Collar of leaves //================================ #local CollarLeaves=union{ #local teta=0; #while (teta<360) object{Leaf rotate z*50 translate -x rotate y*teta} #local teta=teta+18; #end } //================================ // Decorative spiral //================================ #local rSpiral0=3; #local rSpiral=rSpiral0; #local eSpiral=0.4; #local eSpiral1=eSpiral; #local etetaSpiral=pi/30; #local tetaSpiral=etetaSpiral; #local pt1=x*rSpiral; #local SpiralLamp=union{ union{ #while (rSpiral>0.2) #local pt2=*rSpiral; #local eSpiral2=eSpiral1-0.001; cone{pt1,eSpiral1,pt2,eSpiral2} #local rSpiral=rSpiral-0.025; #local tetaSpiral=tetaSpiral+etetaSpiral; #local pt1=pt2; #local eSpiral1=eSpiral2; #end } intersection{ torus{rSpiral0*1.5,eSpiral rotate x*90} plane{x,0} plane{y,0} translate x*(rSpiral0*2.5) } translate -x*(rSpiral0*2.5) scale 1.5 } //================================ // Element6 Spiral sets //================================ #local ElementLamp6=union{ object{SpiralLamp } object{SpiralLamp rotate y*72} object{SpiralLamp rotate y*144} object{SpiralLamp rotate y*216} object{SpiralLamp rotate y*288} translate y*rSpiral*1.5 scale 0.3 } //================================ // Lamp "meche" //================================ #local MecheLamp=union{ sphere{0,0.5} cylinder{-10*y,4*y,1.5} cylinder{4*y,<2,15,-1>,0.15} union{ torus{0.6,0.3} cylinder{x*0.6,<6,-1,0>,0.14} torus{0.7,0.2 rotate x*-90 translate <6.7,-1,0>} translate y*4 } } //================================ // Lamp head //================================ #local HeadLamp=union{ object{GlassLamp} #if (Halo_OK=1) object{LampHalo} #end difference{ box{<-rHeadLamp1,0,-rHeadLamp1>,} box{<-rHeadLamp1+eHeadLamp,-eHeadLamp,-rHeadLamp1+eHeadLamp>,} } difference{ box{<-rHeadLamp2-eHeadLamp,0,-rHeadLamp2-eHeadLamp>,} box{<-rHeadLamp2+eHeadLamp,-eHeadLamp,-rHeadLamp2+eHeadLamp>,} translate yHeadLamp2*y } box{<-rHeadLamp3-eHeadLamp*2,0,-rHeadLamp3-eHeadLamp*2>, translate yHeadLamp3*y} object{MontantHeadLamp} object{MontantHeadLamp rotate y*90} object{MontantHeadLamp rotate y*180} object{MontantHeadLamp rotate y*270} union{ union{ intersection { plane { y, 0.5} quadric {<1.0, -1.0, 1.0>,<0.0, 0.0, 0.0>,<0.0, 0.0, 0.0>,-0.3} plane { y, -1 inverse} translate y } intersection{ sphere{0,0.8 scale <1,0.8,1>} plane{y,0 inverse} translate y*1.5 } scale <1.7,1,1.7> } torus{1.4,0.1 translate y*1.5} sphere{0,0.4 translate y*2.5} union{ object{Leaf} object{Leaf rotate y*72} object{Leaf rotate y*144} object{Leaf rotate y*216} object{Leaf rotate y*288} translate y*2.6 } translate y*(yHeadLamp3+eHeadLamp) } object{MecheLamp scale 0.4 translate -y*yArmLamp} } //================================ // Element5 //================================ #local ElementLamp5=lathe{ cubic_spline 10, <-3, 0>, <0, 0>, <2.5, 0.5>, <4, 0.9>, <3.9, 2>, <2,3>,<3,4>,<3,5>,<0,6>,<-3,6> scale <0.3,0.5,0.3> } //================================ // Element4 //================================ #local partElementLamp4=union{ lathe{cubic_spline 13,<0,0>,<1,0>,<1.3,0.2>,<1.6,1>,<1,2>,<0.5,10>,<0.6,15>,<0.7,15.3>,<0.5,16>,<0.6,19>,<0.9,20>,<0.5,20.5>,<0,21> scale <0.3,1,0.3>} torus{0.3,0.2 translate y*2} torus{0.2,0.1 translate y*14.9} translate x*0.5 rotate z*1 } #local ElementLamp4=union{ #local teta=0; #while (teta<360) object{partElementLamp4 rotate y*teta} #local teta=teta+36; #end } //================================ // Element3 //================================ #local SmallFootLamp=blob{ threshold 1.3 sphere{0,4,4 translate x*4} cylinder{x*4,x*10-y*4,2,3} sphere{0,3,4 translate x*10-y*4} cylinder{x*10-y*4,x*12-y*10,2,3} sphere{0,3,2 translate 2*x translate x*13-y*10} cylinder{0,2*x+y,1.5,3 translate 2*x translate x*13-y*10} sphere{0,2,2 translate 2*x+2*y translate 2*x translate x*13-y*10} cylinder{2*x+2*y,5*x,1,3 translate 2*x translate x*13-y*10} sphere{0,3,2 scale <2,0.4,1> translate 6*x translate 2*x translate x*13-y*10} sphere{0,3,2 translate x rotate y*50 translate x*13-y*10} cylinder{0,2*x+y,1.5,3 translate x rotate y*50 translate x*13-y*10} sphere{0,2,2 translate 2*x+2*y translate x rotate y*50 translate x*13-y*10} cylinder{2*x+2*y,5*x,1,3 translate x rotate y*50 translate x*13-y*10} sphere{0,3,2 scale <2,0.4,1> translate 6*x translate x rotate y*50 translate x*13-y*10} sphere{0,3,2 translate x rotate -y*50 translate x*13-y*10} cylinder{0,2*x+y,1.5,3 translate x rotate -y*50 translate x*13-y*10} sphere{0,2,2 translate 2*x+2*y translate x rotate -y*50 translate x*13-y*10} cylinder{2*x+2*y,5*x,1,3 translate x rotate -y*50 translate x*13-y*10} sphere{0,3,2 scale <2,0.4,1> translate 6*x translate x rotate -y*50 translate x*13-y*10} translate y*10 scale 0.2 translate x*0.5 } #local partElementLamp3=union{ lathe{cubic_spline 10,<0,-1>,<0.5,0>,<3,0.5>,<3.4,1.5>,<2,3>,<2,4.5>,<1.3,5>, <1.6,5.5>,<1.2,5.8>,<0,6> scale <0.5,1,0.5>} lathe{cubic_spline 10,<0,-1>,<0.5,0>,<3,0.5>,<3.4,1.5>,<2,3>,<2,4.5>,<1.3,5>, <1.6,5.5>,<1.2,5.8>,<0,6> scale <0.55,1,0.2>} torus{0.4,0.2 translate y*6} torus{1.6,0.05 translate y*2} torus{1,0.2 scale <1,2,1>} union{ torus{0.3,0.1 rotate z*80} sphere{0,0.12 scale <3,1,1>} translate <-2,3.2,0> } union{ torus{0.3,0.1 rotate z*80} sphere{0,0.12 scale <3,1,1>} translate <-2,4.2,0> } translate x*0.5 } #local ElementLamp3=union{ difference{ cylinder{0,y*2,1} #local teta=0; #while (teta<360) sphere{0,1 scale <1,2.5,2>*0.3 translate -x rotate y*teta translate y} #local teta=teta+36; #end translate y*8 } object{CollarLeaves scale <1,-1,1>*0.5 translate y*8} torus{1,0.2 translate y*10} union{ #local teta=0; #while (teta<360) object{partElementLamp3 rotate y*teta} #local teta=teta+36; #end translate y*2 } union{ #local teta=0; #while (teta<360) object{SmallFootLamp rotate y*teta} #local teta=teta+72; #end } } //================================ // Element1 //================================ #local rEl1=6; #local partElementLamp1=union{ box{<-rEl1-0.5,0,-tan(pi/5)*(rEl1+0.5)>,<0,0.7,tan(pi/5)*(rEl1+0.5)> translate y*13.5} cylinder{-tan(pi/5)*z*(rEl1+0.5),tan(pi/5)*z*(rEl1+0.5),0.2 translate -x*(rEl1+0.5) translate y*14} sphere{tan(pi/5)*z*(rEl1+0.5),0.2 translate -x*(rEl1+0.5) translate y*14} cylinder{-tan(pi/5)*z*(rEl1+0.5),tan(pi/5)*z*(rEl1+0.5),0.25 translate -x*(rEl1+0.5) translate y*13.75} sphere{tan(pi/5)*z*(rEl1+0.5),0.25 translate -x*(rEl1+0.5) translate y*13.75} cylinder{-tan(pi/5)*z*(rEl1+0.5),tan(pi/5)*z*(rEl1+0.5),0.15 translate -x*(rEl1+0.5) translate y*13.625} sphere{tan(pi/5)*z*(rEl1+0.5),0.15 translate -x*(rEl1+0.5) translate y*13.625} box{<-rEl1-0.5,0,-tan(pi/5)*(rEl1+0.5)>,<-rEl1,1,tan(pi/5)*(rEl1+0.5)> translate y*12.5} cylinder{-tan(pi/5)*z*(rEl1+0.5),tan(pi/5)*z*(rEl1+0.5),0.15 translate -x*(rEl1+0.5) translate y*12.5} sphere{tan(pi/5)*z*(rEl1+0.5),0.15 translate -x*(rEl1+0.5) translate y*12.5} cylinder{-tan(pi/5)*z*(rEl1+0.5),tan(pi/5)*z*(rEl1+0.5),0.25 translate -x*(rEl1+0.5) translate y*12.25} sphere{tan(pi/5)*z*(rEl1+0.5),0.25 translate -x*(rEl1+0.5) translate y*12.25} cylinder{-tan(pi/5)*z*rEl1,tan(pi/5)*z*rEl1,0.5 translate -x*rEl1 translate y*12} sphere{tan(pi/5)*z*rEl1,0.5 translate -x*rEl1 translate y*12} object{SideDeco translate -x*0.5 scale rotate x*-90 rotate y*90 translate -x*rEl1 translate y*4.5} cylinder{0,y*7,0.3 translate <-rEl1+0.2,4.5,-tan(pi/5)*rEl1>} cylinder{-tan(pi/5)*z*rEl1,tan(pi/5)*z*rEl1,0.25 translate -x*rEl1 translate y*4.25} sphere{tan(pi/5)*z*rEl1,0.25 translate -x*rEl1 translate y*4.25} cylinder{-tan(pi/5)*z*(rEl1+0.25),tan(pi/5)*z*(rEl1+0.25),0.25 translate -x*(rEl1+0.25) translate y*4} sphere{tan(pi/5)*z*(rEl1+0.25),0.25 translate -x*(rEl1+0.25) translate y*4} difference{ intersection{ box{<-rEl1-1,0,-tan(pi/5)*(rEl1+0.5)*2>,<-rEl1,0.5,tan(pi/5)*(rEl1+0.5)*2>} plane{z,0 rotate y*36} plane{z,0 rotate -y*36 inverse} } cylinder{-tan(pi/5)*z*(rEl1+1)*3,tan(pi/5)*z*(rEl1+1)*3,0.5 translate -x*(rEl1+1) translate y*0.5} translate y*3.5 } cylinder{-tan(pi/5)*z*(rEl1+1),tan(pi/5)*z*(rEl1+1),0.25 translate -x*(rEl1+1) translate y*3.25} sphere{tan(pi/5)*z*(rEl1+1),0.25 translate -x*(rEl1+1) translate y*3.25} box{<-rEl1-1,0,-tan(pi/5)*(rEl1+1)>,<-rEl1,0.5,tan(pi/5)*(rEl1+1)> translate y*2.5} cylinder{-tan(pi/5)*z*(rEl1+1),tan(pi/5)*z*(rEl1+1),0.25 translate -x*(rEl1+1) translate y*2.25} sphere{tan(pi/5)*z*(rEl1+1),0.25 translate -x*(rEl1+1) translate y*2.25} cylinder{-tan(pi/5)*z*(rEl1+1),tan(pi/5)*z*(rEl1+1),0.5 translate -x*(rEl1+1) translate y*1.5} sphere{tan(pi/5)*z*(rEl1+1),0.5 translate -x*(rEl1+1) translate y*1.5} box{<-rEl1-1.5,0,-tan(pi/5)*(rEl1+1.5)>,<-rEl1,1.5,tan(pi/5)*(rEl1+1.5)>} } #local ElementLamp1=union{ #local teta=0; #while (teta<360) object{partElementLamp1 rotate y*teta} #local teta=teta+72; #end } //================================ // Element7 //================================ #local ElementLamp7=lathe{ cubic_spline 11, <4, -1>, <5, 0>, <4, 1>, <3.4, 2>, <3.4, 2.1>,<4,2.5> <3.7,3>,<3,4>,<2,5>,<2,6>,<2.3,7> scale <0.5,48/6,0.5> } //================================ // Lumière //================================ #local LumLamp=light_source{0 C_Light*5 #if (Area_OK=1) area_light x*2,z*2 10, 10 adaptive 1 jitter #end fade_distance Fade_Distance fade_power 2 } //================================ // Lampadaire //================================ #if (Type_Lamp<3) union{ union{ #if (Light_OK=1) object{LumLamp scale 10 translate y*10} #end object{HeadLamp translate y*6.5} #if (Type_Lamp=1) object{ElementLamp6 translate y*4} #end object{ElementLamp5} object{CollarLeaves scale 0.5 translate y*0.5} translate y*47.7 } #if (Type_Lamp=1) object{ElementLamp4 scale <2,1,2> translate y*28.2} object{ElementLamp3 scale 1.5 translate y*14.2} object{ElementLamp1} #else object{ElementLamp7} #end texture{T_Paint} } #else #if (Light_OK=1) object{LumLamp scale 10 translate y*57.7} #end #end // ====================================== // End macro // ====================================== scale 5/60 #end // ====================================== // Lamp example // ====================================== global_settings{ assumed_gamma 1 radiosity{ recursion_limit 2 } } #declare PdV=<0, 1.7, -30>; #declare PdA=<0, 2.5, 0>; camera{ location PdV direction z*4 right image_width*x/image_height look_at PdA } //light_source{PdV color White*0.3} //light_source{<-100,100,-29> color White} light_source{<100,100,-28> color White*3} #declare Type_Lamp=1; // 1=complex 2=simple 3=light only #declare Light_OK=1; // 0=light off 1=light on #declare C_Light=rgb<1.3,1,0.7>; // light color #declare Area_OK=1; // 0=area light off 1=area light on #declare Halo_OK=1; // 0=halo off 1=halo on #declare Halo_Size=7; // outer halo size #declare Halo_Turb=0.1; // outer halo turbulence #declare Halo_Strength=2; // inner and outer halo intensity (outer halo is 50% inner halo intensity) #declare Fade_Distance=5; // light fade distance #declare T_Glass=texture{pigment{Clear} finish{ambient 0 diffuse 0 reflection {0,0.2}}} // glass texture #declare T_Paint=texture{pigment{ForestGreen*0.7} finish{ambient 0 specular 1 roughness 0.05}} // paint texture //#declare SideDeco = height_field{gif "sidedeco.gif"} // decoration for lamp sides #declare SideDeco = box{0,<1,0.1,1>} // minimum side decoration #declare Lamp_On=object{MakeStreetLamp(Type_Lamp,Light_OK,C_Light,Area_OK,Halo_OK,Halo_Size,Halo_Turb,Halo_Strength,Fade_Distance,T_Glass,T_Paint)} #declare Lamp_Off=object{MakeStreetLamp(Type_Lamp,0,C_Light,Area_OK,0,Halo_Size,Halo_Turb,Halo_Strength,Fade_Distance,T_Glass,T_Paint)} object{Lamp_On rotate y*35 translate -x*2.5} object{Lamp_Off rotate y*35 translate x*2.5} plane{y,0 texture{pigment{White*0.3} finish{ambient 0 diffuse 1}}} box{<-0.0001,-1,-29>,<0.0001,1000,100000> hollow texture{pigment{White} finish{ambient 0 diffuse 0}}} union{ box{<-100,-1,0>,<0,200,1> texture{pigment{rgb <0,0,0.3>} finish{ambient 1 diffuse 0}}} box{<100,-1,0>,<0,200,1> texture{pigment{bozo turbulence 0.5 lambda 3 color_map{[0.1 White][0.5 rgb <150,201,255>/255]}} finish{ambient 1 diffuse 0}}} translate z*20 }