コード例 #1
0
ファイル: cinema.cpp プロジェクト: eqkoes/eqkoscope
void Cinema::load(){
        ofDirectory dir("cinema/");
        dir.listDir();
        vector<string> dirs;
        for(int i=0;i<dir.size();i++){
            string d = dir.getPath(i);
            if(d.find("DB")!=string::npos){
                vector<string> vids;
                vector<ofVideoPlayer*> ps;
                ofDirectory dir2(d);
                dir2.listDir();
                for(int j=0;j<dir2.size();j++){
                    vector<double> scene;
                    vector<string> movs;
                    string vidpath = dir2.getPath(j);
                    string origVidPath = vidpath;
                    if(dir2.getName(j)[0] != '.' &&
                            (vidpath.find(".mov")!=string::npos || vidpath.find(".mp4")!=string::npos ||
                       vidpath.find(".avi")!=string::npos ||
                       vidpath.find(".3gp")!=string::npos
                       || vidpath.find(".gif")!=string::npos
                       || vidpath.find(".webm")!=string::npos
                       || vidpath.find(".mkv")!=string::npos)){
                        vids.push_back(vidpath);
                        playerPaths.push_back(vidpath);
                        ofVideoPlayer* p = new ofVideoPlayer;
                        playerIntensities.push_back(0);
                        ps.push_back(p);
                        
                        string txtPath = vidpath;
                        ofStringReplace(txtPath, ".mov", ".txt");
                        ofStringReplace(txtPath, ".mp4", ".txt");
                        ofStringReplace(txtPath, ".mkv", ".txt");
                        ofStringReplace(txtPath, ".webm", ".txt");
                        ofStringReplace(txtPath, ".avi", ".txt");
                        ofStringReplace(txtPath, ".gif", ".txt");
                        string t = ofBufferFromFile(txtPath).getText();
                        if(t.compare("")){
                            vector<string > splitted = ofSplitString(t, "\n");
                            for(int x=0;x<splitted.size();x++){
                                vector<string> line = ofSplitString(splitted[x]," ");
                                scene.push_back(ofToDouble(line[0]));
                                if(line.size()>1)
                                    movs.push_back((line[1]));
                                else
                                    movs.push_back(" ");
                            }
                            ofFile vf(vidpath) ;
                            string absoluteVidPath = vf.getAbsolutePath();
                            playerScenes[absoluteVidPath] = scene;
                            playerScenesMovements[origVidPath] = movs;
                        }
                    }
                   
                }
                strdb.push_back(vids);
            }
        }
    }
コード例 #2
0
void loadXmlFile() {

	string path = ofFilePath::getCurrentWorkingDirectory() + "data";
	ofDirectory dir2D(path);
	dir2D.allowExt("matrix");
	dir2D.listDir();
	int count = min(3, dir2D.numFiles());
	for (int i = 0; i < count; i++) {
		ofBuffer buffer = ofBufferFromFile(dir2D.getPath(i));
		vector<string> lines = ofSplitString(buffer.getText(), "\n");
		for (int k1 = 0; k1 < 4; k1++) {
			for (int k2 = 0; k2 < 4; k2++) {
				vector<string> numbers = ofSplitString(lines[k1], " ");
				cameras[i].Matrix[k1 * 4 + k2] = ofToDouble(numbers[k2]);
			}
		}
	}
}
コード例 #3
0
ファイル: testApp.cpp プロジェクト: quave/tripno
void testApp::readConfig() {

	ofXml xmlConfig;

	if (xmlConfig.load(ofToDataPath("config.xml"))) {
		config.signalAmp = ofToDouble(xmlConfig.getValue("signalAmp"));
		config.elasticKoeff = ofToDouble(xmlConfig.getValue("elasticKoeff"));
		config.resistanceKoeff = ofToDouble(xmlConfig.getValue("resistanceKoeff"));
		config.gateThreshold = ofToDouble(xmlConfig.getValue("gateThreshold"));
		config.maxSignalClampRate = ofToDouble(xmlConfig.getValue("maxSignalClampRate"));
		config.rangeClampRate = ofToDouble(xmlConfig.getValue("rangeClampRate"));
	}
	else {
		config.signalAmp = config.elasticKoeff = 
			config.maxSignalClampRate = config.resistanceKoeff = 0;
	}

	ofLogNotice() << "Update config";
	ofLogNotice() << "signalAmp=" << config.signalAmp;
	ofLogNotice() << "elasticKoeff=" << config.elasticKoeff;
	ofLogNotice() << "resistanceKoeff=" << config.resistanceKoeff;
}
コード例 #4
0
ファイル: ofxGpx.cpp プロジェクト: madc/ofxGpx
bool ofxGpx::load(string _path) {
    if(XML.load(_path)){
        ofLog(OF_LOG_NOTICE, "Loaded " + _path);
        
        // metadataType
        if(XML.exists("metadata")) {
            XML.setTo("metadata[0]");
            
            if(XML.exists("name")) {
                gpxMetadata.name = XML.getValue<string>("name");
            }
            
            if(XML.exists("desc")) {
                gpxMetadata.desc = XML.getValue<string>("desc");
            }
            
            if(XML.exists("autor")) {
                //PersonType
            }
            
            if(XML.exists("copyright")) {
                //CopyrightType
            }
            
            if(XML.exists("link")) {
                //LinkType
            }
            
            if(XML.exists("time")) {
                gpxMetadata.time = XML.getValue<string>("//time");
            }
            
            if(XML.exists("keywords")) {
                gpxMetadata.keywords = XML.getValue<string>("keywords");
            }
            
            if(XML.exists("bounds")) {
                XML.setTo("bounds[0]");
                
                gpxMetadata.bounds_lonlat[0] = ofPoint(ofToFloat(XML.getAttribute("minlon")), ofToFloat(XML.getAttribute("minlat")));
                gpxMetadata.bounds_lonlat[1] = ofPoint(ofToFloat(XML.getAttribute("maxlon")), ofToFloat(XML.getAttribute("maxlat")));
                
                XML.setToParent();
            } else {
                gpxMetadata.bounds_lonlat[0] = ofPoint(180, 90);
                gpxMetadata.bounds_lonlat[1] = ofPoint(-180, -90);
            }
            
            XML.setToParent();
        }
        
        // wptType
        for(int i=0; XML.exists("wpt["+ofToString(i)+"]"); i++) {
            XML.setTo("wpt["+ofToString(i)+"]");
            
            GPXWPT point;
            
            double lat = ofToDouble(XML.getAttribute("lat"));
            double lon = ofToDouble(XML.getAttribute("lon"));
            double ele = XML.getValue<double>("ele");
            
            point.coor_lonlat = ofPoint(lon, lat, ele);
            point.coor_mercator = convertToMercator(point.coor_lonlat);
            
            if(XML.exists("time")) {
                point.time = XML.getValue<string>("time");
            }
            
            if(XML.exists("name")) {
                point.name = XML.getValue<string>("name");
            }
            
            if(XML.exists("cmt")) {
                point.cmt = XML.getValue<string>("cmt");
            }
            
            if(XML.exists("desc")) {
                point.desc = XML.getValue<string>("desc");
            }
            
            if(XML.exists("src")) {
                point.src = XML.getValue<string>("src");
            }
            
            if(XML.exists("link")) {
                //LinkType
            }
            
            calculateBounds(point.coor_lonlat);
            
            gpxWaypoints.push_back(point);
            XML.setToParent();
        }
        
        // rteType
        for(int i=0; XML.exists("rte["+ofToString(i)+"]"); i++) {
            XML.setTo("rte["+ofToString(i)+"]");
            
            if(XML.getName() != "rte") {
                break;
            }
            
            GPXRTE route;
            
            if(XML.exists("name")) {
                route.name = XML.getValue<string>("name");
            }
            
            if(XML.exists("cmt")) {
                route.cmt = XML.getValue<string>("cmt");
            }
            
            if(XML.exists("desc")) {
                route.desc = XML.getValue<string>("desc");
            }
            
            if(XML.exists("src")) {
                route.src = XML.getValue<string>("src");
            }
            
            if(XML.exists("link")) {
                //LinkType
            }
            
            if(XML.exists("number")) {
                route.number = XML.getValue<int>("number");
            }
            
            if(XML.exists("type")) {
                route.type = XML.getValue<string>("type");
            }
            
            if(XML.exists("rtept")) {
                XML.setTo("rtept[0]");

                do {
                    GPXWPT point;
                    
                    double lat = ofToDouble(XML.getAttribute("lat"));
                    double lon = ofToDouble(XML.getAttribute("lon"));
                    double ele = XML.getValue<double>("ele");
                    
                    point.coor_lonlat = ofPoint(lon, lat, ele);
                    point.coor_mercator = convertToMercator(point.coor_lonlat);
                    
                    if(XML.exists("time")) {
                        point.time = XML.getValue<string>("time");
                    }
                    
                    if(XML.exists("name")) {
                        point.name = XML.getValue<string>("name");
                    }
                    
                    if(XML.exists("cmt")) {
                        point.cmt = XML.getValue<string>("cmt");
                    }
                    
                    if(XML.exists("desc")) {
                        point.desc = XML.getValue<string>("desc");
                    }
                    
                    if(XML.exists("src")) {
                        point.src = XML.getValue<string>("src");
                    }
                    
                    if(XML.exists("link")) {
                        //LinkType
                    }
                    
                    calculateBounds(point.coor_lonlat);
                    
                    route.rtept.push_back(point);
                }
                while(XML.setToSibling());
                
                XML.setToParent();
            }
            
            gpxRoutes.push_back(route);
            XML.setToParent();
        }
        
        // trkType
        for(int i=0; XML.exists("trk["+ofToString(i)+"]"); i++) {
            XML.setTo("trk["+ofToString(i)+"]");
            
            GPXTRK track;

            if(XML.exists("name")) {
                track.name = XML.getValue<string>("name");
            }
            
            if(XML.exists("cmt")) {
                track.cmt = XML.getValue<string>("cmt");
            }
            
            if(XML.exists("desc")) {
                track.desc = XML.getValue<string>("//desc");
            }
            
            if(XML.exists("src")) {
                track.src = XML.getValue<string>("//src");
            }
            
            if(XML.exists("link")) {
                //LinkType
            }
            
            if(XML.exists("number")) {
                track.number = XML.getValue<int>("number");
            }
            
            if(XML.exists("type")) {
                track.type = XML.getValue<string>("type");
            }
            
            vector<GPXTRKSEG> tracksegments;
            for(int j=0; XML.exists("trkseg["+ofToString(j)+"]"); j++) {
                XML.setTo("trkseg["+ofToString(j)+"]trkpt[0]");

                GPXTRKSEG tracksegment;

                do {
                    GPXWPT point;
                    
                    double lat = ofToDouble(XML.getAttribute("lat"));
                    double lon = ofToDouble(XML.getAttribute("lon"));
                    double ele = XML.getValue<double>("ele");
                    
                    point.coor_lonlat = ofPoint(lon, lat, ele);
                    point.coor_mercator = convertToMercator(point.coor_lonlat);
                    
                    if(XML.exists("time")) {
                        point.time = XML.getValue<string>("time");
                    }
                    
                    if(XML.exists("name")) {
                        point.name = XML.getValue<string>("name");
                    }
                    
                    if(XML.exists("cmt")) {
                        point.cmt = XML.getValue<string>("cmt");
                    }
                    
                    if(XML.exists("desc")) {
                        point.desc = XML.getValue<string>("desc");
                    }
                    
                    if(XML.exists("src")) {
                        point.src = XML.getValue<string>("src");
                    }
                    
                    if(XML.exists("link")) {
                        //LinkType
                    }
                    
                    calculateBounds(point.coor_lonlat);
                    
                    tracksegment.trkpt.push_back(point);
                }
                while(XML.setToSibling());
                
                tracksegments.push_back(tracksegment);
                
                XML.setToParent();
                XML.setToParent();
            }
            
            XML.setToParent();
            
            track.trkseg = tracksegments;
            gpxTracks.push_back(track);
        }
        
        gpxMetadata.bounds_mercator[0] = convertToMercator(gpxMetadata.bounds_lonlat[0]);
        gpxMetadata.bounds_mercator[1] = convertToMercator(gpxMetadata.bounds_lonlat[1]);
        
        return true;
    } else {
        // not found or parsing error
        ofLog(OF_LOG_ERROR, "Could not load " + _path);
        
        return false;
    }
};
コード例 #5
0
ファイル: Settings.cpp プロジェクト: dormantor/ofxCogEngine
	double SettingItem::GetValDouble(double defaultVal) {
		if (values.size() == 0) return defaultVal;
		return ofToDouble(values[0]);
	}
コード例 #6
0
ファイル: ofApp.cpp プロジェクト: bensnell/misc-iacd
//--------------------------------------------------------------
void ofApp::setup(){
	
	ofSetFrameRate(30);
	ofEnableAlphaBlending();
    
    // load data to buffer
    ofFile file("meteoritessize.csv");
    ofBuffer buffer(file);
    
    // read buffer to vector of meteorites
    bool bHeader = true;
    for (ofBuffer::Line it = buffer.getLines().begin(), end = buffer.getLines().end(); it != end; ++it) {
        
        // skip header line
        if (bHeader) {
            bHeader = false;
            continue;
        }
        
        // get this line
        string line = *it;
        if (line.find_first_not_of("\t\n ") == string::npos) continue; // skip empty lines
        vector<string> words;
        
        // some commas are within quotes, so delimit only when words are not in quotes
        while (!line.empty()) {
            
            // find the end index of the entry
            size_t endIndex = line.find_first_of(",");
            if (endIndex != string::npos) {
                // split by comma
                
                // check if quotation mark exists
                size_t firstQuoteIndex = line.find_first_of("\"");
                if (firstQuoteIndex != string::npos && endIndex > firstQuoteIndex) {
                    // quote exists and encompasses a comma
                    
                    // find the next quotation mark
                    size_t secondQuoteIndex = line.find_first_of("\"", firstQuoteIndex + 1);
                    // find comma after this second quotation mark
                    endIndex = line.find_first_of(",", secondQuoteIndex + 1);
                    
                    // remove these quotes from the line
                    line.erase(secondQuoteIndex, 1);
                    line.erase(firstQuoteIndex, 1);
                    // update the index
                    endIndex -= 2;
                }
            } else {
                // split by line break
                endIndex = line.find_first_of("\n");
                // or split by length by storing npos
            }
            
            // split the line appropriately and add entry to words vector
            if (endIndex != string::npos) {
                // split by the endIndex
                words.push_back(line.substr(0, endIndex));
                line.erase(0, endIndex + 1); // erase comma too
            } else {
                // add all of line
                words.push_back(line);
                line.erase();
            }
        }
        
        // put info into temp met object
        meteorite thisMet;
        thisMet.name = words[0];
        thisMet.type = words[1];
        // remove commas from words[2]
        size_t found = words[2].find_first_of(",");
        while (found != string::npos) {
            words[2].erase(found, 1);
            found = words[2].find_first_of(",");
        }
        thisMet.mass = ofToDouble(words[2]);
        thisMet.bFound = words[3].compare("Found") == 0;
        thisMet.year = ofToInt(words[4]);
        thisMet.database = words[5];
        thisMet.lat = ofToFloat(words[6]);
        thisMet.lon = ofToFloat(words[7]);
        
        // add object to vector
        mets.push_back(thisMet);
    }
    
    // print out size of vector and first entry
//    cout << mets.size() << endl;
//    cout << mets[0].name << " " << mets[0].type << " " << mets[0].mass << " " << mets[0].bFound << " " << mets[0].year << " " << mets[0].database << " " << mets[0].lat << " " << mets[0].lon << endl;
    
    // add all names to vector
    for (unsigned int i = 0, end = mets.size(); i < end; i++) {
        names.push_back(mets[i].name);
    }
    // sort vector
    sort(names.begin(), names.end());
    // add lowercase entries to their own searchable vector
    for (unsigned int i = 0, end = names.size(); i < end; i++) {
        namesLC.push_back(ofToLower(names[i]));
    }
    
    // print all names in alphabetical order
//    for (std::map<string, int>::iterator it = names.begin(), end = names.end(); it != end; ++it) {
//        cout << it->first << endl;
//    }
    
    font.load("OpenSans-Regular.ttf", 60);
    smallFont.load("OpenSans-Regular.ttf", 25);
    
    // initialized matched names vector
    for (int i = 0; i < nChars; i++) {
        vector<string> tempVec;
        matchedNames.push_back(tempVec);
    }
}
コード例 #7
0
void urgTimelapse::findFrames(float speed, float periodSize, float startPeriod) {
    
    // reset markers
    frames.clear();
//    nScans = -1;
    
    long thisScanNumber = 0;
    
    frame thisFrame;
    thisFrame.startTime = -1; // start (zero) condition
    
    // holds the current time sought after (to be >=)
    long searchTime = long(startPeriod * periodSize / speed * 1000.); // ms
    
    // loop through all lines to find the frames
    for (ofBuffer::Line it = buffer.getLines().begin(), end = buffer.getLines().end(); it != end; ++it) {
        
        string line = *it;
        if (line.empty()) {
            cout << "Empty line found. Stopping at scan # " << thisScanNumber << endl;
//            nScans = thisScanNumber;
            break;
        }
        
        // get time now
        line.resize((int)line.find_first_of(','));
        long timeNow = long(ofToDouble(line)); // ms
        
        // check if timeNow is greater than searchTime
        if (timeNow >= searchTime) {
            
            // new frame is found, so store existing frame (unless it's the zeroth frame)
            if (thisFrame.startTime != -1) {
                
                // update its length
                thisFrame.length = thisScanNumber - thisFrame.start;
                
                // add it to the frame vector
                frames.push_back(thisFrame);
            }
            
            // create a new frame with starting values
            thisFrame.start = thisScanNumber;
            thisFrame.startTime = float(timeNow / 1000.);
            
            // update the search time
            searchTime = long((startPeriod + frames.size() + 1) * periodSize / speed * 1000.);
        }
        
        // increment the scan number
        thisScanNumber++;
    }
    
    cout << frames.size() << " frames have been found." << endl;
    
//    if (nScans == -1) nScans = thisScanNumber
    
    
    // print all frame info
//    cout << "*** BEGIN ALL FRAME DATA ***" << endl;
//    cout << "#" << "\t" << "start" << "\t" << "length" << "\t" << "startTime" << endl;
//    for (long i = 0, end = frames.size(); i < end; i++) {
//        cout << i << "\t" << frames[i].start << "\t" << frames[i].length << "\t" << frames[i].startTime << endl;
//    }
//    cout << "*** END ALL FRAME DATA ***" << endl;
    
}
コード例 #8
0
void ofApp::guiEvent(ofxUIEventArgs &e) {
	
	string name = e.widget->getName();
	ofxUISuperCanvas* canvas = (ofxUISuperCanvas*)e.widget->getCanvasParent();
	string canvasName = canvas->getCanvasTitle()->getLabel();

	if(name == "realTime")
	{
		ofxUIToggle* widget = (ofxUIToggle*) e.widget;
		REAL_TIME = widget->getValue() == 1;
	}
	if(name == "realTimeFPSValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		REAL_TIME_FPS = ofToInt(widget->getTextString());
	}
	if(name == "realTimePort")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		REAL_TIME_PORT = ofToInt(widget->getTextString());
	}
	
	if(name == "resolutionXValue") {
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].ResolutionX = ofToInt(widget->getTextString());
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].ResolutionX = ofToInt(widget->getTextString());
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].ResolutionX = ofToInt(widget->getTextString());
		}
	}
	if(name == "resolutionYValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].ResolutionY = ofToInt(widget->getTextString());
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].ResolutionY = ofToInt(widget->getTextString());
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].ResolutionY = ofToInt(widget->getTextString());
		}
	}
	if(name == "resolutionDownSampleValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].ResolutionDownSample = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].ResolutionDownSample = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].ResolutionDownSample = ofToDouble(widget->getTextString());
		}
	}
	if(name == "colorRGB")
	{
		ofxUIToggle* widget = (ofxUIToggle*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].ColorRGB = widget->getValue() == 1;
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].ColorRGB = widget->getValue() == 1;
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].ColorRGB = widget->getValue() == 1;
		}
	}
	if(name == "FPSValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].FPS = ofToInt(widget->getTextString());
		}
		if (canvasName == "CAMERA 1") {
			cameras[0].FPS = ofToInt(widget->getTextString());
		}
		if (canvasName == "CAMERA 2") {
			cameras[0].FPS = ofToInt(widget->getTextString());
		}
	}

	if(name == "3D")
	{
		ofxUIToggle* widget = (ofxUIToggle*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].Use3D = widget->getValue() == 1;
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].Use3D = widget->getValue() == 1;
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].Use3D = widget->getValue() == 1;
		}
	}
	if(name == "2D")
	{
		ofxUIToggle* widget = (ofxUIToggle*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].Use2D = widget->getValue() == 1;
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].Use2D = widget->getValue() == 1;
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].Use2D = widget->getValue() == 1;
		}
	}

	if(name == "dataContextValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].DataContext = widget->getTextString();
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].DataContext = widget->getTextString();
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].DataContext = widget->getTextString();
		}
	}
	if(name == "nearValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].DepthSettings.Near = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].DepthSettings.Near = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].DepthSettings.Near = ofToDouble(widget->getTextString());
		}
	}
	if(name == "farValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].DepthSettings.Far = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].DepthSettings.Far = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].DepthSettings.Far = ofToDouble(widget->getTextString());
		}
	}
	if(name == "pointsDownSampleValue")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "CAMERA 0") {
			cameras[0].DepthSettings.PointsDownSample = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 1") {
			cameras[1].DepthSettings.PointsDownSample = ofToDouble(widget->getTextString());
		}
		if (canvasName == "CAMERA 2") {
			cameras[2].DepthSettings.PointsDownSample = ofToDouble(widget->getTextString());
		}
	}
	
	if(name == "m00")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[0] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[0] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[0] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m01")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[1] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[1] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[1] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m02")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[2] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[2] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[2] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m03")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[3] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[3] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[3] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m10")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[4] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[4] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[4] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m11")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[5] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[5] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[5] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m12")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[6] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[6] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[6] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m13")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[7] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[7] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[7] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m20")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[8] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[8] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[8] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m21")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[9] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[9] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[9] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m22")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[10] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[10] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[10] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m23")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[11] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[11] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[11] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m30")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[12] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[12] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[12] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m31")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[13] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[13] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[13] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m32")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[14] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[14] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[14] = ofToDouble(widget->getTextString());
		}
	}
	if(name == "m33")
	{
		ofxUITextInput* widget = (ofxUITextInput*) e.widget;
		if (canvasName == "MATRIX 0") {
			cameras[0].Matrix[15] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 1") {
			cameras[1].Matrix[15] = ofToDouble(widget->getTextString());
		}
		if (canvasName == "MATRIX 2") {
			cameras[2].Matrix[15] = ofToDouble(widget->getTextString());
		}
	}

	if(name == "SAVE")
	{
		ofxUILabelButton* widget = (ofxUILabelButton*) e.widget;
		if (widget->getValue() == 1) {
			saveXmlFile();
		}
	}
	if(name == "ADD CAMERA")
	{
		ofxUILabelButton* widget = (ofxUILabelButton*) e.widget;
		if (widget->getValue() == 1) {
			ofxUISuperCanvas* gui1 = NULL;
			ofxUISuperCanvas* gui2 = NULL;
			int i = 0;
			for (; i < allCameras.size(); i++) {
				if (allCameras[i] == NULL) {
					gui1 = new ofxUISuperCanvas("CAMERA " + ofToString(i));
					gui1->setPosition(250, 0);
					gui1->setVisible(false);
					allCameras[i] = gui1;

					gui1->autoSizeToFitWidgets();
					ofAddListener(gui1->newGUIEvent,this,&ofApp::guiEvent);
					gui1->loadSettings("guiSettings.xml");

					gui2 = new ofxUISuperCanvas("MATRIX " + ofToString(i));
					gui2->setPosition(480, 0);
					gui2->setVisible(false);
					allMatrix[i] = gui2;
					
					gui2->autoSizeToFitWidgets();
					ofAddListener(gui2->newGUIEvent,this,&ofApp::guiEvent);
					gui2->loadSettings("guiSettings.xml");

					allTabs[i]->setVisible(true);
					break;
				}
			}
			if (gui1 == NULL) {
				return;
			}
			gui->setHeight(720);
			gui1->setHeight(720);
			gui2->setHeight(720);

			gui1->addSpacer();
			gui1->addLabel("Camera Options:");

			gui1->addLabel("resolutionX");
			gui1->addTextInput("resolutionXValue", "800");

			gui1->addLabel("resolutionY");
			gui1->addTextInput("resolutionYValue", "600");

			gui1->addLabel("resolutionDownSample");
			gui1->addTextInput("resolutionDownSampleValue", "1");
	
			gui1->addToggle("colorRGB", true);

			gui1->addLabel("FPS");
			gui1->addTextInput("FPSValue", "24");

			vector<string> radioItems;
			radioItems.push_back("3D");
			radioItems.push_back("2D");
			gui1->addRadio("type", radioItems, OFX_UI_ORIENTATION_HORIZONTAL);

			gui1->addLabel("dataContext");
			gui1->addTextInput("dataContextValue", "");
	
			gui1->addSpacer();
			gui1->addLabel("Depth Settings:");

			gui1->addLabel("near");
			gui1->addTextInput("nearValue", "0");

			gui1->addLabel("far");
			gui1->addTextInput("farValue", "0");

			gui1->addLabel("pointsDownSample");
			gui1->addTextInput("pointsDownSampleValue", "0");
	
			gui2->addSpacer();
			gui2->addLabel("Matrix Settings:");
	
			gui2->addLabel("m[0,0]");
			gui2->addTextInput("m00", ofToString(cameras[i].Matrix[0]));
			gui2->addLabel("m[0,1]");
			gui2->addTextInput("m01", ofToString(cameras[i].Matrix[1]));
			gui2->addLabel("m[0,2]");
			gui2->addTextInput("m02", ofToString(cameras[i].Matrix[2]));
			gui2->addLabel("m[0,3]");
			gui2->addTextInput("m03", ofToString(cameras[i].Matrix[3]));
			gui2->addLabel("m[1,0]");
			gui2->addTextInput("m10", ofToString(cameras[i].Matrix[4]));
			gui2->addLabel("m[1,1]");
			gui2->addTextInput("m11", ofToString(cameras[i].Matrix[5]));
			gui2->addLabel("m[1,2]");
			gui2->addTextInput("m12", ofToString(cameras[i].Matrix[6]));
			gui2->addLabel("m[1,3]");
			gui2->addTextInput("m13", ofToString(cameras[i].Matrix[7]));
			gui2->addLabel("m[2,0]");
			gui2->addTextInput("m20", ofToString(cameras[i].Matrix[8]));
			gui2->addLabel("m[2,1]");
			gui2->addTextInput("m21", ofToString(cameras[i].Matrix[9]));
			gui2->addLabel("m[2,2]");
			gui2->addTextInput("m22", ofToString(cameras[i].Matrix[10]));
			gui2->addLabel("m[2,3]");
			gui2->addTextInput("m23", ofToString(cameras[i].Matrix[11]));
			gui2->addLabel("m[3,0]");
			gui2->addTextInput("m30", ofToString(cameras[i].Matrix[12]));
			gui2->addLabel("m[3,1]");
			gui2->addTextInput("m31", ofToString(cameras[i].Matrix[13]));
			gui2->addLabel("m[3,2]");
			gui2->addTextInput("m32", ofToString(cameras[i].Matrix[14]));
			gui2->addLabel("m[3,3]");
			gui2->addTextInput("m33", ofToString(cameras[i].Matrix[15]));
		}
	}
	
	if(name == "CAMERA 0")
	{
		ofxUILabelButton* widget = (ofxUILabelButton*) e.widget;
		if (widget->getValue() == 1) {
			ofxUISuperCanvas* gui1 = allCameras[0];
			ofxUISuperCanvas* gui2 = allMatrix[0];
			gui1->setVisible(true);
			gui2->setVisible(true);
			gui1 = allCameras[1];
			gui2 = allMatrix[1];
			if (gui1 != NULL) {
				gui1->setVisible(false);
				gui2->setVisible(false);
			}
			gui1 = allCameras[2];
			gui2 = allMatrix[2];
			if (gui1 != NULL) {
				gui1->setVisible(false);
				gui2->setVisible(false);
			}
		}
	}
	if(name == "CAMERA 1")
	{
		ofxUILabelButton* widget = (ofxUILabelButton*) e.widget;
		if (widget->getValue() == 1) {
			ofxUISuperCanvas* gui1 = allCameras[0];
			ofxUISuperCanvas* gui2 = allMatrix[0];
			gui1->setVisible(false);
			gui2->setVisible(false);
			gui1 = allCameras[1];
			gui2 = allMatrix[1];
			gui1->setVisible(true);
			gui2->setVisible(true);
			gui1 = allCameras[2];
			gui2 = allMatrix[2];
			if (gui1 != NULL) {
				gui1->setVisible(false);
				gui2->setVisible(false);
			}
		}
	}
	if(name == "CAMERA 2")
	{
		ofxUILabelButton* widget = (ofxUILabelButton*) e.widget;
		if (widget->getValue() == 1) {
			ofxUISuperCanvas* gui1 = allCameras[0];
			ofxUISuperCanvas* gui2 = allMatrix[0];
			gui1->setVisible(false);
			gui2->setVisible(false);
			gui1 = allCameras[1];
			gui2 = allMatrix[1];
			gui1->setVisible(false);
			gui2->setVisible(false);
			gui1 = allCameras[2];
			gui2 = allMatrix[2];
			gui1->setVisible(true);
			gui2->setVisible(true);
		}
	}
}
コード例 #9
0
//--------------------------------------------------------------
void ofApp::setup() {
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofBackground( 255, 255, 255);
	
    camPosx = 0;
    camPosy = -7;
    camPosz = -10;
    
    camA = 0;
    camB = 0;
    camC = 0;
    
    
    
	camera.setPosition(ofVec3f(camPosx, camPosy, camPosz));
	camera.lookAt(ofVec3f(camA, camB, camC), ofVec3f(0, -1, 0));

	world.setup();
	world.enableGrabbing();
	world.enableDebugDraw();
	world.setCamera(&camera);
	
	sphere = new ofxBulletSphere();
	sphere->create(world.world, ofVec3f(0, 0, 0), 0.1, 3);
	sphere->add();
	
		
	ground.create( world.world, ofVec3f(0., 5.5, 0.), 0., 100.f, 1.f, 100.f );
	ground.setProperties(.25, .95);
	ground.add();
    
    
    
    
    //CSV parse
    currentIndex = 0;
    
    //Path to the comma delimited file
    string filePath = "earthquakes.csv";
    
    //Load file placed in bin/data
    ofFile file(filePath);
    
    if(!file.exists()){
        ofLogError("The file " + filePath + " is missing");
    }
    ofBuffer buffer(file);
    
    //Read file line by line
    
    for (ofBuffer::Line it = buffer.getLines().begin(), end = buffer.getLines().end(); it != end; ++it) {
        string line = *it;
        
        //Split line into strings
        vector<string> words = ofSplitString(line, ",");
        
        //add elements to longlatVector
        temp.longitude = ofToDouble(words[1]);
        temp.latitude = ofToDouble(words[2]);
//        cout << words[14].substr(0,11) <<endl;
        if ((words[14].substr(0,11)).compare(" California")){
            
            temp.cali = true;
        }
        else {
            temp.cali = false;
        }
        
        
        longlatVector.push_back(temp);
        
    }
    
    cout << longlatVector.size() << endl;
    
    for(int i = 0; i < longlatVector.size(); i++){
        //cout << longlatVector[i].longitude << " longitude" << endl;
        testPoint = placePoint(longlatVector[i].latitude, longlatVector[i].longitude, sphere->getRadius());
        //cout << testPoint << " testPoint" << endl;
        earthquakePoints.push_back(testPoint); //vector of 3d vectors
        
    }
    
    //now we can draw them

    
    
    
}
コード例 #10
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetVerticalSync(true);
    ofEnableAntiAliasing();
    glEnable(GL_POINT_SMOOTH); // use circular points instead of square points
    glPointSize(3);
    
//    // --- Loading files
    ofFileDialogResult openFileResult = ofSystemLoadDialog("Get the txt data", true);
    ofLogNotice()  << "Folder: " << openFileResult.getPath();
    ofDirectory     dirFiles;
    dirFiles.listDir( openFileResult.getPath() );
    ofDrawBitmapString("Loading files", ofGetWidth()/2 - 20, ofGetHeight() / 2 );
    
    for ( int indexOfFile = 0; indexOfFile < dirFiles.size(); ++indexOfFile )
    {
//        ofLogNotice() << "file: " << dirFiles.getPath( indexOfFile );
        ofBuffer buffer = ofBufferFromFile( dirFiles.getPath( indexOfFile ) );
        std::vector< weatherData >     currentWeatherData;
        
        if(buffer.size()) {
            buffer.getNextLine();
            while(buffer.isLastLine() == false) {
                string              line = buffer.getNextLine();
                std::stringstream   lineStream( line );
                string              cell;
                std::getline( lineStream, cell, ';' );
                weatherData data;
                
                std::getline( lineStream, cell, ';' );
                data.lon = ofToDouble( cell );
                std::getline( lineStream, cell, ';' );
                data.lat = ofToDouble( cell );
                std::getline( lineStream, cell, ';' );
                data.temp = ofToDouble( cell );
                std::getline( lineStream, cell, ';' );
                data.velWind = ofToDouble( cell );
                
                currentWeatherData.push_back( data );
//                std::cout << data.lon << "\t" << data.lat << "\t" << data.temp << "\n";
            }
        }
        weatherTimed.weatherDataVector.push_back( currentWeatherData );
        
        // --- transform into pixel vec
        ofMesh  currentMeshTemp, currentMeshWind;
        currentMeshTemp.setMode(OF_PRIMITIVE_POINTS);
        currentMeshWind.setMode(OF_PRIMITIVE_POINTS);
        
        for ( auto &data : weatherTimed.weatherDataVector[ indexOfFile ] )
        {
            data.point = ofVec3f( ofMap( data.lon, 0, 357, 0, 300 ),
                                  ofMap( data.lat, 32, 77, 0, 100),
                                  ofMap( data.temp, 273, 320, 0, 100 ) );
            currentMeshTemp.addColor( ofColor(ofMap( data.temp, 273, 320, 0, 255, true ), 0, 0 ) );
            currentMeshTemp.addVertex( data.point );
            
            currentMeshWind.addColor( ofColor( 0, 0, ofMap( std::abs( data.velWind ), 0, 45, 0, 255, true ) ) );
            currentMeshWind.addVertex( ofVec3f( ofMap( data.lon, 0, 357, 0, 300 ),
                                               ofMap( data.lat, 32, 77, 0, 100),
                                               ofMap( data.velWind, -55, 55, -100, 100 ) ) );
        }
        weatherTimed.meshVecTemp.push_back( currentMeshTemp );
        weatherTimed.meshVecWind.push_back( currentMeshWind );
    }
    
    ofLogNotice() << "Loaded file amount: " << weatherTimed.meshVecTemp.size();

    tempButton.addListener( this, &ofApp::tempPlotActivation );
    windButton.addListener( this, &ofApp::windPlotActivation );
    
    gui.setup();
    gui.add( tempButton.setup( "Temperature Plot", true ) );
    gui.add( windButton.setup("Wind Velocity Plot", false ) );
	gui.add( timeSlider.setup("time", 0, 0, weatherTimed.meshVecTemp.size() - 1 ) );
    gui.add( playButton.setup("play time", false ) );
    gui.add( rotation.setup( "rotation", 0, 0, 360 ) );
    gui.add( autoRotate.setup("Auto Rotate", true ) );
    
    cam.disableMouseInput();
    rotation = 0.0;
    tempPlotActivation();
    
    picturePlot.loadImage("Plot1.png");
}