import processing.core.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import java.util.regex.*; public class SoftBody extends PApplet { /** * Soft Body * by Ira Greenberg. * * Softbody dynamics simulation using curveVertex() and curveTightness(). */ // center point float centerX = 0, centerY = 0; float radius = 45, rotAngle = -90; float accelX, accelY; float springing = .0009f, damping = .98f; //corner nodes int nodes = 5; float nodeStartX[] = new float[nodes]; float nodeStartY[] = new float[nodes]; float[]nodeX = new float[nodes]; float[]nodeY = new float[nodes]; float[]angle = new float[nodes]; float[]frequency = new float[nodes]; // soft-body dynamics float organicConstant = 1; public void setup() { size(640, 360); //center shape in window centerX = width/2; centerY = height/2; // iniitalize frequencies for corner nodes for (int i=0; i