diff --git a/java/libraries/opengl/examples/IO/LoadOBJ/LoadOBJ.pde b/java/libraries/opengl/examples/IO/LoadOBJ/LoadOBJ.pde new file mode 100644 index 000000000..5966487c0 --- /dev/null +++ b/java/libraries/opengl/examples/IO/LoadOBJ/LoadOBJ.pde @@ -0,0 +1,18 @@ +PShape rocket; + +public void setup() { + size(640, 360, P3D); + + rocket = loadShape("rocket.obj"); +} + +public void draw() { + background(0); + + lights(); + + translate(width/2, height/2 + 100, -200); + rotateX(PI); + rotateY(frameCount * 0.01f); + shape(rocket); +} diff --git a/java/libraries/opengl/examples/IO/LoadOBJ/data/rocket.mtl b/java/libraries/opengl/examples/IO/LoadOBJ/data/rocket.mtl new file mode 100644 index 000000000..fbce8d026 --- /dev/null +++ b/java/libraries/opengl/examples/IO/LoadOBJ/data/rocket.mtl @@ -0,0 +1,8 @@ +newmtl Default +illum 2 +Ka 0.698039 0.698039 0.698039 +Kd 0.698039 0.698039 0.698039 +Ks 0.710000 0.710000 0.710000 +Ns 76.109253 +map_Kd rocket.png + diff --git a/java/libraries/opengl/examples/IO/SaveDXF/SaveDXF.pde b/java/libraries/opengl/examples/IO/SaveDXF/SaveDXF.pde new file mode 100644 index 000000000..77c146d99 --- /dev/null +++ b/java/libraries/opengl/examples/IO/SaveDXF/SaveDXF.pde @@ -0,0 +1,35 @@ +import processing.dxf.*; + +PShape rocket; + +boolean record; + +public void setup() { + size(640, 360, P3D); + + rocket = loadShape("rocket.obj"); +} + +public void draw() { + if (record) { + beginRaw(DXF, "rocket.dxf"); + } + + background(0); + + lights(); + + translate(width/2, height/2 + 100, -200); + rotateX(PI); + rotateY(frameCount * 0.01f); + shape(rocket); + + if (record) { + endRaw(); + record = false; + } +} + +void keyPressed() { + if (key == 'r') record = true; +} diff --git a/java/libraries/opengl/examples/IO/SaveDXF/data/rocket.mtl b/java/libraries/opengl/examples/IO/SaveDXF/data/rocket.mtl new file mode 100644 index 000000000..fbce8d026 --- /dev/null +++ b/java/libraries/opengl/examples/IO/SaveDXF/data/rocket.mtl @@ -0,0 +1,8 @@ +newmtl Default +illum 2 +Ka 0.698039 0.698039 0.698039 +Kd 0.698039 0.698039 0.698039 +Ks 0.710000 0.710000 0.710000 +Ns 76.109253 +map_Kd rocket.png + diff --git a/java/libraries/opengl/examples/IO/SavePDF/SavePDF.pde b/java/libraries/opengl/examples/IO/SavePDF/SavePDF.pde new file mode 100644 index 000000000..b6acd30a1 --- /dev/null +++ b/java/libraries/opengl/examples/IO/SavePDF/SavePDF.pde @@ -0,0 +1,47 @@ +// Robot 1: Draw from "Getting Started with Processing" +// by Reas & Fry. O'Reilly / Make 2010 + +import processing.pdf.*; + +size(720, 480, P3D); +hint(ENABLE_ACCURATE_2D); +smooth(); +strokeWeight(2); +background(204); +ellipseMode(RADIUS); + +beginRaw(PDF, "robot.pdf"); + +// Neck +stroke(102); // Set stroke to gray +line(266, 257, 266, 162); // Left +line(276, 257, 276, 162); // Middle +line(286, 257, 286, 162); // Right + +// Antennae +line(276, 155, 246, 112); // Small +line(276, 155, 306, 56); // Tall +line(276, 155, 342, 170); // Medium + +// Body +noStroke(); // Disable stroke +fill(102); // Set fill to gray +ellipse(264, 377, 33, 33); // Antigravity orb +fill(0); // Set fill to black +rect(219, 257, 90, 120); // Main body +fill(102); // Set fill to gray +rect(219, 274, 90, 6); // Gray stripe + +// Head +fill(0); // Set fill to black +ellipse(276, 155, 45, 45); // Head +fill(255); // Set fill to white +ellipse(288, 150, 14, 14); // Large eye +fill(0); // Set fill to black +ellipse(288, 150, 3, 3); // Pupil +fill(153); // Set fill to light gray +ellipse(263, 148, 5, 5); // Small eye 1 +ellipse(296, 130, 4, 4); // Small eye 2 +ellipse(305, 162, 3, 3); // Small eye 3 + +endRaw(); diff --git a/java/libraries/opengl/examples/Immediate/Robot1_Draw/Robot1_Draw.pde b/java/libraries/opengl/examples/Immediate/Robot1_Draw/Robot1_Draw.pde index 43dc0cc57..4b6cd2850 100755 --- a/java/libraries/opengl/examples/Immediate/Robot1_Draw/Robot1_Draw.pde +++ b/java/libraries/opengl/examples/Immediate/Robot1_Draw/Robot1_Draw.pde @@ -2,6 +2,7 @@ // by Reas & Fry. O'Reilly / Make 2010 size(720, 480, P3D); +hint(ENABLE_ACCURATE_2D); smooth(); strokeWeight(2); background(204);