Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and

Thursday, 5 April 2012

Exporting to PovRAY from pyprocessing

In my previous blog post, I published a menger pyprocessing sketch where the geometry was created on the fly. In this case the "cubes" of the menger were created with a beginShape(QUADS), endShape() block. I figured it might be quite interesting to create all the geometry (much in the same way as you do with toxiclibs) first then just do the rendering in the draw() loop. You can see the code at GitHub don't forget to look in the util folder, for the helper classes (Cube and Vec3D) in the util module. Most of the logic for rendering a cube is encapsulated in the file. The re-factored menger is now rendered in a beginShape(TRIANGLES) endShape() block, this made it pretty easy to apply the knowledge I picked up creating my povmesh library (that exports from toxiclibs sketches in vanilla processing to PovRAY) to exporting the menger as a union of PovRAY mesh 2 objects to a file which rendered pretty damn quick (1.5 minutes) using the following menger.ini and menger.pov files.  The save file is configured for export alone,  a lower size of 10 is only suitable for export use say 40 for pyprocessing/pyglet rendering.

; menger.ini high quaility setting set quality = 5 say for preview


// Persistence Of Vision Ray Tracer Scene Description File
// File:  Simple Scene for pyprocessing export (geometry from
// Vers: 3.7
// Date: April 2012
// Auth: Martin Prout 

// +w1280 +h1024

#version 3.7;

  assumed_gamma 1.0
    pretrace_start 0.04
    pretrace_end 0.01
    count 200
    recursion_limit 3
    nearest_count 10
    error_bound 0.5

#include ""
#include ""

//----------------begin declare finish

#declare Finish0=finish{diffuse 0.75 emission 0}  // Stroke
#declare Finish1=finish{diffuse 0.78 emission 0}  // Cornell Box Light Patch
#declare Finish2=finish{emission 0.1 phong 0.5 phong_size 10.0}   // Processing object finish

//----------------end declare finish

//----------------begin declare texture

#declare WhiteT=texture{pigment{White} finish{Finish2}} //

//----------------end declare texture

//----------------declare scene Settings
#declare camera0 = camera {            // define additional cameras to suit viewing preferences
   location <-1.5, 30.0, -150.0>
   direction <0.0, 0.0, 2.0>
   up  <0.0, 1.0, 0.0>
   right <1.25, 0.0, 0.0>
   look_at <0.0, 25.0, 35.0>

#declare light0 = light_source { <100.0, 100.0, -200.0> colour White }

#declare ground0 = plane { <0.0, 1.0, 0.0>, 0.0  // a reflective ground plane
   pigment { NeonBlue }
   finish {reflection 0.15}

//------------------end of declare scene settings

// -----------------set the scene

camera { camera0 }              // ------------------------------------------
                                //  The use of declared values makes it possible to easily 
light_source{ light0 }          //  change the way the scene is rendered. Just define an
                                //  additional camera say for your template, and do the
sky_sphere{ S_Cloud3 }          //  substitution here. Retain the original definition and
                                //  you can easily backtrack. Definitions can also be saved
plane{ ground0 }                //  as included file see for an example.
                                // ---------------------------------------------  
// -----------------end set the scene
#include ""
#include ""

union{ mesh_objects
texture{ WhiteT }
scale<0.5, 0.5, 0.5>
rotate<20, 45, 0>
translate<0, 65, 400>
Here's the PovRAY rendered menger
Click on Image to see Full Size

No comments:

Post a Comment


Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby- and processing-3.2.2