Spin3d spin = new Spin3d(); PFont font; Figure fig; 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); // 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(); fig.draw2d(); translate(5,10); fig.drawTitles(); } void mouseDragged() { spin.mouseMoved(); } class Figure extends Joint { public Joint joints[]; public Figure(float scale) { super("Stomach",0,0,90,0,scale, new Joint[]{ new Joint("LoChest",0,0,-180,0.8f, 1.0f, new Joint[]{ new Joint("UpChest",0,0,0,0.5f, 1.0f, new Joint[]{ new Joint("Neck",0,0,0,0.3f), new Joint("rShoulder",0,0,90, 0.4f, 1.0f, new Joint[]{ new Joint("rUpArm",0,0,0,0.7f, 1.0f, new Joint[]{ new Joint("rLoArm",0,0,0,0.7f) }) }), new Joint("rShoulder",0,0,-90, 0.4f, 1.0f, new Joint[]{ new Joint("rUpArm",0,0,0,0.7f, 1.0f, new Joint[]{ new Joint("rLoArm",0,0,0,0.7f) }) }) }) }), new Joint("rHip",0,0,70, 0.3f, 1.0f, new Joint[]{ new Joint("rUpLeg",0,0,-70,1.0f, 1.0f, new Joint[]{ new Joint("rLoLeg",0,0,0,1.0f,1.0f, new Joint[]{ new Joint("rFoot",90,180,90,0.3f) }) }) }), new Joint("lHip",0,0,-70, 0.3f, 1.0f, new Joint[]{ new Joint("lUpLeg",0,0,70,1.0f, 1.0f, new Joint[]{ new Joint("lLoLeg",0,0,0,1.0f,1.0f, new Joint[]{ new Joint("lFoot",90,180,90,0.3f) }) }) }), } ); joints = getJointList(); } } class Joint { String label; float rotateX, rotateY, rotateZ, scale, length; boolean active = false; public Joint(String label, float rotateX, float rotateY, float rotateZ, float length) { this(label,rotateX,rotateY,rotateZ,length,1.0f,null); } public Joint(String label,float rotateX, float rotateY, float rotateZ, float length, float scale, Joint children[]) { this.label = label; this.length = length; this.scale = scale; this.rotateX = rotateX; this.rotateY = rotateY; this.rotateZ = rotateZ; if (children==null) children = new Joint[] {}; this.children = children; } Joint children[]; float tx,ty,tz; void draw() { push(); scale(scale); rotateX(rotateX); rotateY(rotateY); rotateZ(rotateZ); fill(80); triangle(0,-0.05f, 0,0.05f, length,0); translate(length,0,0); tx = screenX(0,0,0)+8; ty = screenY(0,0,0)+4; fill(active?200:0,0,active?0:200); sphere(0.05f); drawChildren(); pop(); } int size() { int size = 1; for (int i=0; i