-
-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathSimpleExport.pde
More file actions
48 lines (42 loc) · 947 Bytes
/
SimpleExport.pde
File metadata and controls
48 lines (42 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Simple DXF Export
* by Simon Greenwold.
*
* Press the 'R' key to export a DXF file.
*/
import processing.dxf.*;
boolean isRecording = false;
void setup() {
size(400, 400, P3D);
noStroke();
sphereDetail(12);
}
void draw() {
if (isRecording == true) {
beginRaw(DXF, "output.dxf"); // Start recording to the file
}
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 (isRecording == true) {
endRaw();
isRecording = false; // Stop recording to the file
}
}
void keyPressed() {
if (key == 'R' || key == 'r') { // Press R to save the file
isRecording = true;
}
}