package com.haxademic.sketch.three_d;

import com.haxademic.core.app.PAppletHax;
import com.haxademic.core.constants.AppSettings;
import com.haxademic.core.draw.context.DrawUtil;
import com.haxademic.core.draw.shapes.Icosahedron;
import com.haxademic.core.draw.shapes.PShapeUtil;
import com.haxademic.core.math.MathUtil;
import com.haxademic.core.math.easing.Penner;

import processing.core.PShape;
import processing.core.PVector;

public class PShapeQuadraticCurves 
extends PAppletHax {
	public static void main(String args[]) { PAppletHax.main(Thread.currentThread().getStackTrace()[1].getClassName()); }
		
	protected PShape obj;

	protected void overridePropsFile() {
		p.appConfig.setProperty(AppSettings.LOOP_FRAMES, 640);
	}
	
	protected void setupFirstFrame() {
		// build obj PShape and scale to window
		obj = Icosahedron.createIcosahedron(p.g, 3, null);
		PShapeUtil.centerShape(obj);
		PShapeUtil.scaleShapeToExtent(obj, p.height * 0.8f);
	}

	public void drawApp() {		
		background(0);
		p.noFill();
		DrawUtil.setBetterLights(p);
		
		// rotate
		float z = Penner.easeInOutExpo(0.5f + 0.5f * MathUtil.saw(loop.progressRads()), 0, 1, 1);
		p.translate(p.width/2f, p.height/2f, z * -p.width); // -p.width

		// draw mesh with texture or without
		obj.disableStyle();
		p.stroke(255);
		p.strokeWeight(1.8f);
		
		// draw curves
		p.pushMatrix();
		p.rotateY(loop.progressRads());
		drawCurves(obj);
		p.popMatrix();
	}
		
	
	public void drawCurves(PShape shape) {
		for (int i = 0; i < shape.getVertexCount() - 2; i+=3) {
			PVector v1 = shape.getVertex(i);
			PVector v2 = shape.getVertex(i+1);
			PVector v3 = shape.getVertex(i+2);
			
			float eqAmp = 1f + p._audioInput.getFFT().spectrum[ i % p._audioInput.getFFT().spectrum.length ];
			p.stroke(255f * (-0.75f + eqAmp));

			p.beginShape();
			p.vertex(v1.x, v1.y, v1.z);
			p.quadraticVertex(v2.x * eqAmp, v2.y * eqAmp, v2.z * eqAmp, v3.x, v3.y, v3.z);
			p.endShape();

			p.beginShape();
			p.vertex(v2.x, v2.y, v2.z);
			p.quadraticVertex(v1.x * eqAmp, v1.y * eqAmp, v1.z * eqAmp, v3.x, v3.y, v3.z);
			p.endShape();
			
			p.beginShape();
			p.vertex(v1.x, v1.y, v1.z);
			p.quadraticVertex(v3.x * eqAmp, v3.y * eqAmp, v3.z * eqAmp, v2.x, v2.y, v2.z);
			p.endShape();
		}
		for (int j = 0; j < shape.getChildCount(); j++) {
			drawCurves(shape.getChild(j));
		}
	}

}
@@ -123,16 +123,65 @@
 ttings;%0A
+import com.haxademic.core.constants.PBlendModes;%0A
 import c
@@ -721,60 +721,413 @@
 %7B%0A%09%09
-p.appConfig.setProperty(AppSettings.LOOP_FRAMES, 640
+int FRAMES = 640;%0A%09%09p.appConfig.setProperty(AppSettings.WIDTH, 1280);%0A%09%09p.appConfig.setProperty(AppSettings.HEIGHT, 720);%0A%09%09p.appConfig.setProperty(AppSettings.LOOP_FRAMES, FRAMES);%0A%09%09p.appConfig.setProperty(AppSettings.RENDERING_MOVIE, false);%0A%09%09p.appConfig.setProperty(AppSettings.RENDERING_MOVIE_START_FRAME, 1 + FRAMES);%0A%09%09p.appConfig.setProperty(AppSettings.RENDERING_MOVIE_STOP_FRAME, 1 + FRAMES * 2
 );%0A%09
@@ -1409,16 +1409,18 @@
 Fill();%0A
+//
 %09%09DrawUt
@@ -1587,16 +1587,22 @@
 ight/2f,
+ 100 +
  z * -p.
@@ -1665,30 +1665,8 @@
 out%0A
-%09%09obj.disableStyle();%0A
 %09%09p.
@@ -1695,17 +1695,17 @@
 eWeight(
-1
+0
 .8f);%0A%09%09
@@ -2170,16 +2170,114 @@
 eqAmp));
+%0A%09%09%09%0A%09%09%09// override for render%0A%09%09%09// p.blendMode(PBlendModes.ADD);%0A%09%09%09eqAmp = 1;%0A%09%09%09p.stroke(185);
 %0A%0A%09%09%09p.b

Clean up