/************************************************************** * LEDS include file for the Persistance of Vision Ray Tracer * * part of the ELECTRONICS set * ************************************************************** * * Created by Mark Hanford, December 2001 * * * LED(Color, Lit) * Creates a simple LED. The colour is detemined by the * vector Color. * If Color.red is >0 then the LED is red * If Color.green is >0 then the LED is green * If Color.red and Color.green are >0 then the LED is yellow * If Lit is > 0 then the LED will illuminate. * * Dependencies * electronics.inc - mainly for some constants * * Optimisation options: * There's not much to optimise on this object yet, this may change... * * Base units: millimetres **************************************************************/ /******************************************** * Check for and set some default variables * ********************************************/ #ifdef(View_POV_Include_Stack) #debug "including leds.inc\n" #end #ifdef (MH_LEDs_Inc_Temp) //do nothing #else #declare MH_LEDs_Inc_Temp=1; #include "electronics.inc" /************ * Textures * ************/ #declare T_LEDr= texture{ pigment{color rgbf<1, 0, 0, 0.5>} finish{ phong 0.8 phong_size 160 ambient 0.2 diffuse 0.4 } } #declare T_LEDg= texture{ pigment{color rgbf<0, 1, 0, 0.5>} finish{ phong 0.8 phong_size 160 ambient 0.2 diffuse 0.4 } } #declare T_LEDy= texture{ pigment{color rgbf<1, 1, 0, 0.5>} finish{ phong 0.8 phong_size 160 ambient 0.2 diffuse 0.4 } } #declare T_Legs = texture{pigment{color Silver} finish{phong 1}} /************* * Constants * *************/ /******************* * A Basic 5mm LED * *******************/ #macro LED(Color, Lit) union{ merge{ //the plastic top difference{ cylinder{<0, 0, 0>, <0, 1.01, 0>,2.8} //base box{<-3, -0.1, -1.5>, <-2.6, 1.1, 1.5>} //the -ve flat } cone{<0, 1, 0>, 2.5, <0, 6.31, 0>, 2.35} //body sphere{<0, 6.30, 0>, 2.35} //top #if (Color.red=1) #if (Color.green=1) texture{T_LEDy} #else texture{T_LEDr} #end #end #if (Color.green=1) #if (Color.red=1) texture{T_LEDy} #else texture{T_LEDg} #end #end } union{ prism{ linear_sweep linear_spline -0.25, 0.25, 20, // -ve <-1.6, -3.5>, <-1.6, 4.7>, <-1.3, 5.0>, < 0.8, 5.0>, <-0.2, 3.5>, <-0.9, 3.5>, <-0.9, -3.5>, <-1.6, -3.5>, // +ve < 0.9, -3.5>, < 0.9, 2.0>, <-0.5, 2.0>, <-0.5, 2.5>, < 0.7, 2.5>, < 1.8, 4.0>, < 1.8, 5.0>, < 2.2, 5.0>, < 2.2, 3.0>, < 1.6, 3.0>, < 1.6, -3.5>, < 0.9, -3.5> rotate -90*x } difference{ sphere{<0,0,0>, 2} box{<-2.1, -1.8, -2.1>, <2.1, 2.1, 2.1>} translate <0, 7, 0> } texture{T_Legs} } #if (Lit=1) light_source { 0*x color rgb <1,1,1>*2 fade_distance 10 fade_power 2 translate <0, 5.5, 0> } #end translate <1, 1, 0> } #end /************* * Finish up * *************/ #end