From 2395f29308fb424eaf9b9ebb08022568a117b0f0 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 17 Jun 2013 15:32:14 +0100 Subject: back to user pointclouds --- 05_pointcloud/src/testApp.cpp | 281 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 05_pointcloud/src/testApp.cpp (limited to '05_pointcloud/src/testApp.cpp') diff --git a/05_pointcloud/src/testApp.cpp b/05_pointcloud/src/testApp.cpp new file mode 100644 index 0000000..6532b57 --- /dev/null +++ b/05_pointcloud/src/testApp.cpp @@ -0,0 +1,281 @@ +#include "testApp.h" + +//-------------------------------------------------------------- +void testApp::setup() { + + ofSetLogLevel(OF_LOG_NOTICE); + + verdana.loadFont(ofToDataPath("verdana.ttf"), 10); + + playing=0; + numDevices=2; + + string filename="TRSS_nesbitt_recordings.xml"; + + if( !XML.loadFile(filename) ){ + printf("unable to load recordings, check data/ folder\n"); + }else{ + if(XML.pushTag("TRSS")) { + int num=XML.getNumTags("rec"); + if(num) { + for (int i=0;i eg., this sets it to every second point + + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + + //openNIPlayers[deviceID].stop(); + openNIPlayers[deviceID].setup(true); + openNIPlayers[deviceID].addUserGenerator(); + openNIPlayers[deviceID].setRegister(true); + openNIPlayers[deviceID].start(); + openNIPlayers[deviceID].setBaseUserClass(user); + //openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing][deviceID])); + } + soundplayer.setLoop(false); + startPlayers(); + + //ofSetFrameRate(25.0f); + offset=0.0f; + drawmovies=false;drawcloud=true; + frame=0; +} + +void testApp::startPlayers(){ + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + //openNIPlayers[deviceID].stop(); + //openNIPlayers[deviceID].setup(false); + //openNIPlayers[deviceID].start(); + openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing].data[deviceID])); + openNIPlayers[deviceID].setSpeed(0.01f); + //openNIPlayers[deviceID].setPaused(true); + + + soundplayer.stop(); + + if (recs[playing].audio!=""){ + soundplayer.loadSound(recs[playing].audio); + soundplayer.play(); + soundplayer.setPosition(offset); + } + } +} + +//-------------------------------------------------------------- +void testApp::update(){ + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIPlayers[deviceID].setFrame(frame); + openNIPlayers[deviceID].update(); + } +} + +//-------------------------------------------------------------- +void testApp::draw(){ + ofBackground(50, 50, 50); + ofSetColor(255, 255, 255); + + + + //glEnable(GL_PROGRAM_POINT_SIZE); + //glEnable(GL_POINT_SMOOTH); + //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + + //glPointSize(12.0f); + + + + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + + if (drawmovies) { + ofTranslate(0, deviceID * 400); + //openNIPlayers[deviceID].drawDebug(); + openNIPlayers[deviceID].drawDepth(50, 0,520,390); + openNIPlayers[deviceID].drawImage(600, 0,520,390); + } + + //construct points + //glBegin(GL_POINTS); + //how to find buffer size? + /* + XnStatus xn::DepthGenerator::ConvertProjectiveToRealWorld ( XnUInt32 nCount, + const XnPoint3D aProjective[], + XnPoint3D aRealWorld[] + ) + */ + + if (drawcloud) { + + cam.begin(); + + ofPushMatrix(); + ofRotate(0,1,0,180); + ofTranslate(0,0,1500); + + + + + ofDrawAxis(100); + + int count; + const XnDepthPixel* depthmap=openNIPlayers[deviceID].getDepthGenerator().GetDepthMap(); + int range=2500; + + int dmw=openNIPlayers[deviceID].getWidth(); + + for (int i=0;irange) continue; // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd + //ofColor color = kinect->getColorAt(x,y); //userID); + //if (col) glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a); + // else + + + glColor4ub((unsigned char)255, (unsigned char)255, (unsigned char)255, (unsigned char)255); + glVertex3f(p.x, p.y, p.z); + //if (i==320&&j==160) cerr<<"world point: "<