CSC 220 - Fall 2022 - Outline of 3D, PShape, and PImage library functions.

Handout sketch CSC220FA2022DemoSome3D is the accompanying demo code.

1. Three-dimensional building blocks.
In setup(), size(width,height,P3D) or fullScreen(P3D) engages the 3D renderer that make heavy use of the graphics card (graphical processing units or GPUs).
    For 2D, size(width,height,P2D) or fullScreen(P2D) work similarly.
    There are a few functions that work only in 2D size(w,h) or fullScreen() that use the Java library renderer.
    For new macs make sure to put frameRate(60) or other frameRate(N) after size() or fullScreen().

The camera() library function sets the viewing point-of-view (POV) a.k.a. "eyeball location".
    camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ), where eyeXYZ is the camera & centerXYZ is what it is looking at.
    Above sketch uses camera(xeye, yeye,  zeye, xeye, yeye,0,0,1,0) in function moveCameraRotateWorldKeys() to look at the Z==0 plane.
    Polled navigation keys enumerated at the top of the sketch move the camera & rotate world view in relation to the camera.

Both translate(...) and scale(...) take up to 3 (X,Y,Z) dimensions; rotateX(), rotateY(), and rotateZ() are library functions; rotateZ() is the same as 2D rotate().
    Use radians(...) to convert degrees to radians and degrees(...) to convert radians to degrees. Rotation, shearX(...), and shearY() take radians.

Use box(DIAMETER) or box(width, height, depth) to draw a cuboid similar to rect(...) for 2D.

Use sphere(RADIUS) to draw a spheroid similar to ellipse(...) for 2D, and sphereDetail(...) to change its level of detail.
    There is a trade-off between spherical fidelity and computation time in level of sphereDetail(...).

Neither box(...) nor sphere(...) take coordinates so precede with translate(...) to position them.
2D shape functions do not have a Z coordinate, therefore also requiring translate(...) when Z != 0.
Also sphere() draws a perfect sphere, use scale(xscale,yscale,zscale) to deform into a sphereoid.
Surround all of this translate(...), scale(...), etc. with push() before an pop() after.

Calling perspective() sets up perspective projection to simulate 3D vanishing point(s) and depth perception.
Calling ortho() sets up orthogonal projection that is useful in seeing alignment of edges in 3D objects.

2. PShape is a class type that supports Processing vector graphics objects.

A vector graphic uses a mathematical description of a shape, including some fonts, that has unlimited resolution.
    A vector is not converted to raster pixels until it is rendered for a raster display.
    There are special vector displays such as analog oscilloscopes and laser projectors.

Library function createShape(...) can create canned shapes like RECT, SPHERE, BOX, etc., as well as custom shapes via explicit vertex(...) calls.

Library function loadShape(...) loads SVG and OBJ files created by tools such as Adobe Illustrator.


3. PImage is a class type that supports Processing raster graphics objects, i.e. a sequence of pixels with ARGB values.
    A is for alpha (opacity 0..255), and Red, Green, Blue, each in the range 0..255.

A raster graphic uses an array or matrix of picture elements (pixels) that has limited resolution.

Library function createImage(...) creates an empty PImage on which code can add or copy pixel values..

Library function loadImage(...) loads JPEG, PNG, and other raster image files such as photographs.