// // to start osceleton streaming from command line // ./osceleton -w -a 192.168.0.45 -i simpleloop.oni import processing.opengl.*; import oscP5.*; import netP5.*; OscP5 oscP5, oscP5Send; NetAddress myRemoteLocation; PaperDoll[] dolls; int NUM_DOLLS = 4; float MILLIS_PER_FRAME = 33.3333333; 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 drawDollTexture=false; boolean drawDollOutline=true; boolean drawSticks=true; boolean drawMarkers=true; boolean sendOSC=true; boolean printOSC=false; boolean heartOn=false; int ballSize = 10; Hashtable skels = new Hashtable(); ArrayList skFrames[] = (ArrayList[]) new ArrayList[NUM_DOLLS]; int rec_id=0; boolean recording=false; int xoffset[] = { -800, -300, 300, 800 }; boolean showlive=true; float speed = 0.4; void setup() { //size(800, 600, OPENGL); //Keep 4/3 aspect ratio, since it matches the kinect's. size(1280, 800, OPENGL); //noCursor(); oscP5 = new OscP5(this, "127.0.0.1", 7110); //oscP5 = new OscP5(this, "192.168.0.231", 7110); oscP5Send = new OscP5(this, 12000); // max/MSP on leo's computer //myRemoteLocation = new NetAddress("127.0.0.1", 7400 ); myRemoteLocation = new NetAddress("192.168.0.127", 7400 ); 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; if((i==rec_id) && recording) { framenum=skFrames[i].size()-1; } else { framenum=(int(millis()/MILLIS_PER_FRAME))%(skFrames[i].size()); } Skeleton s = (Skeleton) skFrames[i].get(framenum); fill(255, 255, 0); if (drawMarkers) { //s.drawSticks(xoffset[i]); s.drawDots(xoffset[i]); } if (drawDoll || drawSticks) { // draw doll pushMatrix(); translate(xoffset[i], 0, 0); scale(width, height, -300.0); dolls[rec_id].calcScreenCoords(s); //dolls[rec_id].printScreenCoords(); popMatrix(); if (drawSticks) dolls[rec_id].drawSticks(); dolls[rec_id].constrainCoords(); if(sendOSC) dolls[rec_id].sendCoords(rec_id); if (drawDoll) { //dolls[rec_id].printConstrainedCoords(); pushMatrix(); 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); // heartlight if(sendOSC) sendHeartBeat(); } void sendHeartBeat() { OscMessage myMessage = new OscMessage("/heartlight"); //myMessage.add(i); if(heartOn) { myMessage.add(1.0); /* add an int to the osc message */ } else { myMessage.add(0.0); } heartOn=!heartOn; /* send the message */ oscP5Send.send(myMessage, myRemoteLocation); } 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': if(skFrames[rec_id].size()>0) 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; } }