##yourLibrary## v##versionNumber##

A library by ##author## for the programming environment processing. Last update, ##date##.

Patchy provides an easy-to-use bicubic patch for 3D graphics in the Processing programming environment.

Acknowledgements

I learned how to calculate bicubic surfaces by reading the course material that Ken Perlin so kindly provides. Part of Patchy is based on his code, and I am very grateful for it.

I learned how to calculate vertex normals, and how to choose vertexes for triangles when rendering, by studying this code, by Tomasz Kaczmarzyk (tom3k). Tomasz was kind enough to explicitly license that code under the Apache 2.0 license, so that I could freely share my work. Thank you, tom3k.

Download

Download ##yourLibrary## version ##versionNumber## in .zip format.

Installation

Unzip and put the extracted ##yourLibrary## folder into the libraries folder of your processing sketches. Reference and examples are included in the ##yourLibrary## folder.

Patch Types (Basis Matrices)

Patchy.BEZIER
Patchy.BSPLINE
Patchy.CATMULL_ROM
Patchy.HERMITE

Constructing a Patch or PatchGroup

// control points as a 4x4 matrix of PVectors
Patch.create(double[][] basis, PVector[][] controlPoints, int gridSteps);
Patch.create(double[][] basis, PVector[][] controlPoints);  // default 20 grid steps

// control points as three 4x4 matrices of x, y, and z coordinates
Patch.create(double[][] basis,
             double[][] cpX, double[][] cpY, double[][] cpZ,
             int gridSteps);
Patch.create(double[][] basis,
             double[][] cpX, double[][] cpY, double[][] cpZ);

// the same but with floats, which are more Processing-friendly
Patch.create(double[][] basis,
             float[][] cpX, float[][] cpY, float[][] cpZ,
             int gridSteps);
Patch.create(double[][] basis,
             float[][] cpX, float[][] cpY, float[][] cpZ);

PatchGroup group = new PatchGroup();
group.add(p1);
group.add(p2);

Drawing a Patch or PatchGroup

void draw(PApplet p); // uses current stroke, fill, and transforms
void drawControlPoints(PApplet p);  // useful for debugging

Other Useful Methods on Patch and PatchGroup

BoundingVolume getBounds();  // for figuring out scale and position
BoundingVolume scale(double s); // scales the patch or group in-place
void translate(double dx, double dy, double dz);  // translates the patch or group in-place
void setBasis(double[][] basisMatrix);
void setGridSteps(int steps); // change the resolution of the rendered mesh

Methods on Patch (but not PatchGroup)

void set(int row, int col, double xVal, double yVal, double zVal);
void set(int row, int col, PVector p);
void setX(int row, int col, double val);
void setY(int row, int col, double val);
void setZ(int row, int col, double val);

Keywords ##keywords##

Reference. Have a look at the javadoc reference here. a copy of the reference is included in the .zip as well.

Source. The source code of ##yourLibrary## is available at ##source:host##, and its repository can be browsed here. Fork it and fix it!

Examples

Find a list of examples in the current distribution of ##yourLibrary##, or have a look at them by following the links below.

    ##examples##

Tested

Platform ##tested:platform##
Processing ##tested:processingVersion##
Dependencies ##tested:dependencies##