XinWang-How To Make A Simple 3D in Processing
XinWang-How To Make A Simple 3D in Processing
P3D Box();
Sphere();
lights();
ambientLight();
directionalLight(): piontLight();
sportLight();
Camera(); perspective();
Vertex();
And so on
Understanding3D
vertex
X axis
vector
Z axis
Y axis
P3D
OPENGL
This is a high speed 3D renderer for that use OpenGL-compatible graphics
hardware if available .
//import processing.opengl.*;
void setup() {
size(400, 400, P3D/ OPENGL); // set up the 3D renderer
}
void draw() {
noStroke(); // commenting this line out will show the lines in the box
//lights(); // uncommenting this will show the model with lights
fill(255);
translate(200, 200, 0);
box(100);
}
Lighting in processing
Sets the position of the camera through setting the eye position, the
center of the scene, and which axis is facing upward. Moving the eye
position and the direction it is pointing (the center of the scene) allows
the images to be seen from different angles.
perspective()
perspective(fov, aspect, zNear, zFar)// default
The default values are: perspective(PI/3.0, width/height, cameraZ/10.0,
cameraZ*10.0)
Perspective ( fov, aspect, zNear, zFar )
Fov float: field-of-view angle (in radians) for vertical direction aspect float: ratio
of width to height zNear float: z-position of nearest clipping plane zFar float: z-
position of farthest clipping plane
ortho()
ortho(left, right, bottom, top, near, far)
the default is used: ortho(0, width, 0, height, -10, 10).
perspective() VS orthographic ()
Thanks