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

Friday, 29 April 2011

Exploring Transparency in Povray

Here is yet another processing sketch using the hemesh library exported to PovRAY original here. I was interested to see how I could achieve the transparency of the original sketch. It seem that what you want to do, is replace "transparent colors" with "opaque colors" in the PovRAY file and use the transmit or filter settings to control the transparency see PovRAY file fragment:-
#declare ColourT0 = color rgbf< 92, 1, 1, 70>/255;
#declare ColourT0 = color rgb< 92, 1, 1>/255;    //becomes
texture{ pigment{ ColourT0 }
texture{ pigment{ ColourT0 transmit 0.7 }   // becomes

"reconstructed" processing sketch exported to povray

Wednesday, 27 April 2011

ContextFree 3.0 Alpha has been released

So far so good with my testing of context free 3.0 alpha, new features include the ability to define constants see the  proposed syntax changes here I have just uploaded a revised syntax highlighting mode at jedit.
Revised version 26 June 2011 for latest changes to syntax (linux v12):-

PHI = (sqrt(5) + 1)/2   
startshape sunstar
CF::Size = [s 0.7 0.7 x 0 y 0]  // trim to hide full shape
shape sunstar{ 
  star[z -1]
  sun[z -0.9]
  sunstar[s IPHI z 0.1]
shape sun{
  loop 5 [r 72]kite[]  
shape star{
  loop 5 [r 72]dart[]  
shape kite {                    
  sharp[b 0.9 sat 1]
  sharp[flip 72]
shape dart {
  flat[b 0.9 sat 1]
  flat[flip 36]

path sharp {     
    LINETO(1, 0)                  
    LINETO(cos(36), sin(36))
    FILL [b 0.7 sat 0.8 h 0]
    STROKE [width 0.01 b -1]
path flat {
    LINETO((cos(36) * PHI), (sin(36) * PHI))
    LINETO(1, 0)
    FILL [b 0.7 sat 0.8 h 60]
    STROKE [width 0.01 b -1]

Saturday, 23 April 2011

More Hemesh Library Processing Sketches Exported To PovRAY

Here is another example of my povwriter processing to PovRAY export tool. Features another Hemesh Library example. Rendered using PovRAY 3.7 Beta, after export using my povwriter library version 0.56.
To get the custom modifier sketch to run with processing 1.5 I needed to modify the code.

Here are the modifications I made
Basically I commented out the package line and used the full address for the HEM_Modifier class.

//specifying package wblut.hemesh allows access to protected members of HE_Mesh and other elements
//package wblut.hemesh.modifiers;

import java.util.Iterator;

import wblut.hemesh.HE_Mesh;
import wblut.hemesh.HE_Selection;
import wblut.hemesh.HE_Vertex;
import wblut.geom.WB_Point;

public class HEM_Noise extends wblut.hemesh.modifiers.HEM_Modifier {

A Mesh Selection Sketch by W:Blut rendered in PovRAY
Custom Modifier Sketch by W:Blut rendered in PovRAY

Friday, 22 April 2011

ANAR+ Tower Processing Sketch Rendered in Povray

Coals to Newcastle comes to mind here is an ANAR+ sketch exported to PovRAY format using my povwriter library.

Anar+ Tower Sketch rendered by PovRAY

Combining PovRAY primitives with exported processing sketch

Ultimately my library may support the direct export of primitives from a processing sketch (sphere, box, cone etc). The reason that this is attractive is that PovRAY supports these primitives pretty well (spheres for example, see below, are rendered much more nicely than the Mesh alternative). For now you can easily post edit the povray file, and if you add primitives within the 'processing sketch union' sizes etc will match the processing sketch.  Here is the 'pov' code I used to a primitive sphere to the Hemesh cage example (see W:Blut for more exciting hemesh stuff.):-

    sphere{<0, 200, 1000>, 400}
    texture{ pigment{ color Silver }
  finish{ F_MetalE } } }

Here is the resulting image:-

Hemesh cage processing sketch rendered using PovRAY. Sphere primitive added in post export edit.

Thursday, 21 April 2011

A simple fix for my Povwriter library (but with enhancements)

Thanks very much to velvetkevorkian for testing my povwriter library. Here is one for him:-
The latest version of my library version 0.56 can do this, and now features a JFileChooser front end, for choosing template files.
povray rendered MeshFaceExtrude, using Cornell Box template

Povray rendered SuperEllipsoidMeshBuilder  processing sketch by toxi

Tuesday, 12 April 2011

Povwriter Library Memory Issues

Over on the processing discussion boards there has been identified a possible memory issue with my povwriter library for the following sketch which was originally rendered 1280*1024 in processing it was necessary to increase max memory of the processing ide from 1024 to 2024MB.  Here is the post-edited file rendered in PovRAY, where White color was changed to silver, and the finish of sphere changed to F_MetalE.  Update 13th April 2011 I'm working on a proper fix (by writing object data to a tmp file on the fly). The below sketch is slight variant (extra enclosed sphere) of one of the processing library hemesh examples by Frederik Vanhoutte aka W Blut . Don't you just love the open source community....

Update 15th April 2011 I have now published a potential bug-fix (memory issues) version 0.55 at, that definitely uses less memory however, if you are pushing the envelope apparently there is still an issue see discussions at contributed libraries forum at (join the discussions there or file a bug a if you have any issues). Update 23 April, see improved version, where sphere is added, after export as a PovRAY sphere primitive (it should be possible to to this within processing sketch, would need to suppress sphere rendering in sketch for export). Version of 0.56 should fix bug (version 0.55 was an incomplete fix).

Monday, 11 April 2011

Povwriter Library Now Revised to version 0.54

Library bundle now includes javadocs (somewhat crudely annotated for the most part) and I am offering template files in a separate zip file.  For those that don't know where to place the 'orginal.pov' template, the first time the library is run (or whenever the {HOME}/original.pov file is missing) a dummy output is produced, that includes the path for you system as determined by the absolute path function.
Here is a example of 3D processing sketch just using stroke (noFill(), the processing rendering looks crap). Beefing up the PovRAY line width (to 20 in this case), the image is then rendered as a collection of PovRAY primitives ie cylinders. I would like to implement spheres primitives (StructureSynth does this), but that is a very long way off, if it ever happens.
NB: in the below output I used the PovRAY "Chrome_Metal" texture and "Silver" color for the cylinders (a post edit of the "output.pov"), thanks to Guillaume LaBelle superCAD library for idea to use cylinders for line.

import lsystem.turtle.*;
import lsystem.collection.*;
import lsystem.*;
import povexport.*;
import povexport.povwriter.*;

boolean record = false;
Grammar grammar;
float distance = 30;
int depth = 4;
float THETA = radians(90);
float PHI = radians(90);
float theta = 0;
float phi = 0;
String production = "";

void setup() {
  size(640, 512, P3D);

void draw() 
  translate(width * 0.6, height * 0.6, -width/3);
  background(0, 0, 26);
  stroke(0,  75,  152);
  if(record) {
    beginRaw(RawPovray.POV, dataPath("output.pov"));


  if (record) {
    record = false;

void keyPressed() {

   switch(key) {
  case 'r':    
    record = true;
  case 'e': 
    String[] args = {"/home/tux/bin/jedit", dataPath("output.pov")};
    try{    // open(args); just should work on processing but didn't for me
      java.lang.Runtime runtime = java.lang.Runtime.getRuntime();
    catch(IOException e){e.printStackTrace();}

void setupGrammar() {
  grammar = new SimpleGrammar(this,  "X");   
  grammar.addRule('X',  "^<XF^<XFX-F^>>XFX&F+>>XFX-F>X->");
  production = grammar.createGrammar(depth);

void render() {  
  CharacterIterator it = grammar.getIterator(production);
  for (char ch = it.first(); ch != CharacterIterator.DONE; ch = {
    switch (ch) {
    case 'F': 
      translate(distance/-2,  0, 0);
      line(-distance/2, 0, 0,  distance/2,  0, 0);
      translate(distance/-2,  0, 0);
    case '-':
      rotateY(-THETA); // juggle round Y and X to compensate for processing
    case '+':
      rotateY(THETA);  // oddball coordinate system  
    case '>':
    case '<':
    case '&':
    case '^':
    case 'X':
      System.err.println("character " + ch + " not in grammar");

A Chrome Hilbert, using povwriter and LSystem processing libraries.

Friday, 8 April 2011

Povwriter Library Now Launched (version 0.52)

After quite a bit of re-factoring I have announced the availability of my povwriter library for download/testing. The library has been found to work both Linux and Windows to date (both 64 bit, but that should not matter) and I've requested feedback from any Mac user prepared to give it a go. High on the to do list is to provide a means of selecting the template.pov file ('original.pov'). I will attempt to expand the list of stock templates, but think it might be nice to share (may'be I should have hosted the project on GitHub, these could easily be posted as a Gist), however integration with NetBeans to is the thing that swung choice of host for me.
I've had a re-think on selecting the template file, as my templates are essentially complete pov files it is fairly natural to render them say 300 * 300 at medium resolution then from PovRAY gui or jEdit linux users save the preferred template as 'original.pov'. Alternatively I could produce a set of thumbnails with a separate chooser/saver?

Friday, 1 April 2011

Developing and Using My Povwriter Library from NetBeans IDE

Here is my TestPov class that I've started to use to continue the development of my library that exports pov files, from a processing sketch, it is so easy to run directly from NetBeans. To speed the evaluation of the output pov file (a lot), the program automatically opens the file within jEdit. This allows me to edit the pov file as necessary with jEdit (which has syntax highlighting for PovRAY built in) and to launch PovRAY using my jEdit commando file (available as community download from jEdit). There are several quality options available when running povray choose medium for quick evaluation. To get radiosity to work select High or Highest Quality.

 * This class is only for testing purposes, however it also demonstrates
 * running a PApplet directly from NetBeans
 * Author Martin Prout
import java.util.logging.Level;
import java.util.logging.Logger;
import processing.core.PApplet;

public class PovTest extends PApplet {

    boolean record = false;

    public void setup() {
        size(400, 400, "processing.core.PGraphics3D");
        camera(200.0f, 200.0f, 600.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);

    public void draw() {
        if (this.record) {            
            beginRaw("povexport.RawPovray", "FTest.pov");
        if (this.record) {
            this.record = false;

    public void render() {        
        fill(255.0f, 0.0f, 0.0f);
        translate(0.0f, -50.0f, 0.0f);
        translate(50.0f, 0.0f, 0.0f);
        translate(-50.0f, -50.0f, 0.0f);
        translate(0.0f, -50.0f, 0.0f);
        translate(50.0f, 0.0f, 0.0f);

    public void keyPressed() {
        switch (key) {
            case 'r':
                this.record = true;
            case 'e':
                String[] jargs = {"/home/tux/bin/jedit", "FTest.pov"};
                Runtime runtime = Runtime.getRuntime();
                try {
                    if (this.record == false) {
                        runtime.exec(jargs); // open jedit with FTest.pov file
                } catch (IOException ex) {
                    Logger.getLogger(PovTest.class.getName()).log(Level.SEVERE, null, ex);

    public static void main(String[] strings) {
        PApplet.main(new String[]{"--bgcolor=#DFDFDF", "PovTest"});

Processing Sketch run from NetBeans

Medium Quality PovRAY rendering

It is of course quite possible to run jEdit directly from the processing ide using the 'open' function in place of the runtime.exec() (which is how open gets implemented), which is handy if you want to stick with the terse processing syntax...
If you are on Windows you probably can run the Povray-GUI directly? However as you currently need to edit the file (move colour declarations), you might as well use jEdit, and ignore the GUI for now......

NB: 'r' is record, 'e' is for launch editor....


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