// Last edited on 2013-12-11 09:20:18 by stolfilocal
// Processed by remove-cam-lights
#include "textures.inc"
#include "eixos.inc"
#include "camlight.inc"

background{ color rgb < 0.75, 0.80, 0.85 > }

#declare tx_plastico =
  texture{
    pigment{ color rgb < 0.10, 0.80, 1.00 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_plastico =
  texture{
    pigment{ color rgb < 0.10, 0.80, 1.00 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_fosca =
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.2 }
  }

#declare tx_red=
  texture{
    pigment{ color rgb < 1.00, 0.0, 0.0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_vidro =
  texture{
    pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 }
    finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 }
  }

#declare tx_glass =
  texture{
    pigment{color rgb < 0.8, 0.8, 1 > filter 0.90 }
    finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.01 roughness 0.005 }
  }

#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#declare raio = 5.000;

// #macro calc_retalho(p11,p12,p13,p14,p21,p22,p23,p24,p31,p32,p33,p34,p41,p42,p43,p44,q11,q12,q13,q14,q21,q22,q23,q24,q31,q32,q33,q34,q41,q42,q43,q44,rad,txg,txr)
//   retalho (p21+q31/2,p22+q32/2,p23+q33/2,p24+q34/2,p21,p22,p23,p24,p31,p32,p33,p34,p41,p42,p43,p44, rad,txg,txr)
// 
//   retalho (q11,q12,q13,q14,q21,q22,q23,q24,q31,q32,q33,q34,p21+q31/2,p22+q32/2,p23+q33/2,p24+q34/2, rad,txg,txr)
// #end

#declare chao =
  box{ <-20,-20,-1>, <+20,+20,0>
        translate <0,0,2>}

#declare roda =
difference {
        union {
                cylinder{
                        < 0.00, +0.00, +0.00 >,
                        < 0.00, +0.00, +1.50 >,
                        0.75
                        rotate <0,270, 0>
                        texture { tx_red}
                }
                cylinder{
                        < 0.00, +0.00, +0.75 >,
                        < 2.85, +0.00, +0.75 >,
                        0.25
                        rotate <0,270, 0>
                }
        }
        cylinder{
                < 0.00, +0.00, -1.00 >,
                < 0.00, +0.00, +1.60 >,
                0.5
                rotate <0,270, 0>
                texture { tx_red}
        }
}

#macro Interpola2(p0,p1,tt)
   ((1-tt)*p0 + tt*p1)
#end

#macro Interpola4 (p0,p1,p2,p3,tt)
   #local p01 = Interpola2(p0, p1,tt);
   #local p12 = Interpola2(p1, p2,tt);
   #local p23 = Interpola2(p2, p3,tt);
   #local p012 = Interpola2(p01, p12,tt);
   #local p123 = Interpola2(p12, p23,tt);
   #local p0123 = Interpola2(p012, p123,tt);
   p0123
#end

#macro tentaculo (p0,p1,p2,q1,q2,q3)
    #local p3 = (p2+q1)/2;
    #local q0 = p3;

    union {
            #local i =0;
            #while (i<1)
                        sphere {
                                Interpola4(p0,p1,p2,p3,i),
                                Interpola4(0.1,0.2,0.3,0.4,i)
                                texture{ tx_red}
                        }
                #local i = i + 0.01;
             #end

            #local i =0;
            #while (i<1)
                        sphere {
                                Interpola4(q0,q1,q2,q3,i),
                                Interpola4(0.4,0.45,0.5,0.55,i)
                                texture{ tx_red}
                        }
                #declare i = i + 0.01;
             #end
    }
#end

#macro polvo ()
union {
        tentaculo (<0,0,0>,<0,1,1>,<0,-1,2>,<0,1,2.2>,<0,0.5,2.5>,<0,1,3>)
        object{tentaculo (<0,0,0>,<0,1,1>,<0,-1,2>,<0,1,2.2>,<0,0.5,2.5>,<0,1,3>)
                rotate <0,0,180>
                translate <0,2,0 >
        }
        object{tentaculo (<0,0,0>,<0,1,1>,<0,-1,2>,<0,1,2.2>,<0,0.5,2.5>,<0,1,3>)
                rotate <0,0,90>
                translate <1,1,0 >
        }
        object{tentaculo (<0,0,0>,<0,1,1>,<0,-1,2>,<0,1,2.2>,<0,0.5,2.5>,<0,1,3>)
                rotate <0,0,-90>
                translate <-1,1,0 >
        }
        sphere {<0,1,3> 1 texture {tx_red}}
}

tentaculo (<0,0,0>,<0,1,1>,<0,-1,2>,<0,1,2.2>,<0,0.5,2.5>,<0,1,3>)

#end

  object{ chao  translate < 0,0,-5 > texture{ tx_xadrez } }

polvo()

declare centro_cena = < 2, -1.5, 1 >;
#declare raio_cena = 7;
#declare dir_camera = < 2,-1,0 >;
#declare dist_camera = 15;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)