-
-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathThreeDGeometry.pde
More file actions
49 lines (42 loc) · 1.12 KB
/
ThreeDGeometry.pde
File metadata and controls
49 lines (42 loc) · 1.12 KB
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
48
49
/**
* SVG Files from 3D Geometry (With Screen Display)
*
* To create vectors from 3D data, use the beginRaw() and
* endRaw() commands. These commands will grab the shape data
* just before it is rendered to the screen. At this stage,
* your entire scene is nothing but a long list of lines and
* triangles. This means that a shape created with sphere()
* method will be made up of hundreds of triangles, rather
* than a single object.
*
* When using beginRaw() and endRaw(), it's possible to write
* to either a 2D or 3D renderer. For instance, beginRaw()
* with the SVG library will write the geometry as flattened
* triangles and lines.
*/
import processing.svg.*;
boolean isRecording;
void setup() {
size(500, 500, P3D);
}
void draw() {
if (isRecording) {
beginRaw(SVG, "output.svg");
}
// Do all your drawing here
background(204);
translate(width/2, height/2, -200);
rotateZ(0.2);
rotateY(mouseX/500.0);
box(200);
if (isRecording) {
endRaw();
isRecording = false;
}
}
// Hit 'r' to record a single frame
void keyPressed() {
if (key == 'r') {
isRecording = true;
}
}