From 796d647fd38f7cf01cb70bbb0700b75427e42d55 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 28 Oct 2012 17:40:19 +0000 Subject: starting to build kinect addition --- liveengine/src/layers.cpp | 18 +++- liveengine/src/layers.h | 5 +- liveengine/src/main.cpp | 2 +- liveengine/src/playlist.cpp | 54 +++++++--- liveengine/src/playlist.h | 11 ++- liveengine/src/testApp.cpp | 137 ++++++++++++++++++++++---- liveengine/src/testApp.h | 31 +++++- liveengine/src/viewport.cpp | 234 ++++++++++++++++++++++++++++++++++++++++++++ liveengine/src/viewport.h | 28 +++++- 9 files changed, 471 insertions(+), 49 deletions(-) mode change 100644 => 100755 liveengine/src/playlist.h (limited to 'liveengine/src') diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp index 6724255..4ac0c59 100755 --- a/liveengine/src/layers.cpp +++ b/liveengine/src/layers.cpp @@ -38,7 +38,7 @@ void svglayer::draw(float a,int cx,int cy,float colShift) { svg.getPathAt(i).draw(xo,yo); } } - +/* void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) { getCentre(cx,cy); //draw layers tinted by controllers @@ -56,6 +56,22 @@ void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transp svg.getPathAt(i).draw(xo,yo); } } +} +*/ + +void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) { + getCentre(cx,cy); + //draw layers grouped by controllers + float layerspercontroller=((float)svg.getNumPath())/6.0f; + + for (int i=0;i<6;i++) { + for (int j=(int)(i*layerspercontroller);j<(int)((i+1)*layerspercontroller);j++) { + svg.getPathAt(j).setFillColor(fills[i]*a*controllers[i]); + if (!transparentBlack||((a*controllers[i])/127.0)>0.1) { + svg.getPathAt(j).draw(xo,yo); + } + } + } } diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h index 3a7883e..c6f4171 100755 --- a/liveengine/src/layers.h +++ b/liveengine/src/layers.h @@ -1,7 +1,8 @@ #ifndef SVGLAYER_H #define SVGLAYER_H -#include "ofxSVGTiny.h" +#include "ofxSVGTiny.h" +#include "ofMain.h" class layer { @@ -16,7 +17,7 @@ class layer protected: bool isLoaded; private: - + }; class svglayer: public layer diff --git a/liveengine/src/main.cpp b/liveengine/src/main.cpp index dadd89f..f0c0c0f 100755 --- a/liveengine/src/main.cpp +++ b/liveengine/src/main.cpp @@ -7,7 +7,7 @@ int main( ){ ofAppGlutWindow window; - ofSetupOpenGL(ofxFensterManager::get(),2048,768, OF_WINDOW); + ofSetupOpenGL(ofxFensterManager::get(),1024,768, OF_WINDOW); //2048,768 //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); diff --git a/liveengine/src/playlist.cpp b/liveengine/src/playlist.cpp index af44940..51bd852 100755 --- a/liveengine/src/playlist.cpp +++ b/liveengine/src/playlist.cpp @@ -1,11 +1,14 @@ #include "playlist.h" playlist::playlist() -{ +{ + name=""; + thumbnail.allocate(128,128,GL_RGB); + thumbnailed=false; } void playlist::load(string _name){ - printf("loading %s\n",_name.c_str()); + //printf("loading %s\n",_name.c_str()); if( !XML.loadFile(_name) ){ @@ -28,23 +31,42 @@ void playlist::threadedFunction(){ } void playlist::loadsvg(){ - int numLayers=0; - layers.clear(); - if(XML.pushTag("playlist")) { - numLayers=XML.getNumTags("svglayer"); - if(numLayers) { - for (int i=0;i::iterator i=layers.begin(); + i->second->draw(1.0,64,64,0.0); + ofPopMatrix(); + thumbnail.end(); + thumbnailed=true; + } +} + + void playlist::loadimg(){ int numLayers=0; layers.clear(); diff --git a/liveengine/src/playlist.h b/liveengine/src/playlist.h old mode 100644 new mode 100755 index 43982f9..846de74 --- a/liveengine/src/playlist.h +++ b/liveengine/src/playlist.h @@ -4,8 +4,8 @@ #include "ofThread.h" #include "ofxXmlSettings.h" -#include "layers.h" - +#include "layers.h" +#include "ofMain.h" class playlist : public ofThread { public: @@ -14,10 +14,15 @@ class playlist : public ofThread { void loadimg(); void loadsvg(); void load(string _name); - void threadedFunction(); + void threadedFunction(); + void makeThumbnail(); + + ofFbo thumbnail; + bool thumbnailed; ofxXmlSettings XML; map layers; + string name; protected: private: }; diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp index 7f0ff47..8527f73 100755 --- a/liveengine/src/testApp.cpp +++ b/liveengine/src/testApp.cpp @@ -8,7 +8,7 @@ void previewWindow::setBuffer(ofFbo *buffer){ } void previewWindow::draw(){ - rb->draw(0,0,ofGetWidth(),ofGetHeight()); + rb->draw(0,0,ofGetWidth(),ofGetHeight()); //why crash? } //-------------------------------------------------------------- @@ -22,26 +22,103 @@ void guiWindow::setParent(testApp *p){ void guiWindow::draw(){ parent->gui.draw(); + if (parent->list.lock()) { //if loaded + if (!parent->list.thumbnailed) parent->list.makeThumbnail(); + if (parent->list.thumbnailed) parent->list.thumbnail.draw(20,ofGetHeight()-150); + parent->list.unlock(); + } + ofDrawBitmapString(parent->list.name,20,ofGetHeight()-10); } void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ - printf("gui received file:%s\n",dragInfo.files[0].c_str()); + parent->dragEvent(dragInfo); +} +void guiWindow::windowMoved(int x,int y){ + //printf("window moved!\n"); +} + +//---------------------------------------------------------------------- + +kinectWindow::~kinectWindow(){ + cout << "kinect window destroyed" << endl; +} +void kinectWindow::setup(){ +} +void kinectWindow::setParent(testApp *p){ + parent=p; +} +void kinectWindow::draw(){ + parent->recordDepth.draw(0,0,ofGetWidth(),ofGetHeight()); + parent->recordUser.draw(ofGetWidth(),ofGetHeight()); } + //-------------------------------------------------------------- void testApp::setup(){ int midiPort=0; - midiChannel=0; + midiChannel=0; + useKinect=false; if( !XML.loadFile("settings.xml") ){ printf("unable to load settings.xml check data/ folder\n"); }else{ printf("settings loaded!\n"); midiPort=ofToInt(XML.getAttribute("liveEngine", "port", "0")); //default to 0/all - midiChannel=ofToInt(XML.getAttribute("liveEngine", "channel", "0")); - if (midiChannel) printf("listening on port %d, midi channel %d\n",midiPort,midiChannel); - else printf("listening on port %d, all midi channels\n",midiPort); - } - + midiChannel=ofToInt(XML.getAttribute("liveEngine", "channel", "0")); + if (midiChannel) printf("listening on port %d, midi channel %d\n",midiPort,midiChannel); + else printf("listening on port %d, all midi channels\n",midiPort); + if(XML.pushTag("liveEngine")) { + int numViews=XML.getNumTags("viewport"); + if(numViews) { + for (int i=0;icreateFenster(0, 0, 320, 240, OF_WINDOW); + kw->setWindowTitle("kinect"); + kw->addListener(kinectWin); + kinectWin->setup(); + kinectWin->setParent(this); + + isLive = true; + isTracking = false; + isFiltering = false; + isMasking = true; + isCloud = false; + + nearThreshold = 500; + farThreshold = 1000; + + filterFactor = 10.0f; + + recordContext.setup(); + recordDepth.setup(&recordContext); + recordImage.setup(&recordContext); + recordUser.setup(&recordContext); + recordUser.setSmoothing(filterFactor); // built in openni skeleton smoothing... + recordUser.setUseMaskPixels(isMasking); + recordUser.setUseCloudPoints(isCloud); + recordUser.setMaxNumberOfUsers(2); + } + viewports.push_back(new viewport(w,h,x,y,rot,ox,oy)); + viewports[viewports.size()-1]->setUG(&recordUser); + } + else viewports.push_back(new viewport(w,h,x,y,rot,ox,oy)); + } + } + else printf("no viewports!\n"); + } + } + midiIn.listPorts(); midiIn.openPort(midiPort); midiIn.addListener(this); @@ -65,8 +142,8 @@ void testApp::setup(){ transparentBlack=false; reversemain=false; - vp1.setup(768,1024,1024,0,-90,-256,-384); - vp2.setup(1024,768,0,0,0,-512,-384); + //vp1.setup(768,1024,1024,0,-90,-256,-384); + //vp2.setup(1024,768,0,0,0,-512,-384); showFPS=false; ofBackground(0,0,0); @@ -103,11 +180,10 @@ void testApp::setup(){ ofAddListener(win->events.mouseDragged, this, &testApp::mousePressedEvent); ofAddListener(win->events.mousePressed, this, &testApp::mousePressedEvent); ofAddListener(win->events.keyPressed, this, &testApp::keyPressedEvent); - ofAddListener(win->events.fileDragEvent, this, &testApp::refDragEvent); win->setWindowTitle("preview"); win->addListener(prevWin); prevWin->setup(); - prevWin->setBuffer(&vp1.rb2); + prevWin->setBuffer(&viewports[0]->rb2); fullscreenoutput=false; @@ -125,9 +201,9 @@ void testApp::setup(){ //gui window stuff ofxFenster* win2=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW); - ofAddListener(win2->events.fileDragEvent, this, &testApp::refDragEvent); - //ofAddListener(win2->events.mousePressed, 0, &testApp::mousePressedEvent); - //ofAddListener(win2->events.keyPressed, this, &testApp::keyPressedEvent); + + ofAddListener(win2->events.windowResized, this, &testApp::windowEvent); + win2->setWindowTitle("config"); win2->addListener(guiWin); guiWin->setup(); @@ -151,6 +227,13 @@ void testApp::makeColours() { //-------------------------------------------------------------- void testApp::update(){ //for (int i=0;iupdate(); + + if (useKinect) { + recordContext.update(); + recordDepth.update(); + recordImage.update(); + recordUser.update(); + } } //-------------------------------------------------------------- @@ -160,8 +243,13 @@ void testApp::draw(){ ofSetColor(255-fadetime,255-fadetime,255-fadetime); //for feedback - vp1.draw(lambda,controllers,xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,scale,fscale,noteRandomiseColours?colShift:0.0f); - vp2.draw(lambda,controllers,reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,reversemain?1.0f/scale:scale,reversemain?1.0f/fscale:fscale,noteRandomiseColours?colShift:0.0f); + //vp1.draw(lambda,controllers,xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,scale,fscale,noteRandomiseColours?colShift:0.0f); + //vp2.draw(lambda,controllers,reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,reversemain?1.0f/scale:scale,reversemain?1.0f/fscale:fscale,noteRandomiseColours?colShift:0.0f); + for (int i=0;iisMapped) viewports[i]->mapdraw(lambda,controllers,even&&reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,even&&reversemain?1.0f/scale:scale,even&&reversemain?1.0f/fscale:fscale,noteRandomiseColours?colShift:0.0f); + else viewports[i]->draw(lambda,controllers,even&&reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,even&&reversemain?1.0f/scale:scale,even&&reversemain?1.0f/fscale:fscale,noteRandomiseColours?colShift:0.0f); + } ofSetColor(255,255,255); if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); @@ -459,14 +547,21 @@ void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- -void testApp::refDragEvent(ofDragInfo &dragInfo){ - dragEvent(dragInfo); -} + void testApp::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ dragEvent(dragInfo); } void testApp::dragEvent(ofDragInfo dragInfo){ - printf("received file:%s\n",dragInfo.files[0].c_str()); + printf("got draginfo: %s\n",dragInfo.files[0].c_str()); + int sta=dragInfo.files[0].find_last_of("\\/")+1; + int len=(dragInfo.files[0].find_last_of(".")+4)-sta; + string filename=dragInfo.files[0].substr(sta,len); + printf("loading %s\n",filename.c_str()); + + list.load(filename); +} +void testApp::windowEvent(ofResizeEventArgs &args){ + printf("window event\n"); } void testApp::mousePressedEvent(ofMouseEventArgs &args) { diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h index a03ad4b..e0a00cc 100755 --- a/liveengine/src/testApp.h +++ b/liveengine/src/testApp.h @@ -2,6 +2,7 @@ //#include +#include "ofxOpenNI.h" #include "ofMain.h" #include "ofxXmlSettings.h" @@ -94,6 +95,7 @@ enum PropertyAttribute { class previewWindow; class guiWindow; +class kinectWindow; //#define GRAB_TEXTURE @@ -117,9 +119,9 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ void dragEvent(ofDragInfo dragInfo); void dragEvent(ofDragInfo dragInfo,ofxFenster* win); - void refDragEvent(ofDragInfo &args); void mousePressedEvent(ofMouseEventArgs &args); void keyPressedEvent(ofKeyEventArgs &args); + void windowEvent(ofResizeEventArgs &args); void makeColours(); @@ -151,9 +153,11 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ float colShift; viewport vp1,vp2; + vector viewports; previewWindow *prevWin; guiWindow *guiWin; + kinectWindow *kinectWin; ofxFenster* win; @@ -164,6 +168,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ void newMidiMessage(ofxMidiEventArgs& eventArgs); playlist list; + ofxPanel gui; ofxToggle reversemain; @@ -175,10 +180,33 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ void resetDrawscalePressed(bool & pressed); void resetFBscalePressed(bool & pressed); + + //kinect stuff + + bool useKinect; + + bool isLive, isTracking, isMasking, isFiltering, isCloud; + + ofxOpenNIContext recordContext; + ofxDepthGenerator recordDepth; + ofxImageGenerator recordImage; + ofxUserGenerator recordUser; + + int nearThreshold, farThreshold; + float filterFactor; }; +class kinectWindow: public ofxFensterListener{ +public: + ~kinectWindow(); + testApp *parent; + void setup(); + void setParent(testApp *p); + void draw(); +}; + class previewWindow: public ofxFensterListener{ public: @@ -197,6 +225,7 @@ public: void setParent(testApp *p); void draw(); void dragEvent(ofDragInfo dragInfo,ofxFenster* win); + void windowMoved(int x, int y); }; diff --git a/liveengine/src/viewport.cpp b/liveengine/src/viewport.cpp index ce67b37..82ee5a0 100755 --- a/liveengine/src/viewport.cpp +++ b/liveengine/src/viewport.cpp @@ -1,11 +1,62 @@ #include "viewport.h" +//texture binding with normalised coords +void bindTexture(ofBaseHasTexture &t) { + ofTexture &tex = t.getTextureReference(); + tex.bind(); + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + + ofTextureData texData = tex.getTextureData(); + if(texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB) { + glScalef(tex.getWidth(), tex.getHeight(), 1.0f); + } else { + glScalef(tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f); + } + + glMatrixMode(GL_MODELVIEW); +} +void unbindTexture(ofBaseHasTexture &t) { + t.getTextureReference().unbind(); + + glMatrixMode(GL_TEXTURE); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); +} +void bindTex(ofTexture &tex) { + tex.bind(); + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + + ofTextureData texData = tex.getTextureData(); + if(texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB) { + glScalef(tex.getWidth(), tex.getHeight(), 1.0f); + } else { + glScalef(tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f); + } + + glMatrixMode(GL_MODELVIEW); +} +void unbindTex(ofTexture &tex) { + tex.unbind(); + + glMatrixMode(GL_TEXTURE); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); +} +//-------------------------------------------------- viewport::viewport() { //ctor } +viewport::viewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { + setup(_w,_h,_x,_y,_r,_ox,_oy); +} void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { r=_r; @@ -105,3 +156,186 @@ viewport::~viewport() { //dtor } + +void viewport::setUG(ofxUserGenerator *_rUser){ + rUser=_rUser; + isMapped=true; +} + +//------------------------- +mappedviewport::mappedviewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { + setup(_w,_h,_x,_y,_r,_ox,_oy); +} +void mappedviewport::setUG(ofxUserGenerator *_rUser){ + rUser=_rUser; +} +void viewport::mapdraw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale,float colShift){ + //printf("draw mapped%s\n",ofGetFrameNum()); + rb1.begin(); + int startx=((w-(w*fscale))/2)+xshift; + while (startx>0) startx-=(w*fscale); + int starty=((h-(h*fscale))/2)+yshift; + while (starty>0) starty-=(h*fscale); + + for (int i=startx;i0) { + switch(mode) { + case BLOCKS: + for (int i=0;i>7,(controller_colours[i].g*controllers[i])>>7,(controller_colours[i].b*controllers[i])>>7)); + ofRect((note-START_NOTE)*notewidth,i*noteheight,notewidth,noteheight); + } + break; + case LIST: + if (list.lock()) { //if playlist is loaded + if (list.layers.find(note)!=list.layers.end()) { + ofPushMatrix(); + ofTranslate(w/2,h/2); + ofScale(scale,scale,scale); + ofTranslate(-w/2,-h/2); + if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack,colShift); + else list.layers[note]->draw(a,w,h,colShift); + ofPopMatrix(); + } + list.unlock(); + } + break; + } + } + + rb1.end(); + + rb2.begin(); + ofSetColor(255,255,255); + ofBackground(0,0,0); + //rb1.draw(0,0); + + //map on kinect skeleton + bindTexture(rb1); + + glPushMatrix(); + glScalef(ofGetWidth()/640.0f,ofGetHeight()/480.0f, 1); + for (int i=0;igetNumberOfTrackedUsers();i++){ + ofxTrackedUser* u=(rUser->getTrackedUser(i+1)); + + //if (u->skeletonTracking) { + if (u->neck.found) { + // u->debugDraw(); + //ofxTrackedUser* u= + //printf("%i\n",(int)recordUser.getTrackedUser(i)->id); + //printf("tracking\n"); + + /* + glBegin(GL_QUADS); + glVertex3i(u->hip.position[0].X, u->hip.position[0].Y,u->hip.position[0].Z); + glVertex3i(u->hip.position[1].X, u->hip.position[1].Y,u->hip.position[1].Z); + glVertex3i(u->right_shoulder.position[1].X, u->right_shoulder.position[1].Y,u->right_shoulder.position[1].Z); + glVertex3i(u->left_shoulder.position[1].X, u->left_shoulder.position[1].Y, u->left_shoulder.position[1].Z); + glEnd(); + */ + + /* + glBegin(GL_QUADS); + glVertex3i(u->hip.position[0].X, u->hip.position[0].Y,0); + glVertex3i(u->hip.position[1].X, u->hip.position[1].Y,0); + glVertex3i(u->right_shoulder.position[1].X, u->right_shoulder.position[1].Y,0); + glVertex3i(u->left_shoulder.position[1].X, u->left_shoulder.position[1].Y,0); + glEnd(); + */ + + float ratio=16.0f/9.0f; + float heightratio=0.8f; + float widthratio=0.8f; + + float ax=((float)(u->hip.position[1].X-u->hip.position[0].X)); //hip width x + float ay=((float)(u->hip.position[1].Y-u->hip.position[0].Y)); //hip width y + + float cx=(float)(u->hip.position[0].X)+(ax*0.5f); //centre of hips + float cy=(float)(u->hip.position[0].Y)+(ay*0.5f); + + float hx=(((float)(u->left_shoulder.position[0].X))-cx); //height of torso + float hy=(((float)(u->left_shoulder.position[0].Y))-cy); + + float p1x=cx+(hx*(1.0f-heightratio)*0.5f); //centre of frame bottom + float p1y=cy+(hy*(1.0f-heightratio)*0.5f); + + float p2x=cx+(hx*(1.0f-((1.0f-heightratio)*0.5f))); //centre of frame top + float p2y=cy+(hy*(1.0f-((1.0f-heightratio)*0.5f))); + + ofVec3f c1=ofVec3f(p2x-(ax*0.5*widthratio), p2y-(ay*0.5*widthratio),0); + ofVec3f c2=ofVec3f(p2x+(ax*0.5*widthratio), p2y+(ay*0.5*widthratio),0); + ofVec3f c3=ofVec3f(p1x-(ax*0.5*widthratio), p1y-(ay*0.5*widthratio),0); + ofVec3f c4=ofVec3f(p1x+(ax*0.5*widthratio), p1y+(ay*0.5*widthratio),0); + + + /* + ofVec3f c1=ofVec3f(u->left_shoulder.position[1].X, u->left_shoulder.position[1].Y,0); + ofVec3f c2=ofVec3f(u->right_shoulder.position[1].X, u->right_shoulder.position[1].Y,0); + ofVec3f c3=ofVec3f(u->hip.position[1].X, u->hip.position[1].Y,0); + ofVec3f c4=ofVec3f(u->hip.position[0].X, u->hip.position[0].Y,0); + */ + + + /* + glBegin(GL_QUADS); + glVertex3i(u->hip.position[1].X, u->hip.position[1].Y,0); + glVertex3i(u->hip.position[0].X, u->hip.position[0].Y,0); + glVertex3i(u->left_shoulder.position[1].X, u->left_shoulder.position[1].Y,0); + glVertex3i(u->right_shoulder.position[1].X, u->right_shoulder.position[1].Y,0); + glEnd(); + */ + + + ofMesh targ; + targ.addVertex(c1); + targ.addTexCoord(ofVec2f(0,0)); + targ.addVertex(c2); + targ.addTexCoord(ofVec2f(1,0)); + targ.addVertex(c3); + targ.addTexCoord(ofVec2f(0,1)); + targ.addVertex(c3); + targ.addTexCoord(ofVec2f(0,1)); + targ.addVertex(c2); + targ.addTexCoord(ofVec2f(1,0)); + targ.addVertex(c4); + targ.addTexCoord(ofVec2f(1,1)); + targ.draw(); + + + + //ofLine(u->left_shoulder.position[1].X,u->left_shoulder.position[1].Y,u->left_shoulder.position[1].Z,u->right_shoulder.position[1].X,u->right_shoulder.position[1].Y,u->right_shoulder.position[1].Z); + ofLine(u->right_shoulder.position[1].X,u->right_shoulder.position[1].Y,u->right_shoulder.position[1].Z,u->right_lower_torso.position[1].X,u->right_lower_torso.position[1].Y,u->right_lower_torso.position[1].Z); + ofLine(u->right_lower_torso.position[1].X,u->right_lower_torso.position[1].Y,u->right_lower_torso.position[1].Z,u->left_lower_torso.position[1].X,u->left_lower_torso.position[1].Y,u->left_lower_torso.position[1].Z); + ofLine(u->left_lower_torso.position[1].X,u->left_lower_torso.position[1].Y,u->left_lower_torso.position[1].Z,u->left_shoulder.position[1].X,u->left_shoulder.position[1].Y,u->left_shoulder.position[1].Z); + + } + } + glPopMatrix(); + unbindTexture(rb1); + + + rb2.end(); + + ofPushMatrix(); + ofTranslate(x+(w/2),y+(h/2)); + ofRotate(r); + //ofTranslate(-abs(sin(ofDegToRad(r))*h/2)-abs(cos(ofDegToRad(r))*w/2),-abs(sin(ofDegToRad(r))*w/2)-abs(cos(ofDegToRad(r))*h/2)); + ofTranslate(ox,oy); + + rb2.draw(0,0); + + ofPopStyle(); + + ofPopMatrix(); + +} diff --git a/liveengine/src/viewport.h b/liveengine/src/viewport.h index 4f29a5b..350ea5d 100755 --- a/liveengine/src/viewport.h +++ b/liveengine/src/viewport.h @@ -1,6 +1,7 @@ #ifndef VIEWPORT_H #define VIEWPORT_H +#include "ofxOpenNI.h" #include "ofMain.h" #include "playlist.h" @@ -13,21 +14,40 @@ #define BLOCKS 1 #define LIST 2 - +void bindTexture(ofBaseHasTexture &t); +void unbindTexture(ofBaseHasTexture &t); +void bindTex(ofTexture &tex); +void unbindTex(ofTexture &tex); class viewport { public: viewport(); - void setup(int w,int h,int x, int y,float r,int _ox,int _oy); + viewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy); + void setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy); void draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale,float colShift); - virtual ~viewport(); + void mapdraw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale,float colShift); + + virtual ~viewport(); + void setUG(ofxUserGenerator *_rUser); ofFbo rb1,rb2; float r; + bool isMapped; protected: + int x, y,w,h,ox,oy; + + ofxUserGenerator *rUser; private: - int x, y,w,h,ox,oy; + +}; + +class mappedviewport: public viewport { + public: + mappedviewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy); + void setUG(ofxUserGenerator *_rUser); + void mapdraw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale,float colShift); + ofxUserGenerator *rUser; }; #endif // VIEWPORT_H -- cgit v1.2.3