Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jdf/patchy
base: 312d64b219
...
head fork: jdf/patchy
compare: 591b2278a4
  • 2 commits
  • 13 files changed
  • 0 commit comments
  • 1 contributor
View
1  .gitignore
@@ -3,4 +3,5 @@ distribution
reference
examples/*/applet
web/Patchy.jar
+web/patchy.jar
web/PeasyCam.jar
View
36 README.textile
@@ -19,19 +19,11 @@ void draw() {
h2. Acknowledgements
-I learned how to calculate bicubic surfaces by reading the
-"course material":http://mrl.nyu.edu/~perlin/courses/spring2009/splines4.html
-that
-"Ken Perlin":http://www.mrl.nyu.edu/~perlin/ so kindly provides.
-Part of Patchy is based on "his code":http://mrl.nyu.edu/~perlin/cubic/Cubic_java.html,
-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":http://tom3k.info/processing/bicubic_patch/bicubic_patch.pde,
-by "Tomasz Kaczmarzyk":http://tom3k.info/ (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.
+I learned how to calculate bicubic surfaces by reading the "course material":http://mrl.nyu.edu/~perlin/courses/spring2009/splines4.html that "Ken Perlin":http://www.mrl.nyu.edu/~perlin/ so kindly provides.
+
+Part of Patchy is based on "his code":http://mrl.nyu.edu/~perlin/cubic/Cubic_java.html, 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":http://tom3k.info/processing/bicubic_patch/bicubic_patch.pde, by "Tomasz Kaczmarzyk":http://tom3k.info/ (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.
h2. Patch Types (Basis Matrices)
@@ -47,17 +39,17 @@ 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,
+Patch.create(double[][] basis,
+ double[][] cpX, double[][] cpY, double[][] cpZ,
int gridSteps);
-Patch.create(double[][] basis,
+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,
+Patch.create(double[][] basis,
+ float[][] cpX, float[][] cpY, float[][] cpZ,
int gridSteps);
-Patch.create(double[][] basis,
+Patch.create(double[][] basis,
float[][] cpX, float[][] cpY, float[][] cpZ);
PatchGroup group = new PatchGroup();
@@ -73,7 +65,7 @@ h2. Other Useful Methods on Patch and PatchGroup
<pre>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,
+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</pre>
@@ -89,5 +81,5 @@ void setZ(int row, int col, double val);
// set the number of vertices created when rendering patch as triangles
void setGridSteps(int gridSteps);</pre>
-Are you looking for the "Patchy" extension to the Mantis bug-tracking system?
-That's "on sourceforge":http://sourceforge.net/projects/patchy/.
+Are you looking for the "Patchy" extension to the Mantis bug-tracking system?
+That's "on sourceforge":http://sourceforge.net/projects/patchy/.
View
372 build.xml
@@ -1,207 +1,167 @@
-<project name="processingLibs" default="build">
-
- <description>
- Patchy build
- </description>
-
- <property name="processing" location="../processing-1.5.1" />
- <property name="processingLibraries" location="C:/Documents and Settings/Administrator/My Documents/Processing/libraries" />
-
- <property name="libraryClasspath" location="${processing}/lib" />
- <path id="library-classpath">
- <fileset dir="${libraryClasspath}">
- <include name="core.jar" />
- </fileset>
- </path>
-
- <property name="javaVersion" value="1.5" />
-
- <property file="library.properties" prefix="library" />
-
- <property name="author" value="Jonathan Feinberg" />
- <property name="copyright" value="(c) 2011" />
- <property name="libraryName" value="patchy" />
- <property name="yourLink" value="http://mrfeinberg.com/" />
- <property name="keywords" value="bicubic,patch,Bezier,Hermite,Catmull-Rom,BSpline,parametric surface" />
- <property name="tested:platform" value="Windows" />
- <property name="tested:processingVersion" value="1.5.1" />
- <property name="tested:dependencies" value="" />
- <property name="source:host" value="GitHub" />
- <property name="source:url" value="http://github.com/jdf/patchy/" />
- <property name="source:repository" value="http://github.com/jdf/patchy/" />
-
- <!-- no changes or adjustments required below -->
-
- <taskdef resource="net/sf/antcontrib/antcontrib.properties">
- <classpath>
- <pathelement location="./resources/code/ant-contrib-1.0b3.jar" />
- </classpath>
- </taskdef>
- <property name="jarFile" value="patchy.jar" />
- <property name="src" location="src" />
- <property name="bin" location="bin" />
- <property name="reference" location="reference" />
- <property name="dist" location="distribution" />
-
- <target name="init">
- <echo>Properties initialized.
- src path ${src}
- bin path ${bin}
- libraryClasspath ${libraryClasspath}
- processing Libraries ${processingLibraries}
- java version ${javaVersion}
- </echo>
- <echo>building library ...</echo>
- <!-- Create the time stamp -->
- <tstamp>
- <format property="date" pattern="MM/dd/yyyy" offset="0" unit="hour" />
- </tstamp>
- <mkdir dir="${dist}" />
- </target>
-
- <target name="pushweb" depends="build">
- <exec executable="sh" dir="distribution/web">
- <arg value="-c"/>
- <arg value="chmod -R +rwX *"/>
- </exec>
- <exec executable="sh" dir="distribution/web">
- <arg value="-c"/>
- <arg value="rsync -azv --exclude .svn --delete -e ssh * jdf@mrfeinberg.com:/var/www/html/mrfeinberg.com/patchy"/>
- </exec>
- <exec executable="sh" dir="distribution/web">
- <arg value="-c"/>
- <arg value="ssh jdf@mrfeinberg.com chmod -R a+rX /var/www/html/mrfeinberg.com/patchy"/>
- </exec>
- </target>
-
- <!-- compile the library -->
- <target name="compile" depends="init" description="compile the source">
- <echo message="bin: ${bin}"/>
- <echo message="javaVersion: ${javaVersion}"/>
- <echo message="library-classpath$ ${library-classpath}"/>
- <mkdir dir="${bin}"/>
- <javac target="${javaVersion}" destdir="${bin}" source="${javaVersion}">
- <classpath>
- <path refid="library-classpath" />
- </classpath>
- <src path="${src}" />
- </javac>
- </target>
-
- <!-- build the distribution of the library -->
- <target name="build" depends="compile" description="generate the distribution">
- <!-- delete the previous content of the ${dist} folder -->
- <delete dir="${dist}" />
-
- <!-- build the structure for ${dist} -->
- <mkdir dir="${dist}" />
-
- <property name="realDist" value="${dist}/patchy"/>
- <mkdir dir="${realDist}" />
-
- <mkdir dir="${realDist}/library" />
- <mkdir dir="${realDist}/examples" />
- <mkdir dir="${realDist}/reference" />
- <mkdir dir="${realDist}/src" />
- <jar jarfile="${realDist}/library/${jarFile}" basedir="${bin}" />
-
- <copy todir="${realDist}" file="library.properties"/>
-
- <copy todir="${realDist}/examples">
- <fileset dir="examples" />
- </copy>
- <copy todir="${realDist}/src">
- <fileset dir="src" />
- </copy>
- <copy todir="web" file="${realDist}/library/${jarFile}"/>
-
- <!-- create the java reference of the library -->
- <mkdir dir="${reference}" />
- <javadoc bottom="processing library ${libraryName} by ${author}. ${copyright}" classpath="${libraryClasspath}/core.jar" destdir="${reference}" verbose="false" stylesheetfile="resources/stylesheet.css" doctitle="Javadocs: ${libraryName}" public="true" version="false" windowtitle="Javadocs: ${libraryName}">
- <taglet name="ExampleTaglet" path="resources/code" />
- <fileset dir="${src}" defaultexcludes="yes">
- <include name="**/*" />
- <exclude name="**/*.bpt.gz" />
- </fileset>
- </javadoc>
-
- <copy todir="${realDist}/reference">
- <fileset dir="${reference}" />
- </copy>
-
- <!-- copy the jar file to processing's libraries -->
- <copy todir="${processingLibraries}">
- <fileset dir="${dist}" />
- </copy>
-
- <!-- zip the distribution of the library -->
- <zip destfile="${dist}/${libraryName}.zip" basedir="${dist}" excludes="**/_DS.Store,**/applet/**" />
-
- <copy file="${dist}/${libraryName}.zip" tofile="${dist}/${libraryName}_${library.version}.zip" />
-
- <!-- organize the ${dist} folder -->
- <mkdir dir="${dist}/web" />
- <move todir="${dist}/web/reference">
- <fileset dir="${realDist}/reference" />
- </move>
-
- <move todir="${dist}/web/examples">
- <fileset dir="${realDist}/examples" />
- </move>
-
- <delete dir="${dist}/library" />
-
- <copy todir="${dist}/web">
- <fileset dir="web" />
- </copy>
-
- <copy tofile="${dist}/web/patchy.txt" file="library.properties"/>
-
- <replaceregexp file="${dist}/web/index.html" match="##yourLibrary##" replace="${libraryName}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##author##" replace="${author}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##versionNumber##" replace="${library.version}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##yourLink##" replace="${yourLink}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##date##" replace="${date}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##keywords##" replace="${keywords}" flags="g" />
-
- <replaceregexp file="${dist}/web/index.html" match="##tested:platform##" replace="${tested:platform}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##tested:processingVersion##" replace="${tested:processingVersion}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##tested:dependencies##" replace="${tested:dependencies}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##source:host##" replace="${source:host}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##source:url##" replace="${source:url}" flags="g" />
- <replaceregexp file="${dist}/web/index.html" match="##source:repository##" replace="${source:repository}" flags="g" />
-
- <echo>---------------------</echo>
- <antcall target="processExamples" />
- <echo>---------------------</echo>
-
- <replaceregexp file="${dist}/web/index.html" match="##examples##" replace="" flags="g" />
-
-
- <!-- finish organizating library's distribution -->
- <copy file="${dist}/${libraryName}.zip" todir="${dist}/web" />
- <copy file="${dist}/${libraryName}_${library.version}.zip" todir="${dist}/web" />
-
- <copy todir="${processingLibraries}/patchy/reference">
- <fileset dir="${reference}" />
- </copy>
-
- <!-- done, finished. -->
- <echo>done, finished.</echo>
- </target>
-
-
-
- <!-- parsing the examples folder -->
- <target name="processExamples">
- <dirset id="examples.contents" dir="examples" excludes="*/*" />
- <property name="examples.list" refid="examples.contents" />
- <foreach list="${examples.list}" target="addExamples" param="exampleDir" delimiter=";">
- </foreach>
- </target>
-
- <target name="addExamples">
- <replaceregexp file="${dist}/web/index.html" match="(##examples##)" replace="&lt;li&gt;&lt;a href=&quot;examples/${exampleDir}/applet/index.html&quot;&gt;${exampleDir}&lt;/a&gt;&lt;/li&gt; \1" flags="g" />
- </target>
+<project default="build" name="processingLibs">
+ <description>Patchy build</description>
+
+ <property location="../processing" name="processing"/>
+
+ <path id="library-classpath">
+ <fileset dir="${processing}/core/library">
+ <include name="core.jar"/>
+ </fileset>
+ </path>
+
+ <property file="library.properties" prefix="library"/>
+
+ <property name="javaVersion" value="1.6"/>
+
+ <property name="author" value="Jonathan Feinberg"/>
+ <property name="copyright" value="(c) 2013"/>
+ <property name="libraryName" value="patchy"/>
+ <property name="yourLink" value="http://mrfeinberg.com/"/>
+ <property name="keywords" value="bicubic,patch,Bezier,Hermite,Catmull-Rom,BSpline,parametric surface"/>
+ <property name="tested:platform" value="Windows"/>
+ <property name="tested:processingVersion" value="2.0"/>
+ <property name="tested:dependencies" value=""/>
+ <property name="source:host" value="GitHub"/>
+ <property name="source:url" value="http://github.com/jdf/patchy/"/>
+ <property name="source:repository" value="http://github.com/jdf/patchy/"/>
+
+ <!-- no changes or adjustments required below -->
+
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties">
+ <classpath>
+ <pathelement location="./resources/code/ant-contrib-1.0b3.jar"/>
+ </classpath>
+ </taskdef>
+
+ <property name="jarFile" value="patchy.jar"/>
+ <property location="src" name="src"/>
+ <property location="bin" name="bin"/>
+ <property location="reference" name="reference"/>
+ <property location="distribution" name="dist"/>
+
+ <target name="init">
+ <echo>Properties initialized.
+ src path ${src}
+ bin path ${bin}
+ libraryClasspath ${libraryClasspath}
+ java version ${javaVersion}</echo>
+ <echo>building library ...</echo>
+ <tstamp>
+ <format offset="0" pattern="MM/dd/yyyy" property="date" unit="hour"/>
+ </tstamp>
+ <mkdir dir="${dist}"/>
+ </target>
+
+ <target name="pushweb" depends="build">
+ <exec dir="distribution/web" executable="sh">
+ <arg value="-c"/>
+ <arg value="chmod -R +rwX *"/>
+ </exec>
+ <exec dir="distribution/web" executable="sh">
+ <arg value="-c"/>
+ <arg value="rsync -azv --exclude .svn --delete -e ssh * jdf@mrfeinberg.com:/var/www/html/mrfeinberg.com/patchy"/>
+ </exec>
+ <exec dir="distribution/web" executable="sh">
+ <arg value="-c"/>
+ <arg value="ssh jdf@mrfeinberg.com chmod -R a+rX /var/www/html/mrfeinberg.com/patchy"/>
+ </exec>
+ </target>
+
+ <!-- compile the library -->
+ <target name="compile" depends="init" description="compile the source">
+ <echo message="bin: ${bin}"/>
+ <echo message="javaVersion: ${javaVersion}"/>
+ <echo message="library-classpath$ ${library-classpath}"/>
+ <mkdir dir="${bin}"/>
+ <javac destdir="${bin}" source="${javaVersion}" target="${javaVersion}">
+ <classpath>
+ <path refid="library-classpath"/>
+ </classpath>
+ <src path="${src}"/>
+ </javac>
+ <copy toDir="${bin}">
+ <fileset dir="src" excludes="**/*.java" />
+ </copy>
+ </target>
+
+ <!-- build the distribution of the library -->
+ <target depends="compile" description="generate the distribution" name="build">
+ <!-- delete the previous content of the ${dist} folder -->
+ <delete dir="${dist}"/>
+ <!-- build the structure for ${dist} -->
+ <mkdir dir="${dist}"/>
+ <property name="realDist" value="${dist}/patchy"/>
+ <mkdir dir="${realDist}"/>
+ <mkdir dir="${realDist}/library"/>
+ <mkdir dir="${realDist}/examples"/>
+ <mkdir dir="${realDist}/reference"/>
+ <mkdir dir="${realDist}/src"/>
+ <jar basedir="${bin}" jarfile="${realDist}/library/${jarFile}"/>
+ <copy file="library.properties" todir="${realDist}"/>
+ <copy todir="${realDist}/examples">
+ <fileset dir="examples"/>
+ </copy>
+ <copy todir="${realDist}/src">
+ <fileset dir="src"/>
+ </copy>
+ <copy file="${realDist}/library/${jarFile}" todir="web"/>
+ <!-- create the java reference of the library -->
+ <mkdir dir="${reference}"/>
+ <javadoc bottom="processing library ${libraryName} by ${author}. ${copyright}" classpath="${libraryClasspath}/core.jar" destdir="${reference}" doctitle="Javadocs: ${libraryName}" public="true" stylesheetfile="resources/stylesheet.css" verbose="false" version="false" windowtitle="Javadocs: ${libraryName}">
+ <taglet name="ExampleTaglet" path="resources/code"/>
+ <fileset defaultexcludes="yes" dir="${src}">
+ <include name="**/*"/>
+ <exclude name="**/*.bpt.gz"/>
+ </fileset>
+ </javadoc>
+ <copy todir="${realDist}/reference">
+ <fileset dir="${reference}"/>
+ </copy>
+ <!-- zip the distribution of the library -->
+ <zip basedir="${dist}" destfile="${dist}/${libraryName}.zip" excludes="**/_DS.Store,**/applet/**"/>
+ <copy file="${dist}/${libraryName}.zip" tofile="${dist}/${libraryName}_${library.version}.zip"/>
+ <!-- organize the ${dist} folder -->
+ <mkdir dir="${dist}/web"/>
+ <move todir="${dist}/web/reference">
+ <fileset dir="${realDist}/reference"/>
+ </move>
+ <copy todir="${dist}/web/examples">
+ <fileset dir="${realDist}/examples"/>
+ </copy>
+ <delete dir="${dist}/library"/>
+ <copy todir="${dist}/web">
+ <fileset dir="web"/>
+ </copy>
+ <copy file="library.properties" tofile="${dist}/web/patchy.txt"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##yourLibrary##" replace="${libraryName}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##author##" replace="${author}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##versionNumber##" replace="${library.version}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##yourLink##" replace="${yourLink}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##date##" replace="${date}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##keywords##" replace="${keywords}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##tested:platform##" replace="${tested:platform}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##tested:processingVersion##" replace="${tested:processingVersion}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##tested:dependencies##" replace="${tested:dependencies}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##source:host##" replace="${source:host}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##source:url##" replace="${source:url}"/>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##source:repository##" replace="${source:repository}"/>
+ <echo>---------------------</echo>
+ <antcall target="processExamples"/>
+ <echo>---------------------</echo>
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="##examples##" replace=""/>
+ <!-- finish organizating library's distribution -->
+ <copy file="${dist}/${libraryName}.zip" todir="${dist}/web"/>
+ <copy file="${dist}/${libraryName}_${library.version}.zip" todir="${dist}/web"/>
+ <!-- done, finished. -->
+ <echo>done, finished.</echo>
+ </target>
+ <!-- parsing the examples folder -->
+ <target name="processExamples">
+ <dirset dir="examples" excludes="*/*" id="examples.contents"/>
+ <property name="examples.list" refid="examples.contents"/>
+ <foreach delimiter=";" list="${examples.list}" param="exampleDir" target="addExamples"/>
+ </target>
+ <target name="addExamples">
+ <replaceregexp file="${dist}/web/index.html" flags="g" match="(##examples##)" replace="&lt;li&gt;&lt;a href=&quot;examples/${exampleDir}/applet/index.html&quot;&gt;${exampleDir}&lt;/a&gt;&lt;/li&gt; \1"/>
+ </target>
</project>
-
View
78 examples/HelloPatchy/HelloPatchy.pde
@@ -9,39 +9,37 @@ int selectedBasis = 1;
int selectedFill = 1;
PImage paper, dude;
-void setup()
-{
+void setup() {
size(400, 400, P3D);
- try
- {
+ try {
textFont(new PFont(createInput("TheSans-Plain-12.vlw")), 12);
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
e.printStackTrace();
}
- final double[][] cpX = new double[][] { { 23, 41, 59, 77 }, { 23, 41, 59, 77 },
- { 23, 41, 59, 77 }, { 23, 41, 59, 77 } };
+ final double[][] cpX = new double[][] { { 23, 41, 59, 77 },
+ { 23, 41, 59, 77 }, { 23, 41, 59, 77 }, { 23, 41, 59, 77 }
+ };
final double[][] cpY = new double[][] { { 0, 0, 0, 0 }, { 0, 40, 40, 0 },
- { 0, 40, 40, 0 }, { 0, 0, 0, 0 } };
+ { 0, 40, 40, 0 }, { 0, 0, 0, 0 }
+ };
final double[][] cpZ = new double[][] { { 23, 23, 23, 23 }, { 41, 41, 41, 41 },
- { 59, 59, 59, 59 }, { 77, 77, 77, 77 } };
+ { 59, 59, 59, 59 }, { 77, 77, 77, 77 }
+ };
patch = Patch.create(Patch.BEZIER, cpX, cpY, cpZ);
bounds = patch.getBounds();
scale = width / bounds.boundingSphereRadius();
cam = new PeasyCam(this, bounds.x.center() * scale, bounds.y.center() * scale
- - 50, bounds.z.center() * scale, width);
- cam.setMinimumDistance(width/2);
+ - 50, bounds.z.center() * scale, width);
+ cam.setMinimumDistance(width / 2);
paper = loadImage("smallpaper.jpg");
dude = loadImage("gabeface.jpg");
}
-public void draw()
-{
+public void draw() {
animateControlPoints();
background(0);
@@ -60,19 +58,17 @@ public void draw()
if (selectedFill == 1 || selectedFill == 4) {
noStroke();
pointLight(160, 160, 160, bounds.x.center() + 3 * bounds.boundingSphereRadius(),
- -(bounds.y.center() + bounds.boundingSphereRadius()), bounds.z.center());
+ -(bounds.y.center() + bounds.boundingSphereRadius()), bounds.z.center());
patch.draw(this, selectedFill == 1 ? paper : dude);
- }
- else if (selectedFill == 2) {
+ } else if (selectedFill == 2) {
noStroke();
pointLight(160, 50, 50, bounds.x.center() + 3 * bounds.boundingSphereRadius(),
- -(bounds.y.center() + bounds.boundingSphereRadius()), bounds.z.center());
+ -(bounds.y.center() + bounds.boundingSphereRadius()), bounds.z.center());
fill(160, 160, 40);
patch.draw(this);
- }
- else {
+ } else {
noFill();
- stroke(0, 255, 0);
+ stroke(0, 255, 0);
patch.draw(this);
}
noStroke();
@@ -83,9 +79,8 @@ public void draw()
instructions();
}
-private void instructions()
-{
- textMode(SCREEN);
+private void instructions() {
+ cam.beginHUD();
fill(selectedBasis == 1 ? color(0, 255, 0) : 255);
text("1 - Bezier", 10, 15);
fill(selectedBasis == 2 ? color(0, 255, 0) : 255);
@@ -106,45 +101,38 @@ private void instructions()
fill(255);
text("Drag to look around. Right-drag to zoom.", 10, height - 8);
+ cam.endHUD();
}
-private void animateControlPoints()
-{
+private void animateControlPoints() {
patch.setY(1, 2, 50f * cos(frameCount / 30f));
patch.setY(1, 1, 50f * cos(frameCount / 30f));
patch.setY(2, 1, -50f * cos(frameCount / 20f));
patch.setY(2, 2, -50f * cos(frameCount / 20f));
for (int i = 0; i < 4; i++)
- for (int j = 0; j < 4; j++)
- {
+ for (int j = 0; j < 4; j++) {
if ((i == 1 || i == 2) && (j == 1 || j == 2))
continue;
patch.setY(i, j, 10 * cos((j * PI / 4) + frameCount / ((i + 1) * 10f)));
}
}
-public void keyPressed(final KeyEvent e)
-{
- final char c = e.getKeyChar();
-
- if (c >= '1' && c <= '4') {
- selectedBasis = 1 + c - '1';
-
- if (c == '1')
+public void keyPressed() {
+ if (key >= '1' && key <= '4') {
+ selectedBasis = 1 + key - '1';
+ if (key == '1')
patch.setBasis(Patch.BEZIER);
- else if (c == '2')
+ else if (key == '2')
patch.setBasis(Patch.BSPLINE);
- else if (c == '3')
+ else if (key == '3')
patch.setBasis(Patch.CATMULL_ROM);
- else if (c == '4')
+ else if (key == '4')
patch.setBasis(Patch.HERMITE);
- }
- else if (c >= 'a' && c <= 'd') {
- selectedFill = 1 + c - 'a';
+ } else if (key >= 'a' && key <= 'd') {
+ selectedFill = 1 + key - 'a';
}
-
}
-
+
View
64 examples/Teapot_OpenGL/Teapot_OpenGL.pde → examples/Teapot/Teapot.pde
@@ -1,59 +1,58 @@
-import processing.opengl.*;
-
import peasy.*;
import patchy.*;
Patchy teapot = PatchGroup.teapot();
+PeasyCam cam;
BoundingVolume bounds;
-PImage chex,paper;
+PImage chex, paper;
int selectedFill = 1;
void setup() {
- size(600,600,OPENGL);
+ size(600, 600, P3D);
teapot.setGridSteps(15);
- bounds = teapot.scale((double)width/teapot.getBounds().boundingSphereRadius());
- new PeasyCam(this, bounds.x.center(), bounds.y.center(), bounds.z.center(),bounds.boundingSphereRadius());
+ bounds = teapot.scale((double)width / teapot.getBounds().boundingSphereRadius());
+ cam = new PeasyCam(this,
+ bounds.x.center(), bounds.y.center(), bounds.z.center(),
+ bounds.boundingSphereRadius());
chex = loadImage("checker_green.jpg");
paper = loadImage("smallpaper.jpg");
- try
- {
+ try {
textFont(new PFont(createInput("TheSans-Plain-12.vlw")), 12);
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
e.printStackTrace();
}
}
+
void draw() {
translate(bounds.x.center(), bounds.y.center(), bounds.z.center());
- rotateX(PI/3);
+ rotateX(PI / 3);
translate(-bounds.x.center(), -bounds.y.center(), -bounds.z.center());
background(0);
lights();
- pointLight(100,100,255,100,-100, 200);
- pointLight(255,100,100,100,100, 200);
- pointLight(100,255,100,-100,100, 200);
- pointLight(255,255,255,-100,100, -200);
+ pointLight(100, 100, 255, 100, -100, 200);
+ pointLight(255, 100, 100, 100, 100, 200);
+ pointLight(100, 255, 100, -100, 100, 200);
+ pointLight(255, 255, 255, -100, 100, -200);
noStroke();
fill(160, 160, 160);
- if (selectedFill == 1)
+ if (selectedFill == 1) {
teapot.draw(this, chex);
- else if (selectedFill == 2)
- teapot.draw(this,paper);
- else {
+ } else if (selectedFill == 2) {
+ teapot.draw(this, paper);
+ } else {
if (selectedFill == 4) {
noFill();
- stroke(0,255,0);
+ stroke(0, 255, 0);
}
- teapot.draw(this);
+ teapot.draw(this);
}
instructions();
}
-private void instructions()
-{
- textMode(SCREEN);
+
+private void instructions() {
+ cam.beginHUD();
fill(selectedFill == 1 ? color(0, 255, 0) : 255);
text("a - Checkerboard", 10, 15);
@@ -66,16 +65,11 @@ private void instructions()
fill(255);
text("Drag to look around. Right-drag to zoom. Double-click to restore.", 10, height - 8);
+ cam.endHUD();
}
-public void keyPressed(final KeyEvent e)
-{
- final char c = e.getKeyChar();
- if (c >= 'a' && c <= 'd') {
- selectedFill = 1 + c - 'a';
- }
+public void keyPressed() {
+ if (key >= 'a' && key <= 'd') {
+ selectedFill = 1 + key - 'a';
+ }
}
-
-
-
-
View
0  ...ples/Teapot_P3D/data/TheSans-Plain-12.vlw → examples/Teapot/data/TheSans-Plain-12.vlw
File renamed without changes
View
0  examples/Teapot_P3D/data/checker_green.jpg → examples/Teapot/data/checker_green.jpg
File renamed without changes
View
0  examples/Teapot_P3D/data/smallpaper.jpg → examples/Teapot/data/smallpaper.jpg
File renamed without changes
View
BIN  examples/Teapot_OpenGL/data/TheSans-Plain-12.vlw
Binary file not shown
View
BIN  examples/Teapot_OpenGL/data/checker_green.jpg
Deleted file not rendered
View
BIN  examples/Teapot_OpenGL/data/smallpaper.jpg
Deleted file not rendered
View
78 examples/Teapot_P3D/Teapot_P3D.pde
@@ -1,78 +0,0 @@
-import peasy.*;
-import patchy.*;
-
-Patchy teapot = PatchGroup.teapot();
-BoundingVolume bounds;
-PImage chex,paper;
-int selectedFill = 1;
-
-void setup() {
- size(600,600,P3D);
- teapot.setGridSteps(15);
- bounds = teapot.scale((double)width/teapot.getBounds().boundingSphereRadius());
- new PeasyCam(this, bounds.x.center(), bounds.y.center(), bounds.z.center(),bounds.boundingSphereRadius());
- chex = loadImage("checker_green.jpg");
- paper = loadImage("smallpaper.jpg");
- try
- {
- textFont(new PFont(createInput("TheSans-Plain-12.vlw")), 12);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
-}
-void draw() {
- translate(bounds.x.center(), bounds.y.center(), bounds.z.center());
- rotateX(PI/3);
- translate(-bounds.x.center(), -bounds.y.center(), -bounds.z.center());
- background(0);
- lights();
- pointLight(100,100,255,100,-100, 200);
- pointLight(255,100,100,100,100, 200);
- pointLight(100,255,100,-100,100, 200);
-
- noStroke();
- fill(160, 160, 160);
- if (selectedFill == 1)
- teapot.draw(this, chex);
- else if (selectedFill == 2)
- teapot.draw(this,paper);
- else {
- if (selectedFill == 4) {
- noFill();
- stroke(0,255,0);
- }
- teapot.draw(this);
- }
-
- instructions();
-}
-private void instructions()
-{
- textMode(SCREEN);
-
- fill(selectedFill == 1 ? color(0, 255, 0) : 255);
- text("a - Checkerboard", 10, 15);
- fill(selectedFill == 2 ? color(0, 255, 0) : 255);
- text("b - Wallpaper", 10, 30);
- fill(selectedFill == 3 ? color(0, 255, 0) : 255);
- text("c - Solid color", 10, 45);
- fill(selectedFill == 4 ? color(0, 255, 0) : 255);
- text("d - Wireframe", 10, 60);
-
- fill(255);
- text("Drag to look around. Right-drag to zoom. Double-click to restore.", 10, height - 8);
-}
-public void keyPressed(final KeyEvent e)
-{
- final char c = e.getKeyChar();
- if (c >= 'a' && c <= 'd') {
- selectedFill = 1 + c - 'a';
- }
-
-}
-
-
-
-
View
2  library.properties
@@ -3,4 +3,4 @@ authorList = [Jonathan Feinberg](http://mrfeinberg.com/)
url = http://mrfeinberg.com/patchy/
category = 3D
sentence = Patchy provides an easy-to-use bicubic patch for 3D Processing sketches.
-version = 100
+version = 200

No commit comments for this range

Something went wrong with that request. Please try again.