generativedesign
Class Mesh

java.lang.Object
  extended by processing.core.PApplet
      extended by generativedesign.Mesh
All Implemented Interfaces:
PConstants

public class Mesh
extends PApplet

Basic class for calculating and drawing a mesh. A mesh is a two dimensional grid (u/v-coordinates) which is deformed by using mathematical formulas resulting in three dimensional surfaces.


Field Summary
static int ASTROIDALELLIPSOID
           
static int BOHEMIANDOME
           
static int BOW
           
static int CORKSCREW
           
 int drawMode
           
static int ELLIPTICTORUS
           
static int FIGURE8TORUS
           
 int form
           
static int HORN
           
static int KIDNEY
           
static int LEMNISCAPE
           
static int LIMPETTORUS
           
static int MAEDERSOWL
           
 float maxBrightness
           
 float maxHue
           
 float maxSaturation
           
 float meshAlpha
           
 float meshDistortion
           
 float minBrightness
           
 float minHue
           
 float minSaturation
           
static int PARABOLOID
           
 float[] params
           
static int PLANE
           
static int SHELL
           
static int SINE
           
static int SPHERE
           
static int STEINBACHSCREW
           
static int SUPERFORMULA
           
static int TORUS
           
static int TRIANGULOID
           
static int TRIAXIALTRITORUS
           
static int TUBE
           
 int uCount
           
 float uMax
           
 float uMin
           
 int vCount
           
 float vMax
           
 float vMin
           
 
Fields inherited from class processing.core.PApplet
args, ARGS_DISPLAY, ARGS_EDITOR_LOCATION, ARGS_EXTERNAL, ARGS_HIDE_STOP, ARGS_LOCATION, ARGS_PRESENT, ARGS_SKETCH_FOLDER, ARGS_STOP_COLOR, ARGS_WINDOW_COLOR, DEFAULT_HEIGHT, DEFAULT_WIDTH, displayHeight, displayWidth, EXTERNAL_MOVE, EXTERNAL_STOP, finished, firstMouse, focused, frame, frameCount, frameRate, g, height, javaPlatform, javaVersion, javaVersionName, key, keyCode, keyEvent, keyPressed, mouseButton, mouseEvent, mousePressed, mouseX, mouseY, pixelDensity, pixelHeight, pixels, pixelWidth, platform, pmouseX, pmouseY, recorder, requestImageMax, useNativeSelect, width
 
Fields inherited from interface processing.core.PConstants
ADD, 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, 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 Summary
Mesh(PApplet theParent)
          Creates a mesh with default form and parameters.
Mesh(PApplet theParent, int theForm)
          Creates a mesh with the given form and default parameters.
Mesh(PApplet theParent, int theForm, float theUMin, float theUMax, float theVMin, float theVMax)
           
Mesh(PApplet theParent, int theForm, int theUCount, int theVCount)
           
Mesh(PApplet theParent, int theForm, int theUCount, int theVCount, float theUMin, float theUMax, float theVMin, float theVMax)
           
 
Method Summary
 PVector calculateAstroidalEllipsoid(float u, float v)
           
 PVector calculateBohemianDome(float u, float v)
           
 PVector calculateBow(float u, float v)
           
 PVector calculateCorkscrew(float u, float v)
           
 PVector calculateEllipticTorus(float u, float v)
           
 PVector calculateFigure8Torus(float u, float v)
           
 PVector calculateHorn(float u, float v)
           
 PVector calculateKidney(float u, float v)
           
 PVector calculateLemniscape(float u, float v)
           
 PVector calculateLimpetTorus(float u, float v)
           
 PVector calculateMaedersOwl(float u, float v)
           
 PVector calculateParaboloid(float u, float v)
           
 PVector calculatePoints(float u, float v)
          Default function for calculating the points of the mesh.
 PVector calculateShell(float u, float v)
           
 PVector calculateSine(float u, float v)
           
 PVector calculateSphere(float u, float v)
           
 PVector calculateSteinbachScrew(float u, float v)
           
 PVector calculateSuperformula(float u, float v)
           
 PVector calculateTorus(float u, float v)
           
 PVector calculateTrianguloid(float u, float v)
           
 PVector calculateTriaxialTritorus(float u, float v)
           
 PVector calculateTube(float u, float v)
           
 void draw()
           
 int getDrawMode()
           
 int getForm()
           
 String getFormName()
           
 float getMaxBrightness()
           
 float getMaxHue()
           
 float getMaxSaturation()
           
 float getMeshAlpha()
           
 float getMeshDistortion()
           
 float getMinBrightness()
           
 float getMinHue()
           
 float getMinSaturation()
           
 float getParam(int theIndex)
           
 float[] getParams()
           
 int getUCount()
           
 float getUMax()
           
 float getUMin()
           
 int getVCount()
           
 float getVMax()
           
 float getVMin()
           
 float logE(float v)
          The processing function log() does not take negative numbers.
 float power(float b, float e)
          The processing function pow() works a bit differently for negative bases.
 void setColorRange(float theMinHue, float theMaxHue, float theMinSaturation, float theMaxSaturation, float theMinBrightness, float theMaxBrightness, float theMeshAlpha)
           
 void setDrawMode(int theMode)
           
 void setForm(int theValue)
           
 void setMaxBrightness(float maxBrightness)
           
 void setMaxHue(float maxHue)
           
 void setMaxSaturation(float maxSaturation)
           
 void setMeshAlpha(float meshAlpha)
           
 void setMeshDistortion(float theValue)
           
 void setMinBrightness(float minBrightness)
           
 void setMinHue(float minHue)
           
 void setMinSaturation(float minSaturation)
           
 void setParam(int theIndex, float theValue)
           
 void setParams(float[] theValues)
           
 void setUCount(int theValue)
           
 void setUMax(float theValue)
           
 void setUMin(float theValue)
           
 void setVCount(int theValue)
           
 void setVMax(float theValue)
           
 void setVMin(float theValue)
           
 void update()
          Updates the points of the mesh.
 
Methods inherited from class processing.core.PApplet
abs, abs, acos, alpha, ambient, ambient, ambient, ambientLight, ambientLight, append, append, append, append, append, append, applyMatrix, applyMatrix, applyMatrix, applyMatrix, applyMatrix, arc, arc, arraycopy, arrayCopy, arraycopy, arrayCopy, arraycopy, arrayCopy, asin, atan, atan2, attrib, attrib, attrib, attribColor, attribNormal, attribPosition, background, background, background, background, background, background, background, beginCamera, beginContour, beginPGL, beginRaw, beginRaw, beginRecord, beginRecord, beginShape, beginShape, bezier, bezier, bezierDetail, bezierPoint, bezierTangent, bezierVertex, bezierVertex, binary, binary, binary, binary, blend, blend, blendColor, blendMode, blue, box, box, brightness, camera, camera, ceil, checkExtension, clear, clip, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, concat, concat, concat, concat, concat, concat, concat, constrain, constrain, copy, copy, copy, cos, createFont, createFont, createFont, createGraphics, createGraphics, createGraphics, createImage, createInput, createInput, createInputRaw, createOutput, createOutput, createPath, createPath, createReader, createReader, createReader, createShape, createShape, createShape, createWriter, createWriter, createWriter, cursor, cursor, cursor, cursor, curve, curve, curveDetail, curvePoint, curveTangent, curveTightness, curveVertex, curveVertex, dataFile, dataPath, day, debug, degrees, delay, desktopFile, desktopPath, die, die, directionalLight, displayDensity, displayDensity, dispose, dist, dist, edge, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endContour, endPGL, endRaw, endRecord, endShape, endShape, exec, exit, exitActual, exitCalled, exp, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, fill, fill, fill, fill, fill, fill, filter, filter, filter, floor, flush, focusGained, focusLost, frameMoved, frameRate, frameResized, frustum, fullScreen, fullScreen, fullScreen, fullScreen, get, get, get, getExtension, getGraphics, getMatrix, getMatrix, getMatrix, getSurface, green, handleDraw, hex, hex, hex, hex, hideMenuBar, hint, hour, hue, image, image, image, imageMode, insertFrame, isLooping, join, join, keyPressed, keyPressed, keyReleased, keyReleased, keyTyped, keyTyped, launch, lerp, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, line, link, loadBytes, loadBytes, loadBytes, loadFont, loadImage, loadImage, loadJSONArray, loadJSONArray, loadJSONObject, loadJSONObject, loadPixels, loadShader, loadShader, loadShape, loadShape, loadStrings, loadStrings, loadStrings, loadStrings, loadTable, loadTable, loadXML, loadXML, log, loop, mag, mag, main, main, main, map, mask, match, matchAll, max, max, max, max, max, max, method, millis, min, min, min, min, min, min, minute, modelX, modelY, modelZ, month, mouseClicked, mouseClicked, mouseDragged, mouseDragged, mouseEntered, mouseEntered, mouseExited, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressed, mouseReleased, mouseReleased, mouseWheel, mouseWheel, nf, nf, nf, nf, nf, nf, nfc, nfc, nfc, nfc, nfp, nfp, nfp, nfp, nfs, nfs, nfs, nfs, noClip, noCursor, noFill, noise, noise, noise, noiseDetail, noiseDetail, noiseSeed, noLights, noLoop, norm, normal, noSmooth, noStroke, noTexture, noTint, orientation, ortho, ortho, ortho, parseBoolean, parseBoolean, parseBoolean, parseBoolean, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseChar, parseChar, parseChar, parseChar, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseJSONArray, parseJSONObject, parseXML, parseXML, pause, perspective, perspective, pixelDensity, point, point, pointLight, popMatrix, popStyle, postEvent, pow, print, print, print, print, print, print, print, print, print, printArray, printCamera, println, println, println, println, println, println, println, println, println, println, println, printMatrix, printProjection, pushMatrix, pushStyle, quad, quadraticVertex, quadraticVertex, radians, random, random, randomGaussian, randomSeed, rect, rect, rect, rectMode, red, redraw, registerMethod, requestImage, requestImage, resetMatrix, resetShader, resetShader, resume, reverse, reverse, reverse, reverse, reverse, reverse, reverse, rotate, rotate, rotateX, rotateY, rotateZ, round, runSketch, saturation, save, saveBytes, saveBytes, saveBytes, saveFile, saveFrame, saveFrame, saveJSONArray, saveJSONArray, saveJSONObject, saveJSONObject, savePath, saveStream, saveStream, saveStream, saveStream, saveStream, saveStrings, saveStrings, saveStrings, saveTable, saveTable, saveXML, saveXML, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, second, selectFolder, selectFolder, selectFolder, selectFolder, selectFolder, selectInput, selectInput, selectInput, selectInput, selectInput, selectOutput, selectOutput, selectOutput, selectOutput, selectOutput, set, set, setMatrix, setMatrix, setMatrix, setSize, settings, setup, shader, shader, shape, shape, shape, shapeMode, shearX, shearY, shininess, shorten, shorten, shorten, shorten, shorten, shorten, shorten, showDepthWarning, showDepthWarningXYZ, showMethodWarning, showMissingWarning, showVariationWarning, sin, size, size, size, sketchDisplay, sketchFile, sketchFullScreen, sketchHeight, sketchOutputPath, sketchOutputStream, sketchPath, sketchPath, sketchPixelDensity, sketchRenderer, sketchSmooth, sketchWidth, sketchWindowColor, smooth, smooth, sort, sort, sort, sort, sort, sort, sort, sort, sort, sort, specular, specular, specular, sphere, sphereDetail, sphereDetail, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, split, split, splitTokens, splitTokens, spotLight, sq, sqrt, start, stop, str, str, str, str, str, str, str, str, str, str, stroke, stroke, stroke, stroke, stroke, stroke, strokeCap, strokeJoin, strokeWeight, style, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, tan, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textAscent, textDescent, textFont, textFont, textLeading, textMode, textSize, texture, textureMode, textureWrap, textWidth, textWidth, textWidth, thread, tint, tint, tint, tint, tint, tint, translate, translate, triangle, trim, trim, unbinary, unhex, unregisterMethod, updatePixels, updatePixels, urlDecode, urlEncode, vertex, vertex, vertex, vertex, vertex, year
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLANE

public static final int PLANE
See Also:
Constant Field Values

TUBE

public static final int TUBE
See Also:
Constant Field Values

SPHERE

public static final int SPHERE
See Also:
Constant Field Values

TORUS

public static final int TORUS
See Also:
Constant Field Values

PARABOLOID

public static final int PARABOLOID
See Also:
Constant Field Values

STEINBACHSCREW

public static final int STEINBACHSCREW
See Also:
Constant Field Values

SINE

public static final int SINE
See Also:
Constant Field Values

FIGURE8TORUS

public static final int FIGURE8TORUS
See Also:
Constant Field Values

ELLIPTICTORUS

public static final int ELLIPTICTORUS
See Also:
Constant Field Values

CORKSCREW

public static final int CORKSCREW
See Also:
Constant Field Values

BOHEMIANDOME

public static final int BOHEMIANDOME
See Also:
Constant Field Values

BOW

public static final int BOW
See Also:
Constant Field Values

MAEDERSOWL

public static final int MAEDERSOWL
See Also:
Constant Field Values

ASTROIDALELLIPSOID

public static final int ASTROIDALELLIPSOID
See Also:
Constant Field Values

TRIAXIALTRITORUS

public static final int TRIAXIALTRITORUS
See Also:
Constant Field Values

LIMPETTORUS

public static final int LIMPETTORUS
See Also:
Constant Field Values

HORN

public static final int HORN
See Also:
Constant Field Values

SHELL

public static final int SHELL
See Also:
Constant Field Values

KIDNEY

public static final int KIDNEY
See Also:
Constant Field Values

LEMNISCAPE

public static final int LEMNISCAPE
See Also:
Constant Field Values

TRIANGULOID

public static final int TRIANGULOID
See Also:
Constant Field Values

SUPERFORMULA

public static final int SUPERFORMULA
See Also:
Constant Field Values

form

public int form

uMin

public float uMin

uMax

public float uMax

uCount

public int uCount

vMin

public float vMin

vMax

public float vMax

vCount

public int vCount

params

public float[] params

drawMode

public int drawMode

minHue

public float minHue

maxHue

public float maxHue

minSaturation

public float minSaturation

maxSaturation

public float maxSaturation

minBrightness

public float minBrightness

maxBrightness

public float maxBrightness

meshAlpha

public float meshAlpha

meshDistortion

public float meshDistortion
Constructor Detail

Mesh

public Mesh(PApplet theParent)
Creates a mesh with default form and parameters.

Parameters:
theParent - Reference to a PApplet. Typically use "this"

Mesh

public Mesh(PApplet theParent,
            int theForm)
Creates a mesh with the given form and default parameters.

Parameters:
theParent - Reference to a PApplet. Typically use "this"
theForm - One of the constants or CUSTOM.

Mesh

public Mesh(PApplet theParent,
            int theForm,
            int theUCount,
            int theVCount)
Parameters:
theParent - Reference to a PApplet. Typically use "this"
theForm - One of the constants or CUSTOM.
theUCount - Number of tiles in u direction
theVCount - Number of tiles in v direction

Mesh

public Mesh(PApplet theParent,
            int theForm,
            float theUMin,
            float theUMax,
            float theVMin,
            float theVMax)
Parameters:
theParent - Reference to a PApplet. Typically use "this"
theForm - One of the constants or CUSTOM.
theUMin - Start value for u
theUMax - End value for u
theVMin - Start value for v
theVMax - End value for v

Mesh

public Mesh(PApplet theParent,
            int theForm,
            int theUCount,
            int theVCount,
            float theUMin,
            float theUMax,
            float theVMin,
            float theVMax)
Parameters:
theParent - Reference to a PApplet. Typically use "this"
theForm - One of the constants or CUSTOM.
theUCount - Number of tiles in u direction
theVCount - Number of tiles in v direction
theUMin - Start value for u
theUMax - End value for u
theVMin - Start value for v
theVMax - End value for v
Method Detail

update

public void update()
Updates the points of the mesh. This is automatically called when creating the mesh. It has to be called manually every time that one of the parameters uCount, vCount, uMin, uMax, vMin or vMax has changed.


calculatePoints

public PVector calculatePoints(float u,
                               float v)
Default function for calculating the points of the mesh. It will result in a simple plane. Override this method, if you want to define custom forms (see sketch Mesh_Custom.pde).


calculateTube

public PVector calculateTube(float u,
                             float v)

calculateSphere

public PVector calculateSphere(float u,
                               float v)

calculateTorus

public PVector calculateTorus(float u,
                              float v)

calculateParaboloid

public PVector calculateParaboloid(float u,
                                   float v)

calculateSteinbachScrew

public PVector calculateSteinbachScrew(float u,
                                       float v)

calculateSine

public PVector calculateSine(float u,
                             float v)

calculateFigure8Torus

public PVector calculateFigure8Torus(float u,
                                     float v)

calculateEllipticTorus

public PVector calculateEllipticTorus(float u,
                                      float v)

calculateCorkscrew

public PVector calculateCorkscrew(float u,
                                  float v)

calculateBohemianDome

public PVector calculateBohemianDome(float u,
                                     float v)

calculateBow

public PVector calculateBow(float u,
                            float v)

calculateMaedersOwl

public PVector calculateMaedersOwl(float u,
                                   float v)

calculateAstroidalEllipsoid

public PVector calculateAstroidalEllipsoid(float u,
                                           float v)

calculateTriaxialTritorus

public PVector calculateTriaxialTritorus(float u,
                                         float v)

calculateLimpetTorus

public PVector calculateLimpetTorus(float u,
                                    float v)

calculateHorn

public PVector calculateHorn(float u,
                             float v)

calculateShell

public PVector calculateShell(float u,
                              float v)

calculateKidney

public PVector calculateKidney(float u,
                               float v)

calculateLemniscape

public PVector calculateLemniscape(float u,
                                   float v)

calculateTrianguloid

public PVector calculateTrianguloid(float u,
                                    float v)

calculateSuperformula

public PVector calculateSuperformula(float u,
                                     float v)

power

public float power(float b,
                   float e)
The processing function pow() works a bit differently for negative bases.

Parameters:
b - Base
e - Exponent
Returns:
b to the power of e

logE

public float logE(float v)
The processing function log() does not take negative numbers. Sometimes it is convenient to have this form.

Parameters:
v - Number (may also be negative)
Returns:
Natural logarithm of the number.

draw

public void draw()
Overrides:
draw in class PApplet

getForm

public int getForm()

setForm

public void setForm(int theValue)

getFormName

public String getFormName()

getUMin

public float getUMin()

setUMin

public void setUMin(float theValue)

getUMax

public float getUMax()

setUMax

public void setUMax(float theValue)

getUCount

public int getUCount()

setUCount

public void setUCount(int theValue)

getVMin

public float getVMin()

setVMin

public void setVMin(float theValue)

getVMax

public float getVMax()

setVMax

public void setVMax(float theValue)

getVCount

public int getVCount()

setVCount

public void setVCount(int theValue)

getParams

public float[] getParams()

setParams

public void setParams(float[] theValues)

getParam

public float getParam(int theIndex)

setParam

public void setParam(int theIndex,
                     float theValue)

getDrawMode

public int getDrawMode()

setDrawMode

public void setDrawMode(int theMode)

getMeshDistortion

public float getMeshDistortion()

setMeshDistortion

public void setMeshDistortion(float theValue)

setColorRange

public void setColorRange(float theMinHue,
                          float theMaxHue,
                          float theMinSaturation,
                          float theMaxSaturation,
                          float theMinBrightness,
                          float theMaxBrightness,
                          float theMeshAlpha)

getMinHue

public float getMinHue()

setMinHue

public void setMinHue(float minHue)

getMaxHue

public float getMaxHue()

setMaxHue

public void setMaxHue(float maxHue)

getMinSaturation

public float getMinSaturation()

setMinSaturation

public void setMinSaturation(float minSaturation)

getMaxSaturation

public float getMaxSaturation()

setMaxSaturation

public void setMaxSaturation(float maxSaturation)

getMinBrightness

public float getMinBrightness()

setMinBrightness

public void setMinBrightness(float minBrightness)

getMaxBrightness

public float getMaxBrightness()

setMaxBrightness

public void setMaxBrightness(float maxBrightness)

getMeshAlpha

public float getMeshAlpha()

setMeshAlpha

public void setMeshAlpha(float meshAlpha)


Processing Library generativedesign by Hartmut Bohnacker, Benedikt Gross. (c) 2015