public class PGraphics2D extends PGraphicsOpenGL
anisoSamplingSupported, autoMipmapGenSupported, blendEqSupported, camera, cameraAspect, cameraFar, cameraFOV, cameraInv, cameraNear, cameraX, cameraY, cameraZ, currentLightFalloffConstant, currentLightFalloffLinear, currentLightFalloffQuadratic, currentLightSpecular, currentPG, defCameraAspect, defCameraFar, defCameraFOV, defCameraNear, defCameraX, defCameraY, defCameraZ, depthBits, drawBufferSupported, fboMultisampleSupported, GLSL_VERSION, initialized, lightAmbient, lightCount, lightDiffuse, lightFalloffCoefficients, lightNormal, lightPosition, lights, lightSpecular, lightSpotParameters, lightType, maxAnisoAmount, maxSamples, maxTextureSize, modelview, modelviewInv, npotTexSupported, OPENGL_EXTENSIONS, OPENGL_RENDERER, OPENGL_VENDOR, OPENGL_VERSION, packedDepthStencilSupported, pgl, projection, projmodelview, readBufferSupported, stencilBitsA, AB, AG, ambientB, ambientColor, ambientG, ambientR, AR, B, backgroundColor, BEEN_LIT, bezierDetail, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, curveDetail, curveTightness, DA, DB, DEFAULT_VERTICES, DG, DR, EB, edge, EDGE, EG, ellipseMode, emissiveB, emissiveColor, emissiveG, emissiveR, ER, fill, fillColor, G, HAS_NORMAL, image, imageMode, normalX, normalY, normalZ, NX, NY, NZ, pixelCount, R, rectMode, SA, SB, setAmbient, SG, shapeMode, SHINE, shininess, smooth, SPB, specularB, specularColor, specularG, specularR, SPG, sphereDetailU, sphereDetailV, SPR, SR, stroke, strokeCap, strokeColor, strokeJoin, strokeWeight, SW, textAlign, textAlignY, textFont, textLeading, textMode, textSize, textureImage, textureMode, textureU, textureV, tint, tintColor, TX, TY, TZ, U, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZALPHA_MASK, BLUE_MASK, format, GREEN_MASK, height, loaded, parent, pixelDensity, pixelHeight, pixels, pixelWidth, RED_MASK, widthADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z| Constructor and Description |
|---|
PGraphics2D() |
| Modifier and Type | Method and Description |
|---|---|
void |
ambientLight(float red,
float green,
float blue)
Add an ambient light based on the current color mode.
|
void |
ambientLight(float red,
float green,
float blue,
float x,
float y,
float z)
Add an ambient light based on the current color mode.
|
void |
applyMatrix(float n00,
float n01,
float n02,
float n03,
float n10,
float n11,
float n12,
float n13,
float n20,
float n21,
float n22,
float n23,
float n30,
float n31,
float n32,
float n33)
Apply a 4x4 transformation matrix to the modelview stack.
|
void |
applyMatrix(PMatrix3D source) |
void |
beginCamera()
Set matrix mode to the camera matrix (instead of the current transformation
matrix).
|
void |
bezierVertex(float x2,
float y2,
float z2,
float x3,
float y3,
float z3,
float x4,
float y4,
float z4)
( begin auto-generated from bezierVertex.xml )
Specifies vertex coordinates for Bezier curves.
|
void |
box(float w,
float h,
float d) |
void |
camera()
Set camera to the default settings.
|
void |
camera(float eyeX,
float eyeY,
float eyeZ,
float centerX,
float centerY,
float centerZ,
float upX,
float upY,
float upZ)
More flexible method for dealing with camera().
|
void |
curveVertex(float x,
float y,
float z) |
void |
directionalLight(float red,
float green,
float blue,
float nx,
float ny,
float nz)
( begin auto-generated from directionalLight.xml )
Adds a directional light.
|
void |
endCamera()
Record the current settings into the camera matrix, and set the matrix mode
back to the current transformation matrix.
|
void |
frustum(float left,
float right,
float bottom,
float top,
float znear,
float zfar)
Same as glFrustum(), except that it wipes out (rather than multiplies
against) the current perspective matrix.
|
PMatrix3D |
getMatrix(PMatrix3D target)
Copy the current transformation matrix into the specified target.
|
void |
hint(int which)
( begin auto-generated from hint.xml )
Set various hints and hacks for the renderer.
|
boolean |
is2D()
Return true if this renderer supports 2D drawing.
|
boolean |
is3D()
Return true if this renderer supports 3D drawing.
|
void |
lightFalloff(float constant,
float linear,
float quadratic)
Set the light falloff rates for the last light that was created.
|
void |
lights()
Sets up an ambient and directional light using OpenGL.
|
void |
lightSpecular(float v1,
float v2,
float v3)
Set the specular color of the last light created.
|
float |
modelX(float x,
float y,
float z)
( begin auto-generated from modelX.xml )
Returns the three-dimensional X, Y, Z position in model space.
|
float |
modelY(float x,
float y,
float z)
( begin auto-generated from modelY.xml )
Returns the three-dimensional X, Y, Z position in model space.
|
float |
modelZ(float x,
float y,
float z)
( begin auto-generated from modelZ.xml )
Returns the three-dimensional X, Y, Z position in model space.
|
void |
noLights()
Disables lighting.
|
void |
ortho()
Calls ortho() with the proper parameters for Processing's standard
orthographic projection.
|
void |
ortho(float left,
float right,
float bottom,
float top)
Calls ortho() with the specified size of the viewing volume along
the X and Z directions.
|
void |
ortho(float left,
float right,
float bottom,
float top,
float near,
float far)
Sets an orthographic projection.
|
void |
perspective()
Calls perspective() with Processing's standard coordinate projection.
|
void |
perspective(float fov,
float aspect,
float zNear,
float zFar)
Similar to gluPerspective().
|
void |
pointLight(float red,
float green,
float blue,
float x,
float y,
float z)
( begin auto-generated from pointLight.xml )
Adds a point light.
|
void |
quadraticVertex(float x2,
float y2,
float z2,
float x4,
float y4,
float z4) |
void |
rotate(float angle,
float vx,
float vy,
float vz)
Rotate around an arbitrary vector, similar to glRotate(), except that it
takes radians (instead of degrees).
|
void |
rotateX(float angle)
( begin auto-generated from rotateX.xml )
Rotates a shape around the x-axis the amount specified by the
angle parameter.
|
void |
rotateY(float angle)
( begin auto-generated from rotateY.xml )
Rotates a shape around the y-axis the amount specified by the
angle parameter.
|
void |
rotateZ(float angle)
( begin auto-generated from rotateZ.xml )
Rotates a shape around the z-axis the amount specified by the
angle parameter.
|
void |
scale(float sx,
float sy,
float sz)
Scale in three dimensions.
|
float |
screenX(float x,
float y,
float z) |
float |
screenY(float x,
float y,
float z) |
float |
screenZ(float x,
float y,
float z)
( begin auto-generated from screenZ.xml )
Takes a three-dimensional X, Y, Z position and returns the Z value for
where it will appear on a (two-dimensional) screen.
|
void |
setMatrix(PMatrix3D source)
Set the current transformation to the contents of the specified source.
|
void |
shape(PShape shape) |
void |
shape(PShape shape,
float x,
float y)
( begin auto-generated from shape.xml )
Displays shapes to the screen.
|
void |
shape(PShape shape,
float x,
float y,
float z) |
void |
shape(PShape shape,
float a,
float b,
float c,
float d) |
void |
shape(PShape shape,
float x,
float y,
float z,
float c,
float d,
float e) |
void |
sphere(float r)
( begin auto-generated from sphere.xml )
A sphere is a hollow ball made from tessellated triangles.
|
void |
spotLight(float red,
float green,
float blue,
float x,
float y,
float z,
float nx,
float ny,
float nz,
float angle,
float concentration)
( begin auto-generated from spotLight.xml )
Adds a spot light.
|
void |
translate(float tx,
float ty,
float tz) |
void |
vertex(float x,
float y,
float z) |
void |
vertex(float x,
float y,
float z,
float u,
float v)
( begin auto-generated from vertex.xml )
All shapes are constructed by connecting a series of vertices.
|
applyMatrix, applyMatrix, applyProjection, applyProjection, attrib, attrib, attrib, attribColor, attribNormal, attribPosition, beginContour, beginDraw, beginPGL, beginShape, bezierVertex, copy, copy, createSurface, curveVertex, dispose, ellipseImpl, endContour, endDraw, endPGL, endShape, filter, filter, filter, flush, get, getCache, getFrameBuffer, getFrameBuffer, getMatrix, getTexture, getTexture, getTexture, isGL, line, line, loadPixels, loadShader, loadShader, loadShape, loadTexture, mask, noClip, point, point, popMatrix, popProjection, popStyle, printCamera, printMatrix, printProjection, pushMatrix, pushProjection, quad, quadraticVertex, removeCache, resetMatrix, resetProjection, resetShader, resetShader, resize, rotate, save, saveImpl, scale, scale, screenX, screenY, set, setCache, setMatrix, setParent, setPrimary, setProjection, setSize, shader, shader, shearX, shearY, strokeCap, strokeJoin, strokeWeight, textAscent, textDescent, textureSampling, textureWrap, translate, triangle, updateDisplay, updateProjmodelview, updateTexture, updateTexture, vertex, vertexalpha, ambient, ambient, ambient, applyMatrix, arc, arc, background, background, background, background, background, background, background, beginRaw, beginShape, bezier, bezier, bezierDetail, bezierPoint, bezierTangent, blendMode, blue, box, brightness, circle, clear, clip, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, createShape, createShape, createShape, curve, curve, curveDetail, curvePoint, curveTangent, curveTightness, displayable, edge, ellipse, ellipseMode, emissive, emissive, emissive, endRaw, endShape, fill, fill, fill, fill, fill, fill, getMatrix, getRaw, getStyle, getStyle, green, haveRaw, hue, image, image, image, imageMode, is2X, lerpColor, lerpColor, loadShape, noFill, normal, noSmooth, noStroke, noTexture, noTint, pop, push, pushStyle, rect, rect, rect, rectMode, red, saturation, setMatrix, setPath, shapeMode, shininess, showDepthWarning, showDepthWarningXYZ, showException, showMethodWarning, showMissingWarning, showVariationWarning, showWarning, showWarning, smooth, smooth, specular, specular, specular, sphereDetail, sphereDetail, square, stroke, stroke, stroke, stroke, stroke, stroke, style, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textFont, textFont, textLeading, textMode, textSize, texture, textureMode, textWidth, textWidth, textWidth, tint, tint, tint, tint, tint, tint, vertexblend, blend, blendColor, clone, copy, get, get, getImage, getModifiedX1, getModifiedX2, getModifiedY1, getModifiedY2, getNative, init, init, isLoaded, isModified, mask, set, setLoaded, setLoaded, setModified, setModified, updatePixels, updatePixelspublic boolean is2D()
PGraphicspublic boolean is3D()
PGraphicspublic void hint(int which)
PGraphicshint in class PGraphicsOpenGLwhich - name of the hint to be enabled or disabledPGraphics,
PApplet.createGraphics(int, int, String, String),
PApplet.size(int, int)public void ortho()
PGraphicsOpenGLortho in class PGraphicsOpenGLpublic void ortho(float left,
float right,
float bottom,
float top)
PGraphicsOpenGLortho in class PGraphicsOpenGLleft - left plane of the clipping volumeright - right plane of the clipping volumebottom - bottom plane of the clipping volumetop - top plane of the clipping volumepublic void ortho(float left,
float right,
float bottom,
float top,
float near,
float far)
PGraphicsOpenGLortho in class PGraphicsOpenGLnear - maximum distance from the origin to the viewerfar - maximum distance from the origin away from the viewerpublic void perspective()
PGraphicsOpenGLProjection functions:
This behavior is pretty much familiar from OpenGL, except where functions replace matrices, rather than multiplying against the previous.
perspective in class PGraphicsOpenGLpublic void perspective(float fov,
float aspect,
float zNear,
float zFar)
PGraphicsOpenGLperspective in class PGraphicsOpenGLfov - field-of-view angle (in radians) for vertical directionaspect - ratio of width to heightzNear - z-position of nearest clipping planezFar - z-position of farthest clipping planepublic void frustum(float left,
float right,
float bottom,
float top,
float znear,
float zfar)
PGraphicsOpenGLImplementation based on the explanation in the OpenGL blue book.
frustum in class PGraphicsOpenGLleft - left coordinate of the clipping planeright - right coordinate of the clipping planebottom - bottom coordinate of the clipping planetop - top coordinate of the clipping planeznear - near component of the clipping plane; must be greater than zerozfar - far component of the clipping plane; must be greater than the near valuePGraphics.camera(float, float, float, float, float, float, float, float, float),
PGraphics.beginCamera(),
PGraphics.endCamera(),
PGraphics.perspective(float, float, float, float)public void beginCamera()
PGraphicsOpenGLNote that the camera matrix is *not* the perspective matrix, it contains the values of the modelview matrix immediatly after the latter was initialized with ortho() or camera(), or the modelview matrix as result of the operations applied between beginCamera()/endCamera().
beginCamera() specifies that all coordinate transforms until endCamera() should be pre-applied in inverse to the camera transform matrix. Note that this is only challenging when a user specifies an arbitrary matrix with applyMatrix(). Then that matrix will need to be inverted, which may not be possible. But take heart, if a user is applying a non-invertible matrix to the camera transform, then he is clearly up to no good, and we can wash our hands of those bad intentions.
begin/endCamera clauses do not automatically reset the camera transform matrix. That's because we set up a nice default camera transform in setup(), and we expect it to hold through draw(). So we don't reset the camera transform matrix at the top of draw(). That means that an innocuous-looking clause like
beginCamera(); translate(0, 0, 10); endCamera();at the top of draw(), will result in a runaway camera that shoots infinitely out of the screen over time. In order to prevent this, it is necessary to call some function that does a hard reset of the camera transform matrix inside of begin/endCamera. Two options are
camera(); // sets up the nice default camera transform resetMatrix(); // sets up the identity camera transformSo to rotate a camera a constant amount, you might try
beginCamera(); camera(); rotateY(PI / 8); endCamera();
public void endCamera()
PGraphicsOpenGLNote that this will destroy any settings to scale(), translate(), or whatever, because the final camera matrix will be copied (not multiplied) into the modelview.
endCamera in class PGraphicsOpenGLPGraphics.beginCamera(),
PGraphics.camera(float, float, float, float, float, float, float, float, float)public void camera()
PGraphicsOpenGLProcessing camera behavior:
Camera behavior can be split into two separate components, camera transformation, and projection. The transformation corresponds to the physical location, orientation, and scale of the camera. In a physical camera metaphor, this is what can manipulated by handling the camera body (with the exception of scale, which doesn't really have a physcial analog). The projection corresponds to what can be changed by manipulating the lens.
We maintain separate matrices to represent the camera transform and projection. An important distinction between the two is that the camera transform should be invertible, where the projection matrix should not, since it serves to map three dimensions to two. It is possible to bake the two matrices into a single one just by multiplying them together, but it isn't a good idea, since lighting, z-ordering, and z-buffering all demand a true camera z coordinate after modelview and camera transforms have been applied but before projection. If the camera transform and projection are combined there is no way to recover a good camera-space z-coordinate from a model coordinate.
Fortunately, there are no functions that manipulate both camera transformation and projection.
camera() sets the camera position, orientation, and center of the scene. It replaces the camera transform with a new one.
The transformation functions are the same ones used to manipulate the modelview matrix (scale, translate, rotate, etc.). But they are bracketed with beginCamera(), endCamera() to indicate that they should apply (in inverse), to the camera transformation matrix.
camera in class PGraphicsOpenGLPGraphics.beginCamera(),
PGraphics.endCamera(),
PGraphics.frustum(float, float, float, float, float, float)public void camera(float eyeX,
float eyeY,
float eyeZ,
float centerX,
float centerY,
float centerZ,
float upX,
float upY,
float upZ)
PGraphicsOpenGLThe actual call is like gluLookat. Here's the real skinny on what does what:
camera(); or camera(ex, ey, ez, cx, cy, cz, ux, uy, uz);do not need to be called from with beginCamera();/endCamera(); That's because they always apply to the camera transformation, and they always totally replace it. That means that any coordinate transforms done before camera(); in draw() will be wiped out. It also means that camera() always operates in untransformed world coordinates. Therefore it is always redundant to call resetMatrix(); before camera(); This isn't technically true of gluLookat, but it's pretty much how it's used.
Now, beginCamera(); and endCamera(); are useful if you want to move the camera around using transforms like translate(), etc. They will wipe out any coordinate system transforms that occur before them in draw(), but they will not automatically wipe out the camera transform. This means that they should be at the top of draw(). It also means that the following:
beginCamera(); rotateY(PI / 8); endCamera();will result in a camera that spins without stopping. If you want to just rotate a small constant amount, try this:
beginCamera(); camera(); // sets up the default view rotateY(PI / 8); endCamera();That will rotate a little off of the default view. Note that this is entirely equivalent to
camera(); // sets up the default view beginCamera(); rotateY(PI / 8); endCamera();because camera() doesn't care whether or not it's inside a begin/end clause. Basically it's safe to use camera() or camera(ex, ey, ez, cx, cy, cz, ux, uy, uz) as naked calls because they do all the matrix resetting automatically.
camera in class PGraphicsOpenGLeyeX - x-coordinate for the eyeeyeY - y-coordinate for the eyeeyeZ - z-coordinate for the eyecenterX - x-coordinate for the center of the scenecenterY - y-coordinate for the center of the scenecenterZ - z-coordinate for the center of the sceneupX - usually 0.0, 1.0, or -1.0upY - usually 0.0, 1.0, or -1.0upZ - usually 0.0, 1.0, or -1.0public void shape(PShape shape, float x, float y)
PGraphicsshape in class PGraphicsshape - the shape to displayx - x-coordinate of the shapey - y-coordinate of the shapePShape,
PApplet.loadShape(String),
Convenience method to draw at a particular location.public void shape(PShape shape, float a, float b, float c, float d)
public void shape(PShape shape, float x, float y, float z)
public void shape(PShape shape, float x, float y, float z, float c, float d, float e)
public float modelX(float x,
float y,
float z)
PGraphicsmodelX in class PGraphicsOpenGLx - 3D x-coordinate to be mappedy - 3D y-coordinate to be mappedz - 3D z-coordinate to be mappedPGraphics.modelY(float, float, float),
PGraphics.modelZ(float, float, float)public float modelY(float x,
float y,
float z)
PGraphicsmodelY in class PGraphicsOpenGLx - 3D x-coordinate to be mappedy - 3D y-coordinate to be mappedz - 3D z-coordinate to be mappedPGraphics.modelX(float, float, float),
PGraphics.modelZ(float, float, float)public float modelZ(float x,
float y,
float z)
PGraphicsmodelZ in class PGraphicsOpenGLx - 3D x-coordinate to be mappedy - 3D y-coordinate to be mappedz - 3D z-coordinate to be mappedPGraphics.modelX(float, float, float),
PGraphics.modelY(float, float, float)public void bezierVertex(float x2,
float y2,
float z2,
float x3,
float y3,
float z3,
float x4,
float y4,
float z4)
PGraphicsbezierVertex in class PGraphicsOpenGLx2 - the x-coordinate of the 1st control pointy2 - the y-coordinate of the 1st control pointz2 - the z-coordinate of the 1st control pointx3 - the x-coordinate of the 2nd control pointy3 - the y-coordinate of the 2nd control pointz3 - the z-coordinate of the 2nd control pointx4 - the x-coordinate of the anchor pointy4 - the y-coordinate of the anchor pointz4 - the z-coordinate of the anchor pointPGraphics.curveVertex(float, float, float),
PGraphics.vertex(float, float, float, float, float),
PGraphics.quadraticVertex(float, float, float, float, float, float),
PGraphics.bezier(float, float, float, float, float, float, float, float, float, float, float, float)public void quadraticVertex(float x2,
float y2,
float z2,
float x4,
float y4,
float z4)
quadraticVertex in class PGraphicsOpenGLz2 - the z-coordinate of the control pointz4 - the z-coordinate of the anchor pointpublic void curveVertex(float x,
float y,
float z)
curveVertex in class PGraphicsOpenGLz - the z-coordinate of the vertexpublic void box(float w,
float h,
float d)
box in class PGraphicsOpenGLw - dimension of the box in the x-dimensionh - dimension of the box in the y-dimensiond - dimension of the box in the z-dimensionpublic void sphere(float r)
PGraphicsImplementation notes:
cache all the points of the sphere in a static array top and bottom are just a bunch of triangles that land in the center point
sphere is a series of concentric circles who radii vary along the shape, based on, er.. cos or something
[toxi 031031] new sphere code. removed all multiplies with radius, as scale() will take care of that anyway [toxi 031223] updated sphere code (removed modulos) and introduced sphereAt(x,y,z,r) to avoid additional translate()'s on the user/sketch side [davbol 080801] now using separate sphereDetailU/V
sphere in class PGraphicsOpenGLr - the radius of the spherePGraphics.sphereDetail(int)public void vertex(float x,
float y,
float z)
vertex in class PGraphicsOpenGLpublic void vertex(float x,
float y,
float z,
float u,
float v)
PGraphicsvertex in class PGraphicsOpenGLx - x-coordinate of the vertexy - y-coordinate of the vertexz - z-coordinate of the vertexu - horizontal coordinate for the texture mappingv - vertical coordinate for the texture mappingPGraphics.beginShape(int),
PGraphics.endShape(int),
PGraphics.bezierVertex(float, float, float, float, float, float, float, float, float),
PGraphics.quadraticVertex(float, float, float, float, float, float),
PGraphics.curveVertex(float, float, float),
PGraphics.texture(PImage)public void translate(float tx,
float ty,
float tz)
translate in class PGraphicsOpenGLtz - forward/backward translationpublic void rotateX(float angle)
PGraphicsrotateX in class PGraphicsOpenGLangle - angle of rotation specified in radiansPGraphics.popMatrix(),
PGraphics.pushMatrix(),
PGraphics.rotate(float),
PGraphics.rotateY(float),
PGraphics.rotateZ(float),
PGraphics.scale(float, float, float),
PGraphics.translate(float, float, float)public void rotateY(float angle)
PGraphicsrotateY in class PGraphicsOpenGLangle - angle of rotation specified in radiansPGraphics.popMatrix(),
PGraphics.pushMatrix(),
PGraphics.rotate(float),
PGraphics.rotateX(float),
PGraphics.rotateZ(float),
PGraphics.scale(float, float, float),
PGraphics.translate(float, float, float)public void rotateZ(float angle)
PGraphicsrotateZ in class PGraphicsOpenGLangle - angle of rotation specified in radiansPGraphics.popMatrix(),
PGraphics.pushMatrix(),
PGraphics.rotate(float),
PGraphics.rotateX(float),
PGraphics.rotateY(float),
PGraphics.scale(float, float, float),
PGraphics.translate(float, float, float)public void rotate(float angle,
float vx,
float vy,
float vz)
PGraphicsOpenGLrotate in class PGraphicsOpenGLpublic void applyMatrix(PMatrix3D source)
applyMatrix in class PGraphicsOpenGLpublic void applyMatrix(float n00,
float n01,
float n02,
float n03,
float n10,
float n11,
float n12,
float n13,
float n20,
float n21,
float n22,
float n23,
float n30,
float n31,
float n32,
float n33)
PGraphicsOpenGLapplyMatrix in class PGraphicsOpenGLn03 - numbers which define the 4x4 matrix to be multipliedn13 - numbers which define the 4x4 matrix to be multipliedn20 - numbers which define the 4x4 matrix to be multipliedn21 - numbers which define the 4x4 matrix to be multipliedn22 - numbers which define the 4x4 matrix to be multipliedn23 - numbers which define the 4x4 matrix to be multipliedn30 - numbers which define the 4x4 matrix to be multipliedn31 - numbers which define the 4x4 matrix to be multipliedn32 - numbers which define the 4x4 matrix to be multipliedn33 - numbers which define the 4x4 matrix to be multipliedpublic void scale(float sx,
float sy,
float sz)
PGraphicsOpenGLscale in class PGraphicsOpenGLsz - percentage to scale the object in the z-axispublic float screenX(float x,
float y,
float z)
screenX in class PGraphicsOpenGLz - 3D z-coordinate to be mappedpublic float screenY(float x,
float y,
float z)
screenY in class PGraphicsOpenGLz - 3D z-coordinate to be mappedpublic float screenZ(float x,
float y,
float z)
PGraphicsscreenZ in class PGraphicsOpenGLx - 3D x-coordinate to be mappedy - 3D y-coordinate to be mappedz - 3D z-coordinate to be mappedPGraphics.screenX(float, float, float),
PGraphics.screenY(float, float, float)public PMatrix3D getMatrix(PMatrix3D target)
PGraphicsgetMatrix in class PGraphicsOpenGLpublic void setMatrix(PMatrix3D source)
PGraphicsOpenGLsetMatrix in class PGraphicsOpenGLpublic void lights()
PGraphicsOpenGL
The Lighting Skinny:
The way lighting works is complicated enough that it's worth
producing a document to describe it. Lighting calculations proceed
pretty much exactly as described in the OpenGL red book.
Light-affecting material properties:
AMBIENT COLOR
- multiplies by light's ambient component
- for believability this should match diffuse color
DIFFUSE COLOR
- multiplies by light's diffuse component
SPECULAR COLOR
- multiplies by light's specular component
- usually less colored than diffuse/ambient
SHININESS
- the concentration of specular effect
- this should be set pretty high (20-50) to see really
noticeable specularity
EMISSIVE COLOR
- constant additive color effect
Light types:
AMBIENT
- one color
- no specular color
- no direction
- may have falloff (constant, linear, and quadratic)
- may have position (which matters in non-constant falloff case)
- multiplies by a material's ambient reflection
DIRECTIONAL
- has diffuse color
- has specular color
- has direction
- no position
- no falloff
- multiplies by a material's diffuse and specular reflections
POINT
- has diffuse color
- has specular color
- has position
- no direction
- may have falloff (constant, linear, and quadratic)
- multiplies by a material's diffuse and specular reflections
SPOT
- has diffuse color
- has specular color
- has position
- has direction
- has cone angle (set to half the total cone angle)
- has concentration value
- may have falloff (constant, linear, and quadratic)
- multiplies by a material's diffuse and specular reflections
Normal modes:
All of the primitives (rect, box, sphere, etc.) have their normals
set nicely. During beginShape/endShape normals can be set by the user.
AUTO-NORMAL
- if no normal is set during the shape, we are in auto-normal mode
- auto-normal calculates one normal per triangle (face-normal mode)
SHAPE-NORMAL
- if one normal is set during the shape, it will be used for
all vertices
VERTEX-NORMAL
- if multiple normals are set, each normal applies to
subsequent vertices
- (except for the first one, which applies to previous
and subsequent vertices)
Efficiency consequences:
There is a major efficiency consequence of position-dependent
lighting calculations per vertex. (See below for determining
whether lighting is vertex position-dependent.) If there is no
position dependency then the only factors that affect the lighting
contribution per vertex are its colors and its normal.
There is a major efficiency win if
1) lighting is not position dependent
2) we are in AUTO-NORMAL or SHAPE-NORMAL mode
because then we can calculate one lighting contribution per shape
(SHAPE-NORMAL) or per triangle (AUTO-NORMAL) and simply multiply it
into the vertex colors. The converse is our worst-case performance when
1) lighting is position dependent
2) we are in AUTO-NORMAL mode
because then we must calculate lighting per-face * per-vertex.
Each vertex has a different lighting contribution per face in
which it appears. Yuck.
Determining vertex position dependency:
If any of the following factors are TRUE then lighting is
vertex position dependent:
1) Any lights uses non-constant falloff
2) There are any point or spot lights
3) There is a light with specular color AND there is a
material with specular color
So worth noting is that default lighting (a no-falloff ambient
and a directional without specularity) is not position-dependent.
We should capitalize.
Simon Greenwold, April 2005
lights in class PGraphicsOpenGLPGraphics.ambientLight(float, float, float, float, float, float),
PGraphics.directionalLight(float, float, float, float, float, float),
PGraphics.pointLight(float, float, float, float, float, float),
PGraphics.spotLight(float, float, float, float, float, float, float, float, float, float, float),
PGraphics.noLights()public void noLights()
PGraphicsOpenGLnoLights in class PGraphicsOpenGLPGraphics.lights()public void ambientLight(float red,
float green,
float blue)
PGraphicsOpenGLambientLight in class PGraphicsOpenGLred - red or hue value (depending on current color mode)green - green or saturation value (depending on current color mode)blue - blue or brightness value (depending on current color mode)PGraphics.lights(),
PGraphics.directionalLight(float, float, float, float, float, float),
PGraphics.pointLight(float, float, float, float, float, float),
PGraphics.spotLight(float, float, float, float, float, float, float, float, float, float, float)public void ambientLight(float red,
float green,
float blue,
float x,
float y,
float z)
PGraphicsOpenGLambientLight in class PGraphicsOpenGLx - x-coordinate of the lighty - y-coordinate of the lightz - z-coordinate of the lightpublic void directionalLight(float red,
float green,
float blue,
float nx,
float ny,
float nz)
PGraphicsdirectionalLight in class PGraphicsOpenGLred - red or hue value (depending on current color mode)green - green or saturation value (depending on current color mode)blue - blue or brightness value (depending on current color mode)nx - direction along the x-axisny - direction along the y-axisnz - direction along the z-axisPGraphics.lights(),
PGraphics.ambientLight(float, float, float, float, float, float),
PGraphics.pointLight(float, float, float, float, float, float),
PGraphics.spotLight(float, float, float, float, float, float, float, float, float, float, float)public void pointLight(float red,
float green,
float blue,
float x,
float y,
float z)
PGraphicspointLight in class PGraphicsOpenGLred - red or hue value (depending on current color mode)green - green or saturation value (depending on current color mode)blue - blue or brightness value (depending on current color mode)x - x-coordinate of the lighty - y-coordinate of the lightz - z-coordinate of the lightPGraphics.lights(),
PGraphics.directionalLight(float, float, float, float, float, float),
PGraphics.ambientLight(float, float, float, float, float, float),
PGraphics.spotLight(float, float, float, float, float, float, float, float, float, float, float)public void spotLight(float red,
float green,
float blue,
float x,
float y,
float z,
float nx,
float ny,
float nz,
float angle,
float concentration)
PGraphicsspotLight in class PGraphicsOpenGLred - red or hue value (depending on current color mode)green - green or saturation value (depending on current color mode)blue - blue or brightness value (depending on current color mode)x - x-coordinate of the lighty - y-coordinate of the lightz - z-coordinate of the lightnx - direction along the x axisny - direction along the y axisnz - direction along the z axisangle - angle of the spotlight coneconcentration - exponent determining the center bias of the conePGraphics.lights(),
PGraphics.directionalLight(float, float, float, float, float, float),
PGraphics.pointLight(float, float, float, float, float, float),
PGraphics.ambientLight(float, float, float, float, float, float)public void lightFalloff(float constant,
float linear,
float quadratic)
PGraphicsOpenGLlightFalloff in class PGraphicsOpenGLconstant - constant value or determining fallofflinear - linear value for determining falloffquadratic - quadratic value for determining falloffPGraphics.lights(),
PGraphics.ambientLight(float, float, float, float, float, float),
PGraphics.pointLight(float, float, float, float, float, float),
PGraphics.spotLight(float, float, float, float, float, float, float, float, float, float, float),
PGraphics.lightSpecular(float, float, float)public void lightSpecular(float v1,
float v2,
float v3)
PGraphicsOpenGLlightSpecular in class PGraphicsOpenGLv1 - red or hue value (depending on current color mode)v2 - green or saturation value (depending on current color mode)v3 - blue or brightness value (depending on current color mode)PGraphics.specular(float, float, float),
PGraphics.lights(),
PGraphics.ambientLight(float, float, float, float, float, float),
PGraphics.pointLight(float, float, float, float, float, float),
PGraphics.spotLight(float, float, float, float, float, float, float, float, float, float, float)