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 processing.py

Tuesday, 28 December 2010

Simple Export DXF example using a modified supercad library

The great thing about povray is it is very human readable, and providing that use declarations to declare say color / pigment / texture / material / finish you can readily post edit the file exported by processing (even easier if you have a template file that can be edited, rather than one that is hard coded). My modified supercad library has such a feature, here is a library example taken from the the processing core library that supports DXF export. Povray does complain a bit about degenerative triangles (but they just don't get drawn) with my modified library (no kludge factor), however sketch renders fine. However this sketch would render better if I translated the sphere primitives directly into a povray script, rather than as triangle mesh.
 I've been taking a look at the yafaray-xml renderer, which can be integrated into blender which should be much faster, haven't managed to compile a yafaray-xml that is integrated with blender yet!!!


import supercad.povwriter.*;
import supercad.*;

String cadSoftware, ext;
boolean record = false;

void setup() {
  size(400, 400, P3D);
  noStroke();
  sphereDetail(12);
}

void draw()
{  
  if(record) {
    noLoop();
    beginRaw("supercad."+cadSoftware, "output."+ext);
  }
  lights();
  background(0);
  translate(width / 3, height / 3, -200);
  rotateZ(map(mouseY, 0, height, 0, PI));
  rotateY(map(mouseX, 0, width, 0, HALF_PI));
  for (int y = -2; y < 2; y++) {
    for (int x = -2; x < 2; x++) {
      for (int z = -2; z < 2; z++) {
        pushMatrix();
        translate(120*x, 120*y, -120*z);
        sphere(30);
        popMatrix();
      }
    }
  }
  if (record) {
    endRaw();
    record = false;
    loop();
  }
}


void keyPressed() {

  switch(key) {
  case 'r': 
    cadSoftware = "Rhino"; 
    ext = "rvb"; 
    break;
  case 's': 
    cadSoftware = "SketchUP"; 
    ext = "rb";
    break;
  case 'a': 
    cadSoftware = "AutoLISP"; 
    ext = "lsp";
    break;
  case 'p': 
    cadSoftware = "PovRAY";    
    ext = "pov";  
    break;
  case 'm': 
    cadSoftware = "Maya"; 
    ext = "mel";
    break; 
  case 'o': 
    cadSoftware = "ObjFile"; 
    ext = "obj";
    break;       
  case 'c': 
    cadSoftware = "ArchiCAD"; 
    ext = "gdl";
    break;
  }  
  record = true;
}


No comments:

Post a Comment

Followers

Blog Archive

About Me

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