import processing.opengl.*; import oscP5.*; import netP5.*; OscP5 oscP5; PaperDoll[] dolls; int NUM_DOLLS = 4; int [] jointTypes = new int[23]; float zoomF =0.5f; float rotX = radians(180); // by default rotate the whole scene 180deg around the x-axis, // the data from openni comes upside down float rotY = radians(0); boolean drawDoll=false; boolean drawMarkers=true; int ballSize = 10; Hashtable skels = new Hashtable(); ArrayList skFrames[] = (ArrayList[]) new ArrayList[NUM_DOLLS]; int rec_id=0; boolean recording=false; int xoffset[] = { -500, -175, 175, 500 }; boolean showlive=true; float speed = 0.4; void setup() { size(800, 600, OPENGL); //Keep 4/3 aspect ratio, since it matches the kinect's. oscP5 = new OscP5(this, "127.0.0.1", 7110); //oscP5 = new OscP5(this, "192.168.0.231", 7110); textFont(createFont("Verdana", 24)); //hint(ENABLE_OPENGL_4X_SMOOTH); noStroke(); dolls = new PaperDoll[NUM_DOLLS]; println(dolls.length); // cut paper animation for (int i=0;i0)) { int framenum=(int(frameCount*speed))%(skFrames[i].size()); Skeleton s = (Skeleton) skFrames[i].get(framenum); fill(255, 255, 0); if (drawMarkers) { for (float[] j: s.allCoords) { pushMatrix(); translate(j[0]*width+xoffset[i], j[1]*height, -j[2]*300); sphere(2 * ballSize/j[2]); popMatrix(); } } if (drawDoll) { // draw doll pushMatrix(); translate(xoffset[i], 0, 0); scale(width, height, -300.0); dolls[rec_id].calcScreenCoords(s); //dolls[rec_id].printScreenCoords(); popMatrix(); dolls[rec_id].constrainCoords(); //dolls[rec_id].printConstrainedCoords(); pushMatrix(); //translate(-xoffset[i]*0.3, 0, 0); dolls[rec_id].drawDoll(); popMatrix(); } } } else { fill(128); text("recording", 20, 120); } } fill(128); text("character "+(rec_id+1), 20, 30); if (skFrames[rec_id]!=null) text("frames "+skFrames[rec_id].size(), 20, 60); //text("speed "+String.format("%.2g%n", speed), 20, 90); } void keyPressed() { switch(key) { case 'r': recording = !recording; if (recording) { if (skFrames[rec_id]==null) skFrames[rec_id] = new ArrayList(); print("start recording to buffer "); println(rec_id); } else { print("done recording. loop has "); print(skFrames[rec_id].size()-1); println(" frames."); } break; case 'c': skFrames[rec_id].clear(); println("erased all frames"); break; case 'n': rec_id=(rec_id+1)%skFrames.length; break; case 'l': showlive=!showlive; break; case 'd': drawDoll=!drawDoll; break; case 'm': drawMarkers=!drawMarkers; break; case '+': speed+=0.01; break; case '-': speed-=0.01; break; } switch(keyCode) { case LEFT: xoffset[rec_id]-=10; break; case RIGHT: // zoom out xoffset[rec_id]+=10; break; } }