summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xaddons.make1
-rwxr-xr-xdiatribe.cbp3
-rw-r--r--diatribe.layout14
-rwxr-xr-xsrc/main.cpp2
-rwxr-xr-xsrc/testApp.cpp96
-rwxr-xr-xsrc/testApp.h52
-rwxr-xr-xsrc/viewport.cpp85
-rwxr-xr-xsrc/viewport.h19
8 files changed, 225 insertions, 47 deletions
diff --git a/addons.make b/addons.make
index ef3e7a0..f5322ea 100755
--- a/addons.make
+++ b/addons.make
@@ -3,3 +3,4 @@ ofxMidi
ofxFenster
ofxGui
ofxKinect
+ofxMayaCam
diff --git a/diatribe.cbp b/diatribe.cbp
index e07a8a0..ef200c6 100755
--- a/diatribe.cbp
+++ b/diatribe.cbp
@@ -27,6 +27,9 @@
<Option projectLinkerOptionsRelation="2" />
</Target>
</Build>
+ <Unit filename="addons.make">
+ <Option virtualFolder="build config/" />
+ </Unit>
<Unit filename="bin/data/settings.xml">
<Option virtualFolder="build config/" />
</Unit>
diff --git a/diatribe.layout b/diatribe.layout
index f261f50..a975f0a 100644
--- a/diatribe.layout
+++ b/diatribe.layout
@@ -1,13 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
+ <File name="addons.make" open="1" top="0" tabpos="3">
+ <Cursor position="61" 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="1" tabpos="2">
- <Cursor position="8764" topLine="256" />
+ <File name="src/testApp.cpp" open="1" top="0" tabpos="2">
+ <Cursor position="6323" topLine="175" />
+ </File>
+ <File name="src/viewport.cpp" open="1" top="1" tabpos="1">
+ <Cursor position="3574" topLine="203" />
</File>
- <File name="src/viewport.cpp" open="1" top="0" tabpos="1">
- <Cursor position="3621" topLine="117" />
+ <File name="src/viewport.h" open="1" top="0" tabpos="4">
+ <Cursor position="1256" topLine="10" />
</File>
</CodeBlocks_layout_file>
diff --git a/src/main.cpp b/src/main.cpp
index f0c0c0f..a815136 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,7 +7,7 @@
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(ofxFensterManager::get(),1024,768, OF_WINDOW); //2048,768
+ ofSetupOpenGL(ofxFensterManager::get(),1280,768, OF_WINDOW); //2048,768
//ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
//ofSetupOpenGL(&window, 1024,768, OF_WINDOW);
diff --git a/src/testApp.cpp b/src/testApp.cpp
index de970da..c12ef7e 100755
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -27,6 +27,7 @@ void guiWindow::draw(){
parent->gui.draw();
}
+
void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){
parent->dragEvent(dragInfo);
}
@@ -67,9 +68,9 @@ void testApp::setup(){
kinectWin->setParent(this);
// enable depth->video image calibration
- kinect.setRegistration(true);
+ kinect.setRegistration(); //true);
- kinect.init(true);
+ kinect.init();
//kinect.init(true); // shows infrared instead of RGB video image
//kinect.init(false, false); // disable video image (faster fps)
@@ -161,10 +162,37 @@ void testApp::setup(){
gui.add(drawCloud.setup("draw pointCloud",false));
*/
+ gui.add(logo.setup("logo",false));
+
fade=255;
gui.add(fadectl.setup("fade level",fade,0,255,255));
- decimate=255;
- gui.add(decimatectl.setup("decimate",decimate,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));
+ 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;
+ gui.add(xrotctl.setup("x rotate",xrot,-1.0f,1.0f,255));
+ yrot=0.0f;
+ 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);
@@ -179,13 +207,31 @@ void testApp::setup(){
guiWin->setup();
guiWin->setParent(this);
-
+int values[2];
+glGetIntegerv(GL_POINT_SIZE_RANGE, values);
+for (int i=0; i<3; i++){
+printf("GLPOINTSIZE = %d\n", values[i]);
+}
}
-void testApp::fadeSet(int amt) {
- printf("fader set to %i\n",amt);
+void testApp::pointsModeSet(bool & set){
+ drawMode=POINTS;
+ //pointsMode=true; //segfaults!?
+ //linesMode=false;
+ //polysMode=false;
+}
+void testApp::linesModeSet(bool & set){
+ drawMode=LINES;
+ //pointsMode=true;
+ //linesMode=true;
+ //polysMode=false;
+}
+void testApp::polysModeSet(bool & set){
+ drawMode=POLYS;
+ //pointsMode=false;
+ //linesMode=false;
+ //polysMode=true;
}
-
//--------------------------------------------------------------
void testApp::update(){
@@ -213,13 +259,9 @@ void testApp::saveSettings(string filename){
void testApp::draw(){
for (int i=0;i<viewports.size();i++) {
- viewports[i]->draw(fade,decimate);
+ viewports[i]->draw(drawMode,fade,decimate,featuresize,xrot,yrot,zrot,range,logo);
}
-
-
-
-
}
//--------------------------------------------------------------
@@ -233,8 +275,8 @@ void testApp::keyPressed(int key, ofxFenster* win){
}
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);
+ //if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->keyPressed(key);
+ //else if (activeView<viewports.size()) viewports[activeView]->keyPressed(key);
if (key>='0' && key <='5'){
@@ -263,12 +305,32 @@ void testApp::keyPressed(int key){
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();
+ }
+ if(key == 'x'){
+ if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->camera.disableAllInput();
+ else if (activeView<viewports.size()) viewports[activeView]->camera.disableAllInput();
+ }
+ if(key == 'q'){
+ if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->xrot=0;
+ else if (activeView<viewports.size()) viewports[activeView]->xrot=0;
+ }
+ if(key == 'w'){
+ if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->yrot=0;
+ else if (activeView<viewports.size()) viewports[activeView]->yrot=0;
+ }
+ if(key == 'e'){
+ if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->zrot=0;
+ else if (activeView<viewports.size()) viewports[activeView]->zrot=0;
+ }
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
- if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->keyReleased(key);
- else if (activeView<viewports.size()) viewports[activeView]->keyReleased(key);
+ //if (activeView<0) for (int i=0;i<viewports.size();i++) viewports[i]->keyReleased(key);
+ //else if (activeView<viewports.size()) viewports[activeView]->keyReleased(key);
}
//--------------------------------------------------------------
diff --git a/src/testApp.h b/src/testApp.h
index f99df9f..78ed5eb 100755
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -13,13 +13,13 @@
#include "ofxMidi.h"
#include "ofxFensterManager.h"
+
+
#include "ofxGui.h"
#include "viewport.h"
-#include "ofxKinect.h"
-
class previewWindow;
@@ -27,6 +27,8 @@ class guiWindow;
class kinectWindow;
+
+
class testApp : public ofxFensterListener, public ofxMidiListener{
public:
@@ -81,6 +83,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
ofxPanel gui;
+ /*
ofxToggle reversemain;
ofxToggle controlColours;
ofxToggle noteRandomiseColours;
@@ -88,17 +91,45 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
ofxButton resetDrawscale;
ofxButton resetFBscale;
ofxToggle drawCloud;
+ */
ofxIntSlider fadectl;
ofxParameter<int> fade;
- ofxIntSlider decimatectl;
- ofxParameter<int> decimate;
-
+ ofxFloatSlider decimatectl;
+ ofxParameter<float> decimate;
+ ofxFloatSlider featurectl;
+ ofxParameter<float> featuresize;
+
+ //a radio button. sigh.
+ int drawMode;
+ ofxToggle pointsMode;
+ ofxToggle linesMode;
+ ofxToggle polysMode;
+ void pointsModeSet(bool & set);
+ void linesModeSet(bool & set);
+ void polysModeSet(bool & set);
+
+ ofxToggle logo;
+ //void logoSet(bool & set);
+
+ 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;
void resetDrawscalePressed(bool & pressed);
void resetFBscalePressed(bool & pressed);
+ void resetSlidePressed(bool & pressed);
- void fadeSet(int amt);
//kinect stuff
@@ -136,6 +167,15 @@ public:
void setup();
void setParent(testApp *p);
void draw();
+ void mouseMoved(int x, int y, ofxFenster* f) {};
+ void mouseMoved(int x, int y) {};
+ void mouseDragged(int x, int y, int button, ofxFenster* f) {};
+ void mouseDragged(int x, int y, int button) {};
+ void mousePressed(int x, int y, int btn, ofxFenster* f) {};
+ void mousePressed(int x, int y, int btn) {};
+ void mouseReleased(int x, int y, int btn, ofxFenster* f) {};
+ void mouseReleased(int x, int y, int btn) {};
+ void mouseReleased() {};
void dragEvent(ofDragInfo dragInfo,ofxFenster* win);
void windowMoved(int x, int y);
};
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 513b954..4f65a6d 100755
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -74,9 +74,13 @@ void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
yshift=0;
scale=1.0;
fscale=1.0;
+ xrot=yrot=zrot=0.0f;
+
+ logo.loadImage("logo.png");
}
-void viewport::draw(int fade,int decimate){
+void viewport::draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool dologo){
+
/*
ofNode c=ofNode();
ofNode t=ofNode();
@@ -84,7 +88,7 @@ void viewport::draw(int fade,int decimate){
t.setPosition();
//make target controls relative to rotation
c.rotate(vars["lng"].getVal(), ofVec3f(0, 1, 0));
-*/
+
target.setPosition(vars["targX"].getVal(),vars["targY"].getVal(),vars["targZ"].getVal());
//camera.orbit(vars[5].getVal(), vars[4].getVal(), vars[7].getVal(), target);
camera.setFov(vars["fov"].getVal());
@@ -95,6 +99,7 @@ void viewport::draw(int fade,int decimate){
p += target.getPosition();
camera.setPosition(p);
camera.lookAt(target,ofVec3f(0,1,0).rotate(vars["roll"].getVal(),ofVec3f(0,0,1)).rotate(vars["lng"].readVal(),ofVec3f(0,1,0)));
+ */
rb1.begin();
@@ -122,25 +127,69 @@ void viewport::draw(int fade,int decimate){
camera.begin();
+ ofPushMatrix();
- glBegin(GL_POINTS);
-
- float step = 255.0f/(float)decimate;
+ ofTranslate(0,0,-1500);
+ xrot+=xr;
+ yrot+=yr;
+ zrot+=zr;
+ ofRotateY(yrot);
+ ofRotateX(xrot);
+ ofRotateZ(zrot);
+ 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);
+
+ 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);
+ glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
+ }
+ }
- 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 ) 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);
- glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
- }
+ glEnd();
+ glDisable(GL_PROGRAM_POINT_SIZE);
+ }
+ if (mode==LINES) {
+ glEnable(GL_LINE_SMOOTH);
+ glLineWidth(feat);
+
+ for(float y = 0.0f; y < 480.0f; y += step) {
+ glBegin(GL_LINE_STRIP);
+ for(float x = 0.0f; x < 640.0f; x += 1.0f+(step*0.1)) {
+ ofVec3f pos = kinect->getWorldCoordinateAt(x, y);
+ if (pos.z == 0 || pos.z>range) {
+ glEnd();
+ glBegin(GL_LINE_STRIP);
+ 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);
+ glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
+ }
+ glEnd();
+ }
}
-
- glEnd();
+ ofPopMatrix();
camera.end();
glColor3f(1.0f, 1.0f, 1.0f);
@@ -158,6 +207,12 @@ void viewport::draw(int fade,int decimate){
ofTranslate(ox,oy);
rb2.draw(0,0);
+
+ if (dologo) {
+ ofEnableAlphaBlending();
+ logo.draw(0,0,ofGetWidth(),ofGetHeight());
+ ofDisableAlphaBlending();
+ }
ofPopMatrix();
}
diff --git a/src/viewport.h b/src/viewport.h
index 1ffda0a..f635e51 100755
--- a/src/viewport.h
+++ b/src/viewport.h
@@ -6,6 +6,12 @@
#include "ofMain.h"
#include "keyVar.h"
+#define POINTS 1
+#define LINES 2
+#define POLYS 3
+
+#include "ofxMayaCam.h"
+
class viewport
{
@@ -22,26 +28,31 @@ class viewport
void mousePressedEvent(int xs,int ys,float sc,float fs);
- void draw(int fade,int decimate);
+ void draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool dologo);
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;
+
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
- //has its own own camera
- ofCamera camera;
- ofNode target;
+
+
};