« midterm | Main | 3d meshes »
part 1:
part 2:
and I also managed to get my original idea for the midterm project running, although I found the lines were too complex for the eye to follow so I reworked the UI a bit and went with a more easy to 'read' piece.
On the y-axis you see a collection of tangible information (date, gender and value) some of the information was estimated based on other information found about similar works by the same artist, regardless you can compare dynamically different art works, by moving them closer to other pieces you can see how high different values are in comparison to their neighbors.
I'm interested in mapping this information dynamically in some sort of UI. Ideally so that anyone can manage a large collection as if to curate an entire museum . . . on their own terms.
here is a movie to give you an idea of how it works-- code is also provided behind the cut..
you can also see it here if the above embedding doesn't play nice.
problem 1:
for( int step=0; step glBegin( GL_LINE_LOOP ); for ( int arc=0; arc float a = arc / circlesteps*PI*2.0; float x = radius*cos( a ); float y = step*stepheight; float z = radius*sin( a ); glVertex3f( x, y, z ); } glEnd(); } for( int step=0; step for( int arc=0; arc< circlesteps; arc++ ) { glBegin( GL_LINE_STRIP ); float a = arc / circlesteps*PI*2.0; float x = radius*cos( a ); float z = radius*sin( a ); glVertex3f( x, step*stepheight, z ); glVertex3f( x, (step+1)*stepheight, z ); glEnd();
float circlesteps = 30; vector circleCurr; vector circlePrev; for( int i=0; i glBegin( GL_LINE_LOOP ); for ( int arc=0; arc float a = arc / circlesteps*PI*2.0; float radius = points[i].x; ofPoint3f cp = ofPoint3f( radius*cos(a), points[i].y, radius*sin(a) ); circleCurr.push_back(cp); glVertex3f( cp.x, cp.y, cp.z ); } glEnd(); glBegin( GL_LINES ); for( int i=0; i glVertex3f( circleCurr[i].x, circleCurr[i].y, circleCurr[i].z ); glVertex3f( circlePrev[i].x, circlePrev[i].y, circlePrev[i].z ); } glEnd(); circlePrev.clear(); for( int i=0; i circlePrev.push_back( circleCurr[i]); } circleCurr.clear();
glBegin( GL_LINE_LOOP ); for ( int arc=0; arc float a = arc / circlesteps*PI*2.0; float radius = points[i].x; ofPoint3f cp = ofPoint3f( radius*cos(a), points[i].y, radius*sin(a) ); circleCurr.push_back(cp); glVertex3f( cp.x, cp.y, cp.z ); } glEnd(); glBegin( GL_LINES ); for( int i=0; i glVertex3f( circleCurr[i].x, circleCurr[i].y, circleCurr[i].z ); glVertex3f( circlePrev[i].x, circlePrev[i].y, circlePrev[i].z ); } glEnd();
circlePrev.clear(); for( int i=0; i circlePrev.push_back( circleCurr[i]); } circleCurr.clear();
midterm part 2
#include #include #include #include "ofMain.h" #include "ofStefanix.h" #include "ofDirList.h" #include "photoMetadata.h" #include "ImageWidget.h" class world : public ofSimpleApp { public: void setup(); void update(); void draw(); void layoutImages(); void drawLayers(); void tagImages(); void loadImages(); vector images; multimap imagesByOffsetX; float imgOffY; float imgCellH; float imgCellW; float imgPadX; float imgPadY; void keyPressed( int key ); void mouseMoved( int x, int y ); void mouseDragged( int x, int y, int button ); void mousePressed( int x, int y, int button ); void mouseReleased(); }; void world::setup() { loadImages(); imgOffY = 600; imgCellH = 0; imgCellW = 0; imgPadX = 5; imgPadY = imgPadX; layoutImages(); } void world::update() { ofBackground( 100, 100, 100 ); } void world::draw() { ofSetColor( 0x222222 ); ofRect( 0, imgOffY-50, ofGetWidth(), ofGetHeight()-550 ); glBegin(GL_POLYGON); ofSetColor( 0x000000 ); glVertex2f(0, imgOffY-40); glVertex2f(0, imgOffY-50); ofSetColor( 0xffffff ); glVertex2f(ofGetWidth(), imgOffY-50); glVertex2f(ofGetWidth(), imgOffY-40); glEnd(); for( int i=0; i ImageWidget* img = images[i]; if( img->mouseOver ) { ofSetColor( 0xffffff ); } else { ofSetColor( 0x888888 ); } img->draw(); } drawLayers(); ofSetColor( 0xffffff ); ofDrawBitmapString( "mountGraph.",20, 748 ); } void world::layoutImages() { static float focusedImgW = 100; imgPadX = 5; imgCellW = (ofGetWidth()+2*imgPadX)/IMGNUM; //no padding at the very ends imgCellH = imgCellW; imgPadY = imgPadX; imagesByOffsetX.clear(); for( int i=0; i ImageWidget* img = images[i]; img->loc.set(i*imgCellW, imgOffY); img->dwidth = imgCellW-2*imgPadX; img->dheight = imgCellH-2*imgPadY; img->dragBBmin.set(0, imgOffY-50); img->dragBBmax.set(ofGetWidth(), ofGetHeight()); imagesByOffsetX.insert(pair(i*imgCellW, i)); } } void world::drawLayers() { float ridge[IMGNUM]; multimap::iterator iterX; //init ridge for( int ii=0; ii ridge[ii] = imgOffY-50; } //subjective value ofSetColor(0xee00ff); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(0, 10, 3, 33, phmdSubjectiveValue[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd(); //political relevance ofSetColor(0x8888ff); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(0, 10, 3, 23, phmdPoliticalRelevance[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd(); //creation date ofSetColor(0xff5555); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(1967, 2007, 3, 43, phmdCreationYear[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd(); //artist birth date ofSetColor(0xffff33); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(1900, 1980, 3, 23, phmdArtistYearOfBirth[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd(); } void world::tagImages() { /* ofDirList DIR; char inpath[] = "/Users/noema/svn/openFrameworks/myapp/luminoStory/src/pix_medium_skyline"; */ } void world::loadImages() { ofDirList DIR; char inpath[] = "../../../data/"; DIR.setVerbose(false); int numFiles = DIR.listDir(inpath); //ofImage images[numFiles]; for(int i = 0; i < numFiles; i++) { ImageWidget* temp = new ImageWidget; temp->loadImage(DIR.getPath(i)); images.push_back(temp); } } void world::keyPressed( int key ) { if( key == ' '){ layoutImages(); } } void world::mouseMoved( int x, int y ) { for( int i=0; i images[i]->mouseMoved(x, y); } } void world::mouseDragged( int x, int y, int button ) { for( int i=0; i ImageWidget* img = images[i]; int tempX = img->loc.x; if( img->mouseDragged( x, y)) { //delete old entry //int count = imagesByOffsetX.count(tempX); multimap::iterator p = imagesByOffsetX.find(tempX); if( p != imagesByOffsetX.end() ) { while (p != imagesByOffsetX.upper_bound(tempX)) { if( p->second == i) { imagesByOffsetX.erase(p); break; } p++; } } //reinsert under different key imagesByOffsetX.insert(pair(img->loc.x, i)); } } } void world::mousePressed( int x, int y, int button ) { for( int i=0; i images[i]->mousePressed( x, y ); } } void world::mouseReleased() { for( int i=0; i images[i]->mouseReleased(); } } int main() { ofSetupOpenGL( 1024, 768, OF_WINDOW ); world APP; ofRunApp( &APP ); }
#include "ofMain.h" #include "ofStefanix.h" #include "ofDirList.h"
#include "photoMetadata.h" #include "ImageWidget.h"
class world : public ofSimpleApp { public:
void setup(); void update(); void draw(); void layoutImages(); void drawLayers(); void tagImages(); void loadImages(); vector images; multimap imagesByOffsetX; float imgOffY; float imgCellH; float imgCellW; float imgPadX; float imgPadY;
void keyPressed( int key ); void mouseMoved( int x, int y ); void mouseDragged( int x, int y, int button ); void mousePressed( int x, int y, int button ); void mouseReleased(); };
void world::setup() { loadImages(); imgOffY = 600; imgCellH = 0; imgCellW = 0; imgPadX = 5; imgPadY = imgPadX; layoutImages(); }
void world::update() { ofBackground( 100, 100, 100 );
}
void world::draw() {
ofSetColor( 0x222222 ); ofRect( 0, imgOffY-50, ofGetWidth(), ofGetHeight()-550 ); glBegin(GL_POLYGON); ofSetColor( 0x000000 ); glVertex2f(0, imgOffY-40); glVertex2f(0, imgOffY-50); ofSetColor( 0xffffff ); glVertex2f(ofGetWidth(), imgOffY-50); glVertex2f(ofGetWidth(), imgOffY-40); glEnd(); for( int i=0; i ImageWidget* img = images[i]; if( img->mouseOver ) { ofSetColor( 0xffffff ); } else { ofSetColor( 0x888888 ); } img->draw(); } drawLayers(); ofSetColor( 0xffffff ); ofDrawBitmapString( "mountGraph.",20, 748 ); }
void world::layoutImages() { static float focusedImgW = 100; imgPadX = 5; imgCellW = (ofGetWidth()+2*imgPadX)/IMGNUM; //no padding at the very ends imgCellH = imgCellW; imgPadY = imgPadX;
imagesByOffsetX.clear(); for( int i=0; i ImageWidget* img = images[i]; img->loc.set(i*imgCellW, imgOffY); img->dwidth = imgCellW-2*imgPadX; img->dheight = imgCellH-2*imgPadY; img->dragBBmin.set(0, imgOffY-50); img->dragBBmax.set(ofGetWidth(), ofGetHeight()); imagesByOffsetX.insert(pair(i*imgCellW, i)); } }
void world::drawLayers() { float ridge[IMGNUM]; multimap::iterator iterX; //init ridge for( int ii=0; ii ridge[ii] = imgOffY-50; }
//subjective value ofSetColor(0xee00ff); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(0, 10, 3, 33, phmdSubjectiveValue[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd();
//political relevance ofSetColor(0x8888ff); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(0, 10, 3, 23, phmdPoliticalRelevance[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd();
//creation date ofSetColor(0xff5555); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(1967, 2007, 3, 43, phmdCreationYear[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd();
//artist birth date ofSetColor(0xffff33); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, imgOffY-50); for( iterX = imagesByOffsetX.begin(); iterX!=imagesByOffsetX.end(); ++iterX ) { pair p = *iterX; int i = p.second; float val = ofRangemap(1900, 1980, 3, 23, phmdArtistYearOfBirth[i]); ImageWidget* img = images[i]; glVertex2f(img->loc.x, ridge[i]-val); glVertex2f(img->loc.x, ridge[i]); ridge[i] = ridge[i]-val; } glVertex2f(ofGetWidth(), imgOffY-50); glEnd(); }
void world::tagImages() { /* ofDirList DIR; char inpath[] = "/Users/noema/svn/openFrameworks/myapp/luminoStory/src/pix_medium_skyline";
*/ }
void world::loadImages() { ofDirList DIR; char inpath[] = "../../../data/"; DIR.setVerbose(false); int numFiles = DIR.listDir(inpath); //ofImage images[numFiles]; for(int i = 0; i < numFiles; i++) { ImageWidget* temp = new ImageWidget; temp->loadImage(DIR.getPath(i)); images.push_back(temp); } }
void world::keyPressed( int key ) { if( key == ' '){ layoutImages(); } } void world::mouseMoved( int x, int y ) { for( int i=0; i images[i]->mouseMoved(x, y); } } void world::mouseDragged( int x, int y, int button ) { for( int i=0; i ImageWidget* img = images[i]; int tempX = img->loc.x; if( img->mouseDragged( x, y)) { //delete old entry //int count = imagesByOffsetX.count(tempX); multimap::iterator p = imagesByOffsetX.find(tempX); if( p != imagesByOffsetX.end() ) { while (p != imagesByOffsetX.upper_bound(tempX)) { if( p->second == i) { imagesByOffsetX.erase(p); break; } p++; } } //reinsert under different key imagesByOffsetX.insert(pair(img->loc.x, i)); } } } void world::mousePressed( int x, int y, int button ) { for( int i=0; i images[i]->mousePressed( x, y ); } } void world::mouseReleased() { for( int i=0; i images[i]->mouseReleased(); } }
int main() { ofSetupOpenGL( 1024, 768, OF_WINDOW ); world APP; ofRunApp( &APP ); }
Posted by itp on November 1, 2007 04:55 PM | Permalink
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)
Name:
Email Address:
URL:
Remember personal info?
Comments: