// Last edited on 2019-07-17 03:32:35 by stolfilocal
// Processed by remove-cam-lights

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

#declare tx_plastico_branco =
  texture{
    pigment{ color rgb < 1.0, 1.0, 1.0 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_plastico_preto =
  texture{
    pigment{ color rgb < 0.0, 0.0, 0.0 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_plastico_vermelho =
  texture{
    pigment{ color rgb < 0.90, 0.20, 0.10 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_plastico_azul =
  texture{
    pigment{ color rgb < 0.1, 0.2, 0.9 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#macro bola (raio, centro, textura)
  sphere{
    centro,
                raio
    texture{ textura }
  }
#end

#declare bola_unit =
  sphere{
    <0, 0, 0>,
                0.05
    texture{ tx_plastico_vermelho }
  }

#declare x0 = -5; // posição final
#declare x1 = 5;  // posição inicial

#macro circulo (raioS, raioC, start, stop, passo)
                union{
                        #for (i, start, stop, passo)
                                        #declare centro = raioC * <0, cos(2 * pi * i), sin(2 * pi * i)>;

                                        object{ bola(raioS, centro, tx_plastico_vermelho) }
                        #end // end while
                }
#end

#macro palito (raio, p0, p1, passo)
                union{
                        #for (i, -1, 1, passo)
                                        #declare centro = p0 + i * p1;

                                        object{ bola(raio, centro, tx_plastico_vermelho) }
                        #end // end while
                }
#end

#macro interplin (p0, t0, p1, t1, tt)
        #local r = (tt - t0) / (t1 - t0);
        #local s = 1 - r;
        #local vv = s * p0 + r * p1;
        vv
#end // end interplin

#macro bezier (A, B, C, D, tt)
        #local AB = interplin(A, 0, B, 1, tt);
        #local BC = interplin(B, 0, C, 1, tt);
        #local CD = interplin(C, 0, D, 1, tt);

        #local ABC = interplin(AB, 0, BC, 1, tt);
        #local BCD = interplin(BC, 0, CD, 1, tt);

        #local ABCD = interplin(ABC, 0, BCD, 1, tt);

        ABCD

#end // end bezier

#macro quadrado (passo)
                union{
                        #for (i, 0, 1, passo)
                                object{ bola_unit translate interplin(<0, 0, 0>, 0, <0, 0, 1>, 1, i)}
                                object{ bola_unit translate interplin(<0, 0, 0>, 0, <0, 1, 0>, 1, i)}
                                object{ bola_unit translate interplin(<0, 1, 0>, 0, <0, 1, 1>, 1, i)}
                                object{ bola_unit translate interplin(<0, 1, 1>, 0, <0, 0, 1>, 1, i)}
                        #end // end while
                }
#end

#macro cubo (passo)
        union{
                object{ quadrado(passo) }
                object{ quadrado(passo) translate <0, -1, 0> rotate <0, 0, 90> }
                object{ quadrado(passo) translate <1, -1, 0> rotate <0, 0, 90> }
                object{ quadrado(passo) translate <1, 0, 0> }
        }
#end

#macro suavizaX(P, N, i)

        #local j = mod(i + 1, N);
        #local vv = (P[j][1] - P[i][2]) / 2;
        #declare P[i][2] = P[i][3] - vv;
        #declare P[j][1] = P[j][0] + vv;
#end // end suavizaX

        #declare P = array[6][4];

        #declare P[0][0] = <-1, -1, -0.5>;
        #declare P[0][1] = <-0.75, -0.75, -0.2>;
        #declare P[0][2] = <0.3, 0, 0.75>;
        #declare P[0][3] = <0.75, 0.75, 0.5>;

        #declare P[1][0] = <0.75, 0.75, 0.5>;
        #declare P[1][1] = <0.55, 0.55, 0.2>;
        #declare P[1][2] = <0.3, 0.3, -0.5>;
        #declare P[1][3] = <0, 0, -0.75>;

        #declare P[2][0] = <0, 0, -0.75>;
        #declare P[2][1] = <-0.3, -0.3, -0.5>;
        #declare P[2][2] = <-0.55, -0.55, 0.2>;
        #declare P[2][3] = <-0.75, -0.75, 0.5>;

        #declare P[3][0] = <-0.75, -0.75, 0.5>;
        #declare P[3][1] = <-3, 0, 0.75>;
        #declare P[3][2] = <0.75, 0.75, -0.2>;
        #declare P[3][3] = <1, 1, -0.5>;

        #declare P[4][0] = <-1, -1, -0.5>;
        #declare P[4][1] = <-0.85, -0.85, 0.7>;
        #declare P[4][2] = <-0.75, -0.75, 0.9>;
        #declare P[4][3] = <0, 0, 1.0>;

        #declare P[5][0] = <1, 1, -0.5>;
        #declare P[5][1] = <0.85, 0.85, 0.7>;
        #declare P[5][2] = <0.75, 0.75, 0.9>;
        #declare P[5][3] = <0, 0, 1.0>;

        suavizaX(P, 6, 0)
        suavizaX(P, 6, 1)
        suavizaX(P, 6, 2)
        suavizaX(P, 6, 3)
        suavizaX(P, 6, 4)
        suavizaX(P, 6, 5)

        #for (i, 0, 1, 0.001)
                object{ bola_unit
                                                translate bezier(P[0][0], P[0][1], P[0][2], P[0][3], i)
                                        }

                object{ bola_unit
                                                translate bezier(P[1][0], P[1][1], P[1][2], P[1][3], i)
                                        }

                object{ bola_unit
                                                translate bezier(P[2][0], P[2][1], P[2][2], P[2][3], i)
                                        }

                object{ bola_unit
                                                translate bezier(P[3][0], P[3][1], P[3][2], P[3][3], i)
                                        }

                object{ bola_unit
                                                translate bezier(P[4][0], P[4][1], P[4][2], P[4][3], i)
                                        }

                object{ bola_unit
                                                translate bezier(P[5][0], P[5][1], P[5][2], P[5][3], i)
                                        }
        #end

#include "eixos.inc"
//object{ eixos(1.0) }

#include "camlight.inc"
#declare centro_cena = < 0.0, 0.0, 0.2 >;
#declare raio_cena = 2.7;
#declare dir_camera = < 45, -50, 60 >;
#declare dist_camera = 5*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)