Spin3d spin = new Spin3d(); PFont font; Figure fig; FPS fps = new FPS(); void setup() { size(400,400); framerate(30); depth(); font = loadFont("font.vlw"); textFont(font,10); angleMode(DEGREES); hint(DISABLE_SMOOTH_HACK); fig = new Figure(1.0f); updateActive(0); //fig.updateUp(); ellipseMode(CENTER); // smooth(); } void text(String s, float x, float y) { for (int i=0; i=fig.joints.length) active = 0; fig.joints[active].active = true; } void draw() { background(240); noStroke(); push(); translate(width/2,height/2); scale(80); spin.update(); spin.apply(); fig.draw(); pop(); push(); fig.draw2d(); translate(5,10); fig.drawTitles(); pop(); fps.frame(); text(fps.fps+"[30]fps",width-45,10); } void mouseDragged() { spin.mouseMoved(); } class Figure extends Joint { public Joint joints[]; public Figure(float scale) { super("Root",true,0,1,0,0,scale, new Joint[]{ new Joint("Stomach",true,0,0,-1, 0.8f, 1.0f, new Joint[]{ new Joint("Chest",false,0,0,-1, 0.5f, 1.0f, new Joint[]{ new Joint("Neck",false,0,0,-1, 0.3f), new Joint("Right Shoulder",true,1,0,0, 0.4f, 1.0f, new Joint[]{ new Joint("Right Upper Arm",false,1,0,0,0.7f, 1.0f, new Joint[]{ new Joint("Right Lower Arm",false,1,0,0,0.7f) }) }), new Joint("Left Shoulder",true,-1,0,0, 0.4f, 1.0f, new Joint[]{ new Joint("Left Upper Arm",false,-1,0,0,0.7f, 1.0f, new Joint[]{ new Joint("Left Lower Arm",false,-1,0,0,0.7f) }) }) }) }), new Joint("Right Hip",true,1,0,0.2f, 0.3f, 1.0f, new Joint[]{ new Joint("Right Upper Leg",false,0.2f,0.2f,0.5f,1.0f, 1.0f, new Joint[]{ new Joint("Right Lower Leg",false,0,0,1,1.0f,1.0f, new Joint[]{ new Joint("Right Foot",false,0,1,0.0001f,0.3f) }) }) }), new Joint("Left Hip",true,-1,0,0.2f, 0.3f, 1.0f, new Joint[]{ new Joint("Left Upper Leg",false,0,0,1,1.0f, 1.0f, new Joint[]{ new Joint("Left Lower Leg",false,0,0,1,1.0f,1.0f, new Joint[]{ new Joint("Left Foot",false,0,1,0.0001f,0.3f) }) }) }), } ); joints = getJointList(); } } class Joint { String label; float lx, ly, lz, scale, length; float ux=0,uy=1,uz=0; float x,y,z; boolean active = false; boolean locked = false; Joint parent = null; public Joint(String label, boolean locked, float lx, float ly, float lz, float length) { this(label,locked,lx,ly,lz,length,1.0f,null); } public Joint(String label,boolean locked, float lx, float ly, float lz, float length, float scale, Joint children[]) { this.label = label; this.locked = locked; this.length = length; this.scale = scale; this.lx = lx; this.ly = ly; this.lz = lz; if (children==null) children = new Joint[]{}; this.children = children; for (int i =0; i