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

Monday, 20 December 2010

Processing to Povray with 'Y' axis correction?

This post has been superceded by the next post however it does include the test sketch, and the upside down test 'T' povray rendered image. 

I created a simple 'T' in processing (using box primitives) as a test file, here I am using my modified supercad library for a funkier look (should work just as well with th original supercad library):-

   1 import povwriter.*;               // a modified superCad library
   2                                   // povray export only draws mesh (ignores lines)
   3 String cadSoftware, ext;
   4 boolean record = false;
   5 
   6 void setup() {
   7   noStroke();
   8   size(400, 400, P3D);
   9 }
  10 
  11 void draw()
  12 {  
  13   if(record) {
  14     scale(1, -1, 1);              // perform Y axis inversion if record
  15     translate(0, height/4, 0);
  16     noLoop();
  17     beginRaw("povwriter."+cadSoftware, "output."+ext);
  18   }
  19   render();
  20   if (record) {
  21     endRaw();
  22     record = false;
  23     loop();
  24   }
  25 }
  26 
  27 void render() {
  28   pushMatrix();
  29   translate(width/2, height/2);
  30   box(100);
  31   translate(0, -100);
  32   box(100);
  33   translate(0, -100);
  34   box(100);
  35   translate(0, -100);
  36   box(100);
  37   translate(-100, 0);
  38   box(100);
  39   translate(200, 0);
  40   box(100);
  41   popMatrix();
  42 }
  43 
  44 void keyPressed() {
  45 
  46   switch(key) {
  47   case 'r': 
  48     cadSoftware = "Rhino"; 
  49     ext = "rvb"; 
  50     break;
  51   case 's': 
  52     cadSoftware = "SketchUP"; 
  53     ext = "rb";
  54     break;
  55   case 'a': 
  56     cadSoftware = "AutoLISP"; 
  57     ext = "lsp";
  58     break;
  59   case 'p': 
  60     cadSoftware = "PovRAY";    
  61     ext = "pov";  
  62     break;
  63   case 'm': 
  64     cadSoftware = "Maya"; 
  65     ext = "mel";
  66     break; 
  67   case 'o': 
  68     cadSoftware = "ObjFile"; 
  69     ext = "obj";
  70     break;       
  71   case 'c': 
  72     cadSoftware = "ArchiCAD"; 
  73     ext = "gdl";
  74     break;
  75   }  
  76   record = true;
  77 }

The "T" is upright in the processing sketch (albeit a bit over-sized). With the scale transformation the "T" is the right way up when rendered in povray without it is inverted. The "Z" direction does not want to play ball, and I don't understand why, but sometimes to view the object correctly I need to position the camera behind the screen (ie +ve 'Z' in povray).

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