/**
RawDXF_RHZU_Demo.pde
Dave Bollinger, Jul 2007
http://www.davebollinger.com
as of Processing 0125 Beta
A modified version of the DXF export library that writes output in a coordinate system
perhaps more suitable for some modelling software such as 3dsMax and SketchUp.
The intent is to keep the orientation of the shapes the same on screen as when shown in
Processing, despite the change in coordinate systems. This is sort of hard to explain --
you'll either notice a problem importing DXF's from the existing library, or you won't.
If you do notice problems, like things seem to be mirror-image and rotated and inside-out,
then this may solve those problems. If whatever software you're importing into works
better with the original DXF's, then of course you don't need this!
This demo doesn't actually do anything useful online - provided only for easy access.
Download it and run it locally, press 'r' to record the dxf's, then import them into
your favorite modeller. If the new version works better, use it. If not, use the original.
Or, here's the ready-to-use output, to make that testing easier:
output_old.dxf
output_new.dxf
What you'll see in Processing:
"Front" (default camera view, looking at origin from +z)
(long z is pointing straight at camera, only near face will be visible)
O-- (short x)
|
|
| (medium y)
What you want to see on import (from an iso or perspective view):
*-- (short x, still x)
/ |
/ |
/ | (medium y, now -z)
/
/ (long z, now -y)
(the angle of "long z, now -y" might be different, depending on camera elevation of default view)
Or something like these (in ortho axis views):
"Front" (looking at origin from the new +y)
O-- (short x)
|
|
| (medium y, now -z)
"Right" (looking at origin from +x)
------------O (long z, now -y)
|
|
| (medium y, now -z)
"Top" (looking at origin from the new +z) (CAD's "plan" view)
O-- (short x, still x)
|
|
|
|
|
| (long z, now -y)
You should then also make sure that normals face outward. In SketchUp if your faces
are tan-colored then you're good, if they're blue then normals are backwards. In 3dsMax
you can turn on the normals from the modify face panel, the red lines should face AWAY
or OUTWARD from the box faces.
Be sure to check the comments in RawDXF_RHZU.java for any further usage issues.
*/
import processing.dxf.*;
boolean record;
void setup() {
size(200, 200, P3D);
}
void keyPressed() {
// use a key press so that it doesn't make a million files
if (key == 'r') record = true;
}
void draw() {
if (record) {
// ONCE FOR THE OLD LIB:
beginRaw(DXF, "output_old.dxf");
drawStuff();
endRaw();
// AGAIN FOR THE NEW LIB:
beginRaw("RawDXF_RHZU", "output_new.dxf");
drawStuff();
endRaw();
// DONE RECORDING:
println("DXF's written.");
record = false;
} else {
// JUST TO SCREEN:
drawStuff();
}
}
void drawStuff() {
camera();
pushMatrix();
translate(width/2f, height/2f, 0f);
// draw progressively longer boxes on positive x,y,z axes:
pushMatrix(); translate(10,0,0); box(20,4,4); popMatrix();
pushMatrix(); translate(0,20,0); box(4,40,4); popMatrix();
pushMatrix(); translate(0,0,30); box(4,4,60); popMatrix();
popMatrix();
}