// Last edited on 2003-10-22 04:13:27 by stolfi
// ============================================================================
// MC930A - Computacao Grafica    =============================================
// Eduardo Uemura Okada RA 001606 =============================================
// Laboratorio 03                 =============================================
// ============================================================================

global_settings { max_trace_level 10 }

// ============================================================================
// Camera e Iluminacao ========================================================
// ============================================================================

background { color rgb <1,1,1> }

#declare ctr = < 0.00, 1.00, -7.50 >;
#declare camdir = < 10.00, 10.00, 30.00 >;

camera {
  location  ctr + 1.00*camdir  // Posição do observador.
  right     -1.00*x
  up        0.75*y
  sky       y                      // Qual direção é "para cima"?
  look_at   ctr  // Para onde a câmera está apontando.
}

light_source {
  100 * <-7,15,-3>
	color rgb 1.2*<1,1,1>
}

light_source {
  100 * <-3,20,10>
	color rgb 0.5*<1,1,1>
}

// ============================================================================
// Declaracao de Propriedades =================================================
// ============================================================================

#declare cor_cristala = <0.2,0.2,0.8>;
#declare cor_cristalb = <0.8,0.2,0.05>;
#declare tx_cristala =
	texture {
		finish {
			ambient 0.1 diffuse 0.1
			reflection 0.25
			specular 1 roughness 0.001
		}
		pigment { color cor_cristala filter 1 }
	}

#declare tx_cristalb =
	texture {
                finish {
                        ambient 0.1 diffuse 0.1
                        reflection 0.25
                        specular 1 roughness 0.001
                }
                pigment { color cor_cristalb filter 1 }
        }


#declare cor_espelho = <0.3,0.3,0.3>;
#declare tx_espelho =
	texture {
		finish {
			ambient 0.05 diffuse 0.05
			reflection cor_espelho
			specular 0.20 roughness 0.05
		}
		pigment { rgb cor_espelho }
	}

// ============================================================================
// Declaracao de objetos ======================================================
// ============================================================================

// Caixa 10x5x5
#declare caixafrontal =
	box {
		< -6, -2.5, -2.5 >
		< 6, 2.5, 2.5 >
	}

#declare semiportafrontal =
	box {
		< -1, -1.5, -1 >
		< 1, 1.5, 1 >
	}

#declare paredelateral =
	box {
		< -2.5, -2.5, -6 >
		< 2.5, 2.5, 6 >
	}

#declare prisma =
	prism {
		linear_sweep
		linear_spline
		0,
		10,
		3,
		<0,0>, <0.5,1>, <1,0>
	}

#declare toroide =
	torus {
		1.7, 1
	}

#declare cilindro =
	cylinder {
		< 0, -3.5, 0 >,
		< 0, 3.5, 0 >,
		2.5
	}

#declare conico =
	cone {
		< 0,0,0 >, 2.5
		< 0,3,0 >, 0
	}

#declare esfera =
	sphere {
		< 0,0,0 >, 5
	}

#declare cortaesfera =
	box {
		< -7, -7, -7 >
		< 7, 7, 7 >
	}

#declare fatiaesfera_aux =
	difference {
		object { esfera }
		object { cortaesfera translate < 0, 0, 9.45 > }
	}

#declare fatiaesfera =
	difference {
		object { fatiaesfera_aux }
		object { cortaesfera translate < 0, 0, -9.45 > }
	}


// ============================================================================
// Montagem de pecas ==========================================================
// ============================================================================

#declare torre1 =
	union {
		object { cilindro translate < -7.5, 0, 0 > texture { tx_cristala } interior { ior 1.5 } }
		object { toroide translate < -7.5, 4, 0 > texture { tx_espelho } interior { ior 1.5 } }
		object { conico translate < -7.5, 4.5, 0 > texture { tx_cristalb } interior { ior 1.5 } }
	}

#declare torre2 =
	union {
		object { cilindro translate < 7.5, 0, 0 > texture { tx_cristala } interior { ior 1.5 } }
		object { toroide translate < 7.5, 4, 0 > texture { tx_espelho } interior { ior 1.5 } }
		object { conico translate < 7.5, 4.5, 0 > texture { tx_cristalb } interior { ior 1.5 } }
	}

#declare torre3 =
	union {
		object { cilindro translate < -7.5, 0, -15 > texture { tx_cristala } interior { ior 1.5 } }
		object { toroide translate < -7.5, 4, -15 > texture { tx_espelho } interior { ior 1.5 } }
		object { conico translate < -7.5, 4.5, -15 > texture { tx_cristalb } interior { ior 1.5 } }
	}

#declare torre4 =
	union {
		object { cilindro translate < 7.5, 0, -15 > texture { tx_cristala } interior { ior 1.5 } }
		object { toroide translate < 7.5, 4, -15 > texture { tx_espelho } interior { ior 1.5 } }
		object { conico translate < 7.5, 4.5, -15 > texture { tx_cristalb } interior { ior 1.5 } }
	}

#declare fundo =
	union {
		object { caixafrontal translate < 0, 0, -15 > texture { tx_cristala } interior { ior 1.5 } }
	}

#declare ladoesquerdo =
	union {
		object { paredelateral translate < -7.5, 0, -7.5 > texture { tx_cristala } interior { ior 1.5 } }
	}

#declare ladodireito =
	union {
		object { paredelateral translate < 7.5, 0, -7.5 > texture { tx_cristala } interior { ior 1.5 } }
	}

#declare frente =
	union {
		object { fatiaesfera translate < 0, 2.5, 0 > texture { tx_cristala } interior { ior 1.5 } }
		object { caixafrontal translate < 0, 0, 0 > texture { tx_cristala } interior { ior 1.5 } }
		object { semiportafrontal translate < -1.038, -1.5, 2 > texture { tx_cristalb } interior { ior 1.5 } }
		object { semiportafrontal translate < 1.038, -1.5, 2 > texture { tx_cristalb } interior { ior 1.5 } }
	}

// ============================================================================
// Composicao da Cena =========================================================
// ============================================================================

plane { <0,1,0>, -2.5
  pigment { checker color rgb < 1.0,1.0,1.0 >,  color rgb < 0.8,0.8,0.8 > } }
object { torre1 }
object { torre2 }
object { torre3 }
object { torre4 }
object { fundo }
object { ladoesquerdo }
object { ladodireito }
object { frente }
object { fatiaesfera }