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, 21 December 2010

'F' Test for superCAD library

Here is little processing sketch designed to test the superCAD library, it should produce a 3D 'F'

import superCAD.*;
                                 // a modified superCad library
String cadSoftware, ext;
boolean record = false;

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

void draw()
{  
  if(record) {
    noLoop();
    beginRaw("superCAD."+cadSoftware, "output."+ext);
  }
  render();
  if (record) {
    endRaw();
    record = false;
    loop();
  }
}

void render() {
  translate(width/2, height*0.4);
  box(50);
  translate(0, -50, 0);
  box(50);
  translate(50, 0, 0);
  box(50);
  translate(-50, -50, 0);
  box(50);
  translate(0, -50, 0);  
  box(50);
  translate(50, 0, 0);
  box(50);
}

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;
}















Here is the 'F' rendered using the original superCAD library with a modified toStringComa function, where the Y and Z vertices are multiplied by -1.


protected String toStringComa(float[] vertex){
    return vertex[X] + ", " + vertex[Y]*-1 + ", " + vertex[Z]*-1;
}

The "F" is the right way up, facing right, both reflection and shadow look right, what is not to like? Other solutions like scale(1, -1, 1) worked to correct 'Y' axis but scale(1, -1, -1) did not seem to work?

Of course without the proposed change to  toStringComa you get an inverted and reversed 'F'.

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