summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diatribe.layout14
-rwxr-xr-xsrc/testApp.cpp81
-rwxr-xr-xsrc/testApp.h17
-rwxr-xr-xsrc/viewport.cpp67
-rwxr-xr-xsrc/viewport.h30
5 files changed, 121 insertions, 88 deletions
diff --git a/diatribe.layout b/diatribe.layout
index a975f0a..3bd5b1a 100644
--- a/diatribe.layout
+++ b/diatribe.layout
@@ -1,19 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
- <ActiveTarget name="Debug" />
+ <ActiveTarget name="Release" />
<File name="addons.make" open="1" top="0" tabpos="3">
<Cursor position="61" topLine="0" />
</File>
+ <File name="bin/data/settings.xml" open="1" top="0" tabpos="5">
+ <Cursor position="0" topLine="0" />
+ </File>
<File name="src/layers.h" open="1" top="0" tabpos="0">
<Cursor position="42" topLine="0" />
</File>
<File name="src/testApp.cpp" open="1" top="0" tabpos="2">
- <Cursor position="6323" topLine="175" />
+ <Cursor position="1889" topLine="45" />
+ </File>
+ <File name="src/testApp.h" open="1" top="0" tabpos="6">
+ <Cursor position="2114" topLine="96" />
</File>
<File name="src/viewport.cpp" open="1" top="1" tabpos="1">
- <Cursor position="3574" topLine="203" />
+ <Cursor position="3423" topLine="83" />
</File>
<File name="src/viewport.h" open="1" top="0" tabpos="4">
- <Cursor position="1256" topLine="10" />
+ <Cursor position="762" topLine="15" />
</File>
</CodeBlocks_layout_file>
diff --git a/src/testApp.cpp b/src/testApp.cpp
index c12ef7e..4fbba8a 100755
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -10,7 +10,7 @@ void previewWindow::setBuffer(ofFbo *buffer){
void previewWindow::draw(){
rb->draw(0,0,ofGetWidth(),ofGetHeight()); //why crash?
-
+
ofSetColor(255,255,255);
ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20);
@@ -66,19 +66,19 @@ void testApp::setup(){
kw->addListener(kinectWin);
kinectWin->setup();
kinectWin->setParent(this);
-
+
// enable depth->video image calibration
- kinect.setRegistration(); //true);
-
- kinect.init();
+ kinect.setRegistration(true); //true);
+
+ kinect.init(true);
//kinect.init(true); // shows infrared instead of RGB video image
//kinect.init(false, false); // disable video image (faster fps)
-
+
kinect.open(); // opens first available kinect
//kinect.open(1); // open a kinect by id, starting with 0 (sorted by serial # lexicographically))
//kinect.open("A00362A08602047A"); // open a kinect using it's unique serial #
-
-
+
+
if( !XML.loadFile("settings.xml") ){
printf("unable to load settings.xml check data/ folder\n");
}else{
@@ -120,7 +120,7 @@ void testApp::setup(){
}
-
+
activeView=-1;
@@ -161,26 +161,29 @@ void testApp::setup(){
gui.add(resetFBscale.setup("reset FB scale"));
gui.add(drawCloud.setup("draw pointCloud",false));
*/
-
+
gui.add(logo.setup("logo",false));
-
+ gui.add(add.setup("add",false));
+ gui.add(usecolour.setup("add",false));
+
+
fade=255;
gui.add(fadectl.setup("fade level",fade,0,255,255));
decimate=1.0f;
gui.add(decimatectl.setup("decimate",decimate,0,1.0f,255));
-
+
featuresize=1.0f;
gui.add(featurectl.setup("featuresize",featuresize,0,16.0f,255));
gui.add(pointsMode.setup("points",true));
gui.add(linesMode.setup("lines",false));
- gui.add(polysMode.setup("lines",false));
+ gui.add(polysMode.setup("polys",false));
drawMode=POINTS;
-
+
pointsMode.addListener(this,&testApp::pointsModeSet);
linesMode.addListener(this,&testApp::linesModeSet);
polysMode.addListener(this,&testApp::polysModeSet);
-
+
range=5000;
gui.add(rangectl.setup("max range",range,0,5000,255));
xrot=0.0f;
@@ -189,13 +192,14 @@ void testApp::setup(){
gui.add(yrotctl.setup("y rotate",yrot,-1.0f,1.0f,255));
zrot=0.0f;
gui.add(zrotctl.setup("z rotate",zrot,-1.0f,1.0f,255));
-
- gui.add(resetDrawscale.setup("points"));
- gui.add(resetFBscale.setup("points"));
- gui.add(resetSlide.setup("points"));
- //resetDrawscale.addListener(this,&testApp::resetDrawscalePressed);
- //resetFBscale.addListener(this,&testApp::resetFBscalePressed);
+ gui.add(resetDrawscale.setup("resetdraw"));
+ gui.add(resetFBscale.setup("resetFB"));
+ gui.add(resetSlide.setup("resetSlide"));
+
+ resetDrawscale.addListener(this,&testApp::resetDrawscalePressed);
+ resetFBscale.addListener(this,&testApp::resetFBscalePressed);
+ resetSlide.addListener(this,&testApp::resetSlidePressed);
//gui window stuff
ofxFenster* win2=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW);
@@ -214,6 +218,19 @@ printf("GLPOINTSIZE = %d\n", values[i]);
}
}
+void testApp::resetDrawscalePressed(bool & set) {
+ for (int i=0;i<viewports.size();i++) viewports[i]->scale=1.0f;
+}
+void testApp::resetFBscalePressed(bool & set) {
+ for (int i=0;i<viewports.size();i++) viewports[i]->fscale=1.0f;
+}
+void testApp::resetSlidePressed(bool & set) {
+ for (int i=0;i<viewports.size();i++) {
+ viewports[i]->xshift=0;
+ viewports[i]->yshift=0;
+ }
+}
+
void testApp::pointsModeSet(bool & set){
drawMode=POINTS;
//pointsMode=true; //segfaults!?
@@ -257,9 +274,9 @@ void testApp::saveSettings(string filename){
}
//--------------------------------------------------------------
void testApp::draw(){
-
+
for (int i=0;i<viewports.size();i++) {
- viewports[i]->draw(drawMode,fade,decimate,featuresize,xrot,yrot,zrot,range,logo);
+ viewports[i]->draw(drawMode,fade,decimate,featuresize,xrot,yrot,zrot,range,add,logo,usecolour);
}
}
@@ -274,7 +291,7 @@ void testApp::keyPressed(int key, ofxFenster* win){
else keyPressed(key);
}
void testApp::keyPressed(int key){
-
+
//if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->keyPressed(key);
//else if (activeView<viewports.size()) viewports[activeView]->keyPressed(key);
@@ -304,7 +321,7 @@ void testApp::keyPressed(int key){
if(key == 'f'){
toggleFPS();
}
-
+
if(key == 'z'){
if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->camera.enableAllInput();
else if (activeView<viewports.size()) viewports[activeView]->camera.enableAllInput();
@@ -380,12 +397,12 @@ void testApp::windowEvent(ofResizeEventArgs &args){
}
void testApp::mousePressedEvent(ofMouseEventArgs &args) {
-
+
int xs=0;
int ys=0;
float sc=1.0f;
float fs=1.0f;
-
+
switch (args.button) {
case 0:
xs=args.x-(win->getWidth()/2);
@@ -398,9 +415,9 @@ void testApp::mousePressedEvent(ofMouseEventArgs &args) {
fs=(pow(pow(args.x-(win->getWidth()/2),2)+pow(args.y-(win->getHeight()/2),2),0.5)/(win->getWidth()))+0.5;
break;
}
-
-
-
+
+
+
for (int i=0;i<viewports.size();i++) viewports[i]->mousePressedEvent(xs,ys,sc,fs);
}
@@ -440,14 +457,14 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){
// if (layers[i]->note==eventArgs.byteOne) layers[i]->setActive(noteOn);
//}
if (DEBUG) printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo);
-
+
break;
case 176: //control change channel 0
//for (int i=0;i<numLayers;i++){
// if (layers[i]->mix==eventArgs.byteOne) layers[i]->setMixAmt(((float)eventArgs.byteTwo)/127.0f);
//}
if (DEBUG) printf("cc: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo);
-
+
}
}
}
diff --git a/src/testApp.h b/src/testApp.h
index 78ed5eb..82c563b 100755
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -92,14 +92,14 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
ofxButton resetFBscale;
ofxToggle drawCloud;
*/
-
+
ofxIntSlider fadectl;
ofxParameter<int> fade;
ofxFloatSlider decimatectl;
ofxParameter<float> decimate;
ofxFloatSlider featurectl;
ofxParameter<float> featuresize;
-
+
//a radio button. sigh.
int drawMode;
ofxToggle pointsMode;
@@ -108,20 +108,23 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
void pointsModeSet(bool & set);
void linesModeSet(bool & set);
void polysModeSet(bool & set);
-
+
ofxToggle logo;
//void logoSet(bool & set);
-
+
+ ofxToggle add;
+ ofxToggle usecolour;
+
ofxFloatSlider rangectl;
ofxParameter<float> range;
-
+
ofxFloatSlider xrotctl;
ofxParameter<float> xrot;
ofxFloatSlider yrotctl;
ofxParameter<float> yrot;
ofxFloatSlider zrotctl;
ofxParameter<float> zrot;
-
+
ofxButton resetDrawscale;
ofxButton resetFBscale;
ofxButton resetSlide;
@@ -129,7 +132,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
void resetDrawscalePressed(bool & pressed);
void resetFBscalePressed(bool & pressed);
void resetSlidePressed(bool & pressed);
-
+
//kinect stuff
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 4f65a6d..aee712e 100755
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -52,7 +52,7 @@ void unbindTex(ofTexture &tex) {
viewport::viewport()
{
-
+
//ctor
}
viewport::viewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
@@ -75,13 +75,13 @@ void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
scale=1.0;
fscale=1.0;
xrot=yrot=zrot=0.0f;
-
+
logo.loadImage("logo.png");
}
-void viewport::draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool dologo){
+void viewport::draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool add, bool dologo, bool col){
- /*
+ /*ool ad
ofNode c=ofNode();
ofNode t=ofNode();
t.setParent(c);
@@ -102,7 +102,7 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa
*/
rb1.begin();
-
+ glDisable(GL_BLEND);
//can be done with texture offset?
int startx=((w-(w*fscale))/2)+xshift;
@@ -115,52 +115,56 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa
rb2.draw(i,j,w*fscale,h*fscale);
}
}
-
+
if (fade>254) ofClear(0,0,0);
else if (fade>0) {
- ofEnableAlphaBlending();
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ofSetColor(0,0,0,fade);
ofRect(0,0,w,h);
- ofDisableAlphaBlending();
+ glDisable(GL_BLEND);
}
-
-
+
+
camera.begin();
-
+
ofPushMatrix();
-
+
ofTranslate(0,0,-1500);
xrot+=xr;
yrot+=yr;
zrot+=zr;
- ofRotateY(yrot);
- ofRotateX(xrot);
ofRotateZ(zrot);
-
+ ofRotateX(xrot);
+
+ ofRotateY(yrot);
+
float minstep=1.0f/160.0f;
float step = decimate>minstep?1.0f/decimate:160.0f;
float scale=w/640.0f;
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
+ glEnable(GL_BLEND);
+ if (add) glBlendFunc(GL_ONE,GL_ONE);
+ else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
if (mode==POINTS) {
glEnable(GL_PROGRAM_POINT_SIZE);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
-
+
glPointSize(feat);
glBegin(GL_POINTS);
-
-
+
+
for(float y = 0.0f; y < 480.0f; y += step) {
for(float x = 0.0f; x < 640.0f; x += step) {
ofVec3f pos = kinect->getWorldCoordinateAt(x, y);
if (pos.z == 0 || pos.z>range) continue; // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd
ofColor color = kinect->getColorAt(x,y); //userID);
- glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a);
+ 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(pos.x*scale, pos.y*scale, pos.z*scale);
}
}
@@ -180,15 +184,16 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa
glEnd();
glBegin(GL_LINE_STRIP);
continue;
- } // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd
+ } // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd
ofColor color = kinect->getColorAt(x,y); //userID);
- glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a);
+ 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(pos.x*scale, pos.y*scale, pos.z*scale);
}
glEnd();
}
}
-
+
ofPopMatrix();
camera.end();
@@ -207,13 +212,15 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa
ofTranslate(ox,oy);
rb2.draw(0,0);
-
+
if (dologo) {
ofEnableAlphaBlending();
logo.draw(0,0,ofGetWidth(),ofGetHeight());
ofDisableAlphaBlending();
}
- ofPopMatrix();
+ ofPopMatrix();
+
+ glDisable(GL_BLEND);
}
@@ -231,7 +238,7 @@ void viewport::mousePressedEvent(int xs,int ys,float sc,float fs) {
yshift=ys;
scale=sc;
fscale=fs;
-
+
}
void viewport::setcam(map<string,float>&settings){
@@ -245,7 +252,7 @@ void viewport::setcam(map<string,float>&settings){
vars["dolly"].set('o','l',settings["dolly"],10,1.0,1.0);
}
-
+
double viewport::getSetting(const string& setting){
diff --git a/src/viewport.h b/src/viewport.h
index f635e51..23f840e 100755
--- a/src/viewport.h
+++ b/src/viewport.h
@@ -22,39 +22,39 @@ class viewport
virtual ~viewport();
void setKinect(ofxKinect *k);
void setFade(int f);
-
+
void setcam(map<string,float>&settings);
double getSetting(const string& setting);
-
+
void mousePressedEvent(int xs,int ys,float sc,float fs);
-
- void draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool dologo);
+
+ void draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool add, bool dologo, bool col);
void drawgui();
ofFbo rb1,rb2; //can do 2d buffer effects with feedback, can pass out rb2 for preview
-
+
void keyPressed(int key);
void keyReleased(int key);
-
+
ofxMayaCam camera;
float xrot,yrot,zrot;
-
+int xshift, yshift;
+ float scale,fscale;
protected:
int x, y,w,h,ox,oy,r;
- int xshift, yshift;
- float scale,fscale;
-
+
+
ofImage logo;
-
-
+
+
ofxKinect *kinect; //passes in kinect data
//passes in a playing move that can be used to generate 3D points in teh same way
private:
map<string,keyVar> vars; //change to midimappedkeyvars
-
-
-
+
+
+
};