domingo, 9 de febrero de 2014

RENDER - DE STL A POV-RAY

PASAR STL A POV-RAY PARA RENDERIZAR




Hoy os paso la receta para renderizar vuestros objetos 3D en POV-RAY, partiendo de un STL.

Para ello, necesitamos 3 cosas:

1) POV-RAY actualmente en su version 3.7 y que podéis descargar de su pagina oficial. http://www.povray.org/
2) STL2POV, podeis suponer que para crear la escena en POV a partir del STL y que podeis descargar de aquí.  http://solidworks.cad.de/download/stl2pov.zip
3) Un STL. :) En este ejemplo, partiremos del llavero para la printer party de Leon. http://www.thingiverse.com/thing:243332

El sistema es facil.
Ejecutamos STL2POV

Los pasos, son sencillos:
1) Seleccionamos el directorio donde tenemos el STL.
2) Seleccionamos el STL
3) Pulsamos a GO, Le decimos donde queremos guardar el resultado y esperamos que termine.
Este proceso nos genera dos ficheros:
un fichero de tipo .INC donde estara la pieza en formato POV-RAY
un fichero de escena con extension .POV

Ahora, abrimos POV-RAY y cargamos nuestra escena.

El resultado, es simplemente "PENOSO", pero no pasa nada, lo mejoramos ahora.

Primero cambiamos la posición de la camara.  location  <-20 .0="" 40.0="">

//typical camera
camera {
  location  <-20 .0="" 40.0="">
  // SW uses right-handed-coordinates, so if you want POV
  // to use it uncommend the following line
  //right <-1 .33="" 0="">
  look_at   <0 .0="" 0.0="">
}
Le aplicamos una textura metalica.

#include "CWL6.inc"
object {// Assembly
  union { // to take control of assembly
    object { // SW_Mesh_1
      // is File E:\@@REPRAP\@Objetos para imprimir\@@LEON 3D\CWL6.inc
      SW_Mesh_1
      // to access every single Part 
      texture{ pigment {Black} finish { ambient 0.3 diffuse 0.9 specular 0.5 brilliance 0.6 roughness 0.05 reflection {5.5 metallic}}}
    }
  } // close union
  // sample transaltion of assembly 
  translate <0 0="">
} // close object

Y la cosa cambia un poco.


Y si lo que queremos es un render como el de la portada, solo tenemos que aplicar esta escena:

// POV Scene File
// from STL2POV  (c) 1998 by Stefan Berlitz
// File: E:\@@REPRAP\@Objetos para imprimir\@@QUAD\CacerFramev4.pov
// Date: 02/02/2014 22:41:51

// Standard pre-defined colors
#include "colors.inc"
#include "textures.inc" 

// Set default textures for shapes to come
default {
   finish {
      ambient 0.5     // Unusually high ambient setting.
      diffuse 0.5     // Unusually low diffuse setting.
      reflection 0.15
      specular 0.25 roughness 0.001
   }
}   

global_settings {
  assumed_gamma 1.0 
  max_trace_level 5
}


/*
plane { -z, -600
    pigment { Black }
    finish { Dull }
}  

*/ 

// Ground plane
plane { y, -5
   pigment {Black}
   finish {
      ambient 0.3
      diffuse 0.7
      specular 0.5  roughness 0.05
   }
}

#declare SphereTexture = texture {
    pigment { Red }
    finish { Shiny }
}


//typical camera
camera {
  location  <0 .0="" 100.0="">
  // SW uses right-handed-coordinates, so if you want POV
  // to use it uncommend the following line 
  angle 35
  right <-1 .33="" 0="">
  look_at   <0 .0="" 0.0="" 30.0="">
}

// create a regular point light source
light_source
{
  0*x                 // light's position (translated below)
  color White         // light's color
  translate <-2000 -2000="" 4000="">
}
                      

light_source {
    <200 200=""> color White
    area_light <8 0="">, <0 0="" 8="">, 5, 5
    adaptive 0
    jitter

    spotlight
    point_at <-20 0="">
    tightness 2
    radius 1
    falloff 11
}                   
                      
// Create an infinite sphere around scene and allow any texture on it
sky_sphere {
  pigment {
    gradient y
    color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }
  }
}     
      
      
//sphere {<120>,30  pigment {Black} finish { ambient 0.3 diffuse 0.9 specular 0.5 brilliance 0.6 roughness 0.05 reflection {5.5 metallic}}}

#include "CWL6.inc"
object {// Assembly
  union { // to take control of assembly
    object { // SW_Mesh_1
      // is File E:\@@REPRAP\@Objetos para imprimir\@@QUAD\CacerFramev3.inc
      SW_Mesh_1
      // to access every single Part  
      rotate 00*x 
      rotate 15*y

             
       texture{ pigment {Black} finish { ambient 0.3 diffuse 0.9 specular 0.5 brilliance 0.6 roughness 0.05 reflection {5.5 metallic}}}
      
      }  
    
  } // close union
  // sample transaltion of assembly 
  translate <0 0="" 25="">
} // close object