 |
Using Processing to show 3D objects / OpenGL
Source code name: "sketch.java"
Programming language: Java
Topic: Graphics/3D
DMelt Version 1.5. Last modified: 05/16/1970. License: Pro
https://datamelt.org/code/cache/sketch_5470.java
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;
//import controlP5.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.io.*;
import java.awt.*;
import java.net.URL;
import java.awt.image.*;
import javax.imageio.ImageIO;
import java.util.Properties;
import javax.swing.*;
public class sketch extends PApplet {
PGraphics canvas;
public void setup() {
background(0);
canvas = createGraphics(650, 450, P3D);
canvas.beginDraw();
canvas.clear();
canvas.endDraw();
}
public void settings() {
size(600, 400, P3D);
}
public void draw() {
background(0);
String txt="3D objects with processing";
stroke(153);
textSize(32);
textAlign(CENTER, CENTER);
//text(txt,170,100);
lights();
translate(100,60);
// Draw a cube
box(100);
translate(200,70);
// Draw a box
box(100, 150, 100);
translate(140,170);
sphere(40);
if (mousePressed) {
canvas.beginDraw();
canvas.endDraw();
}
}
public static void main(String args[]) {
String[] appletArgs = new String[] { "sketch" };
if (args != null) {
PApplet.main(concat(appletArgs, args));
} else {
PApplet.main(appletArgs);
}
}
}
You see the box below because you did not login.