float ofxDOMLayoutHelper::getDesiredHeight(DOM::Element* e, float parentHeight){ float res = e->getMinHeight() + getPaddingVertical(e); if(e->hasAttribute("_height")){ std::string heightstr = e->getAttribute<std::string>("_height"); if(ofIsStringInString(heightstr, "%")){ vector<std::string> _val = JsonConfigParser::getMatchedStrings(heightstr, "(?:\\b|-)([1-9]{1,2}[0]?|100)\\b"); if(_val.size() > 0){ float amount = ofToFloat(_val[0])/100.; return parentHeight*amount-getMarginVertical(e); } }else { return ofToFloat(heightstr); } } return res; }
//-------------------------------------------------------------- void ofApp::guiEvent(ofxUIEventArgs &e) { string name = e.getName(); string alignment = "alignment"; if(name == "pixelWidth" || name == "pixelWidthLarge"){ ((ofxUITextInput*)settingCanvas->getWidget("pixelWidthText"))->setTextString(ofToString(float(desideredPixelWidthLarge)+desideredPixelWidth)); }else if(name == "pixelWidthText"){ string val = ((ofxUITextInput*)e.widget)->getTextString(); float fval = ofToFloat(val); desideredPixelWidth = fmodf(fval,1.0); desideredPixelWidthLarge = floor(fval); }else if(name == "Calibrate Menu"){ lastState = state; state = Calibratig; settingCanvas->setVisible(false); calibrateCanvas->setVisible(true); }else if(name.substr(0,alignment.size()) == alignment ){ int start = alignment.size()+1; int x = ofToInt(name.substr(start,start+1)); int y = ofToInt(name.substr(start+2,start+3)); texAlign.x = x == 0 ? 0 : x == 1 ? 0.5 : 1.0; texAlign.y = y == 0 ? 1.0 : y == 1 ? 0.5 : 0.0; }else if(name == "Settings Menu"){ lastState = state; state = Settings; settingCanvas->setVisible(true); calibrateCanvas->setVisible(false); }else if(name == "Calibration Size"){ ofxUIRadio* w = ((ofxUIRadio*)e.widget); string active = w->getActiveName(); vector<string> names(calibrationSizeOptionsNames,end(calibrationSizeOptionsNames)); int pos = find(names.begin(), names.end(), active) - names.begin(); ((ofxUILabel*)calibrateCanvas->getWidget("selected_calibration"))->setLabel(calibrationSizeOptionsNames[pos]); currentCalibratorTolLengthInMM = calibrationSizeOptionsValues[pos]; }else if(name == "Read From Marker"){ outPixelPerMM = calibratorTool.getLength() / currentCalibratorTolLengthInMM; }else if(name == "Syphon Servers"){ ofxUIRadio *syphon_list = (ofxUIRadio*)e.widget; string active = syphon_list->getActiveName(); vector<string> parts = ofSplitString(active, "::"); syphonServerDesc = ofxSyphonServerDescription(parts[0],parts[1]); syphonClient.set(syphonServerDesc); }else if(name == "Mode"){ ofxUIRadio *mode_list = (ofxUIRadio*)e.widget; if(mode_list->getActiveName() == "Round"){ mode = 0; }else { mode = 1; } } }
void CloudsVisualSystemFireworks::loadFileToGeometry( string loc, vector<ofVec3f>& points ) { ofBuffer buffer = ofBufferFromFile( loc ); points.clear(); if(buffer.size()) { while (buffer.isLastLine() == false) { string line = buffer.getNextLine(); vector<string> vals = ofSplitString( line, ","); points.push_back( ofVec3f( ofToFloat(vals[0]),ofToFloat(vals[1]),ofToFloat(vals[2]) ) ); } } buffer.clear(); }
void ofxResolume::fragment(int layer,int input){ //OSC route //layer1/video/effect1/param1/values (Float 0.0 - 1.0) ofxOscMessage mr; mr.setAddress("/layer"+ofToString(layer)+"/video/effect1/param1/values"); mr.addFloatArg(ofMap(ofToFloat(ofToString(input)),0.0,1024.0,0.0,1.0));//remap the input(mouseX) resSender.sendMessage(mr); }
float ofxDOMLayoutHelper::getDesiredWidthStretched(DOM::Element* e, float parentWidth){ float res = e->getMinWidth() + getPaddingHorizontal(e); if(e->hasAttribute("_width")){ std::string widthstr = e->getAttribute<std::string>("_width"); if(ofIsStringInString(widthstr, "%")){ vector<std::string> _val = JsonConfigParser::getMatchedStrings(widthstr, "(?:\\b|-)([1-9]{1,2}[0]?|100)\\b"); if(_val.size() > 0){ float amount = ofToFloat(_val[0])/100.; return parentWidth*amount-getMarginHorizontal(e); } }else { return ofToFloat(widthstr); } } return max(res, parentWidth-getMarginHorizontal(e)); }
void ofxBox::loadParts(const string& path){ ifstream fs( ofToDataPath(path).c_str()); string line; int lineCounter = 0; //cout << "- Loading box: " << path << endl; while(!(fs >> line).fail()){ vector <string> values = ofSplitString(line, ","); string _pathImage = values[0]; float _radio = ofToFloat(values[1].c_str()); // the first value is the Letter or Key, the second one is radio from the center float _angle = ofToFloat(values[2].c_str()); // the 3th is the angle on radians from the center (this last to parameters are the ones that let the keabord be redraw in any angle and continue working) int _xI = ofToInt(values[3].c_str()); // the 4th and 5th are the with and height of each key. int _yI = ofToInt(values[4].c_str()); bool _m = ( ofToInt(values[5].c_str() ) != 0 )?true:false; _pathImage = objDir + "/" + _pathImage; ofxElement p = ofxElement( _pathImage, _radio, _angle, _xI, _yI,_m); if (_pathImage == (objDir + "/core.png")){ width = p.getWidth() * scale; height = p.getHeight() * scale; //cout << "--- Core Structure Found width " << width << "x" << height << endl; } if (_pathImage == (objDir + "/shadow.png")){ height = p.getRadio(); } p.setScale(&scale); p.setBodyNorth(&angle); p.setBodyCenter(&pos); p.fromPolarToCart(); element.push_back(p); } fs.seekg(0,ios::beg); fs.clear(); fs.close(); if ((width == -1) && (height != -1)) height = width; }
//-------------------------------------------------------------- void testApp::update(){ if (bSendSerialMessage){ // (1) write the letter "a" to serial: serial.writeByte('a'); // (2) read // now we try to read 3 bytes // since we might not get them all the time 3 - but sometimes 0, 6, or something else, // we will try to read three bytes, as much as we can // otherwise, we may have a "lag" if we don't read fast enough // or just read three every time. now, we will be sure to // read as much as we can in groups of three... nTimesRead = 0; nBytesRead = 0; int nRead = 0; // a temp variable to keep count per read unsigned char bytesReturned[3]; memset(bytesReadString, 0, 4); memset(bytesReturned, 0, 3); while( (nRead = serial.readBytes( bytesReturned, 3)) > 0){ nTimesRead++; nBytesRead = nRead; }; float fbytesReadString = ofToFloat(bytesReadString); fbytesReadString = ofMap(fbytesReadString, 0, 1023, 10, 12); memcpy(bytesReadString, bytesReturned, 3); readTime = ofGetElapsedTimef(); if ( spacebrew.isConnected() ){ float LightData = ofToFloat(bytesReadString); spacebrew.sendRange("LightData", (LightData) ); } }}
void testApp::addObject( vector < string > _stringList ) { for ( int i = 0; i < _stringList.size(); i += 3 ) { // This function adds an NPC Object. Object tmp; tmp.setup( iScaler, staffPosList, _stringList[ i ], ofToInt( _stringList[ i + 2 ] ) ); tmp.pos.x = ofToFloat( _stringList[ i + 1 ] ); objectList.push_back( tmp ); } }
void ofxGuiInputField<Type>::parseInput(){ bChangedInternally = true; Type tmpVal = ofToFloat(input); if(tmpVal < getMin()){ tmpVal = getMin(); }else if(tmpVal > getMax()){ tmpVal = getMax(); } value = tmpVal; }
//-------------------------------------------------------------- void ofApp::loadCsvToMemes(string filePath){ ofFile file(filePath); if(!file.exists()){ ofLogError("The file " + filePath + " is missing"); } ofBuffer buffer(file); //データをVector(配列)に読み込む //CSVファイルを読み込んで、1行ごとに配列linesの要素として読み込む for (ofBuffer::Line it = buffer.getLines().begin(), end = buffer.getLines().end(); it != end; ++it) { string line = *it; vector<string> data = ofSplitString(line, ","); if (data.size()>=6) { Meme meme; meme.user_id = data[0]; meme.zone_date = data[1]; meme.zone_focus = ofToFloat(data[3]); meme.zone_calm = ofToFloat(data[4]); meme.zone_posture = ofToFloat(data[5]); memes.push_back(meme); if(it == buffer.getLines().begin()){ max_focus = min_focus = meme.zone_focus; max_calm = min_calm = meme.zone_calm; max_posture = min_posture = meme.zone_posture; } else{ //データをひとつずつ比較しながら最小値最大値を調べる max_focus = (meme.zone_focus > max_focus) ? meme.zone_focus : max_focus; min_focus = (meme.zone_focus < min_focus) ? meme.zone_focus : min_focus; max_calm = (meme.zone_calm > max_calm) ? meme.zone_calm : max_calm; min_calm = (meme.zone_calm < min_calm) ? meme.zone_calm : min_calm; max_posture = (meme.zone_posture > max_posture) ? meme.zone_posture : max_posture; min_posture = (meme.zone_posture < min_posture) ? meme.zone_posture : min_posture; } } } }
void ofApp::countRatings() { //find the average raiting for each country for (int i = 0; i < _csv.data.size(); i++) { if (ofToString(_csv.data[i][0]).compare("")!=0 && ofToString(_csv.data[i][1]).compare("")!=0) { //if this is the first country on the list. if (countrys.size() == 0) { Country tempContry; tempContry.name = ofToString(_csv.data[i][0]); tempContry.numberOfRaitings = 1; tempContry.averageRaiting = ofToFloat(_csv.data[i][1]); countrys.push_back(tempContry); } bool foundMatch = false; int matchNum = -1; for (int j = countrys.size()-1; j > 0; j--) { if (ofToString(_csv.data[i][0]).compare(countrys[j].name) == 0) { foundMatch = true; matchNum = j; break; } } if (foundMatch) { countrys[matchNum].numberOfRaitings += 1; countrys[matchNum].averageRaiting = (countrys[matchNum].averageRaiting*float(countrys[matchNum].numberOfRaitings-1) + ofToFloat(_csv.data[i][1])) / countrys[matchNum].numberOfRaitings; matchNum = false; } else { Country tempContry; tempContry.name = ofToString(_csv.data[i][0]); tempContry.numberOfRaitings = 1; tempContry.averageRaiting = ofToFloat(_csv.data[i][1]); countrys.push_back(tempContry); } } } //print out the country data //for (int i = 0; i < countrys.size(); i++) { // cout << countrys[i].name + " : " + ofToString(countrys[i].numberOfRaitings) + " : " + ofToString(countrys[i].averageRaiting) << endl; //} cout << "done making countrys" << endl; sortByAvgRaitings(); }
//-------------------------------------------------------------- void testApp::setup() { ofDisableAntiAliasing(); ofBackgroundHex(0xfdefc2); ofSetLogLevel(OF_LOG_NOTICE); ofSetVerticalSync(true); // Box2d box2d.init(); box2d.setGravity(0, 30); box2d.createGround(); box2d.setFPS(30.0); // load the lines we saved... ifstream f; f.open(ofToDataPath("lines.txt").c_str()); vector <string> strLines; while (!f.eof()) { string ptStr; getline(f, ptStr); strLines.push_back(ptStr); } f.close(); for (int i=0; i<strLines.size(); i++) { vector <string> pts = ofSplitString(strLines[i], ","); if(pts.size() > 0) { ofPtr <ofxBox2dEdge> edge = ofPtr<ofxBox2dEdge>(new ofxBox2dEdge); for (int j=0; j<pts.size(); j+=2) { if(pts[j].size() > 0) { float x = ofToFloat(pts[j]); float y = ofToFloat(pts[j+1]); edge.get()->addVertex(x, y); } } edge.get()->create(box2d.getWorld()); edges.push_back(edge); } } }
void bandBar::setup(xmlParse * config) { clearBut.setTitle("clear blocks"); clearBut.setTextSize(24); clearBut.setAvailable(true); sideBarBack.loadImage("images/sidebar.jpg"); string font=config->prop; for (unsigned int i=0; i<config->size(); i++) { xmlParse xml=config->child[i]; if (xml.label=="instrument") { string col=xml.prop; string title=xml.name; cout << title << " current instrument" << endl; long color=strtol(col.c_str(),NULL,0); int curInst=instruments.size(); unsigned char note, channel; bool repeat=false; double delay=0; map<string,int> list; list["note"]=0; list["channel"]=1; list["repeat"]=2; list["delay"]=3; list["dropdown"]=4; cout << xml.size() << " number of children" << endl; for(int j=0; j<xml.size(); j++) { string * node=xml.getSubnode(j); switch (list.find(node[0])->second) { case 0: note=ofToInt(node[1]); break; case 1: channel=ofToInt(node[1]); break; case 2: repeat=true; break; case 3: delay=ofToFloat(node[1]); break; case 8: //ddGroup.push_back(ofDropDown(&xml->child[i])); break; default: break; } } instruments.push_back( instrument(title,channel,note,repeat)); instruments[curInst].setColor(color); instruments[curInst].setDelay(delay); } } setHeight(); }
ofInterObj * demoAnim::searchForObject(ofTag & tag, int & _x, int & _y) { ofInterObj * ret=0; string where=tag.getAttribute("where"); string xTemp=tag.getAttribute("x"); string yTemp=tag.getAttribute("y"); vector<string> whSplit = ofSplitString(where, "[]."); if(whSplit[0]=="sidebar"){ if(whSplit.size()==2) ret=((*sideBar)[ofToInt(whSplit[1])]); if(whSplit.size()==3) ret=&((*(*sideBar)[ofToInt(whSplit[1])])[ofToInt(whSplit[2])]); } if(whSplit[0]=="openBar"){ if(whSplit.size()==2&&sideBar->openBar()){ if(whSplit[1]=="drop") ret=&((as_dynamic(sideBar->openBar()))->select); else ret=&((*(sideBar->openBar()))[ofToInt(whSplit[1])]); } } else if(whSplit[0]=="sidebarButton"){ if(whSplit.size()==2) ret=&((*sideBar)[ofToInt(whSplit[1])])->button; } else if(whSplit[0]=="base"){ if(whSplit.size()==1) ret=&(blocks->base); else if(whSplit.size()>=2&&whSplit[1]=="last") ret=searchBlock(whSplit,blocks->base.blocksOn.back(),2); else if(whSplit.size()>=2) ret=searchBlock(whSplit,blocks->base.blocksOn[ofToInt(whSplit[1])],2); } else if(whSplit[0]=="upload"){ ret=&blocks->base.uploadBut; //TODO: update the base block to include the upload button. } else if(whSplit[0]=="test"){ ret=&blocks->base.testBut; } vector<string> xSpl = ofSplitString(xTemp, "+-/*"); if(xSpl.size()==1) _x=ofToInt(xSpl[0]); else if(xSpl.size()==2) _x=operaterByChar(ret->w,xTemp[xSpl[0].length()],ofToFloat(xSpl[1])); vector<string> ySpl = ofSplitString(yTemp, "+-/*"); if(ySpl.size()==1) _y=ofToInt(ySpl[0]); else if(ySpl.size()==2) _y=operaterByChar(ret->h,yTemp[ySpl[0].length()],ofToFloat(ySpl[1])); return ret; }
bool LedsManager::parseLedLine(string& line, ofPoint& position) { if(line.size() == 0){ return false; } char chars[] = "{}"; removeCharsFromString(line, chars); //vector <string> strings = ofSplitString(line, ". " ); //id = ofToInt(strings[0]); vector <string> positionsStrings = ofSplitString(line, ", " ); position.x = ofToFloat(positionsStrings[0])*0.1; position.y = ofToFloat(positionsStrings[1])*0.1; position.z = ofToFloat(positionsStrings[2])*0.1; return true; }
void ofxTLPage::loadElementPositions() { ofxXmlSettings elementPositions; if(elementPositions.loadFile("settings/timeline/" + name + "_elementPositions.xml")) { //cout << "loading element position " << name << "_elementPositions.xml" << endl; elementPositions.pushTag("positions"); int numElements = elementPositions.getNumTags("element"); for(int i = 0; i < numElements; i++) { string name = elementPositions.getAttribute("element", "name", "", i); elementPositions.pushTag("element", i); ofRectangle elementPosition = ofRectangle(ofToFloat(elementPositions.getValue("x", "0")), ofToFloat(elementPositions.getValue("y", "0")), ofToFloat(elementPositions.getValue("width", "0")), ofToFloat(elementPositions.getValue("height", "0"))); savedElementPositions[name] = elementPosition; elementPositions.popTag(); } elementPositions.popTag(); } }
//-------------------------------------------------------------- void Interface::load( int index ) { string fileName = "presets/preset" + ofToString( index ) + ".txt"; string text = string( ofBufferFromFile( fileName ) ); vector<string> list = ofSplitString( text, " " ); if ( list.size() == slider.size() ) { for (int i=0; i<slider.size(); i++) { *slider[i].value = ofToFloat( list[i] ); } } }
void shakeData::loadDAT(string filename) { file=filename; ifstream input(ofToDataPath(file).c_str()); string buffer; int lineCount=0; getline(input,buffer); double lastTime=0; while(!input.eof()){ getline(input, buffer); vector<string> spl=ofSplitString(buffer," \t"); if(spl.size()){ float time=ofToFloat(spl[0]); uData.push_back(dataPoint(ofToFloat(spl[1]),time-lastTime)); sampFreq=1/(time-lastTime); lastTime=time; } } input.close(); processData(); }
int Telemetry::parse(string line) { ofLogNotice() << "onNewSerialLine, message: " << line << endl; vector<string> input = ofSplitString(line, ","); string msgtype = input.at(0); if(msgtype == "GPSL") { if( input.size() == 3) { ofLogNotice() << "GPSL line found"; gps.lat = ofToFloat( input.at(1) ); gps.lon = ofToFloat( input.at(2) ); int i = 0; ofNotifyEvent( onGpsCoordinates, i ); } else { ofLogNotice() << "ignored GPS reading: " << line; } } else if (msgtype == "GPSQ") { if( input.size() == 4) { ofLogNotice() << "GPSQ line found"; gps.fix = ofToBool( input.at(1) ); gps.quality = ofToInt( input.at(2) ); gps.satelites = ofToInt( input.at(3) ); } else { ofLogNotice() << "ignored GPS reading: " << line; } } else if(msgtype == "IMU") { if( input.size() == 4) { imu.yaw = ofToFloat( input.at(1) ); imu.pitch = ofToFloat( input.at(2) ); imu.roll = ofToFloat( input.at(3) ); } else { ofLogNotice() << "rejected IMU reading: " << line; } // ofLogNotice() << "IMU line found"; // for ( std::vector<std::string>::iterator it=input.begin(); it<input.end(); it++) { // std::cout << ' ' << *it; // } } }
cloudsSequencer::cloudsSequencer(string f, vector<lukeNote>& n) { string sline; ofFile seqfile (GetCloudsDataPath()+"sound/seqs/" + f); if(!seqfile.exists()) { ofLogError("can't find sequence!"); } ofBuffer seqbuf(seqfile); while(!seqbuf.isLastLine()) { sline = seqbuf.getNextLine(); vector<string> temp = ofSplitString(sline, " "); lukeNote foo; foo.starttime = ofToFloat(temp[0])/1000.; foo.pitch = ofToInt(temp[1]); foo.velo = (ofToFloat(temp[2])/128.); foo.dur = ofToFloat(temp[3])/1000.; //cout << foo.starttime << ": " << foo.pitch << " " << foo.velo << " " << foo.dur << endl; n.push_back(foo); } }
void ofApp::processInstance(const ICalendarEventInstance& instance) { if (instance.isValidEventInstance()) { std::string description = instance.getEvent().getDescription(); std::vector<std::string> lines = ofSplitString(description, "\n", true, true); std::vector<std::string>::iterator iter = lines.begin(); while (iter != lines.end()) { std::vector<std::string> tokens = ofSplitString(*iter, "=", true, true); if (tokens.size() == 2) { if (tokens[0] == "color") { std::vector<std::string> rgbTokens = ofSplitString(tokens[1], ",", true, true); if (rgbTokens.size()) { currentColor.set(ofToFloat(rgbTokens[0]), ofToFloat(rgbTokens[1]), ofToFloat(rgbTokens[2])); } } else if(tokens[0] == "speed") { currentSpeed = ofToFloat(tokens[1]); } else { ofLogError("ofApp::processInstance") << "Unknown key."; } } ++iter; } } }
//-------------------------------------------------------------- void Path3D::parsePts(string filename, ofPolyline &polyline){ ofFile file = ofFile(ofToDataPath(filename)); polyline.clear(); if(!file.exists()){ ofLogError("The file " + filename + " is missing"); } ofBuffer buffer(file); //Read file for (ofBuffer::Line it = buffer.getLines().begin(); it != buffer.getLines().end(); it++) { string line = *it; float scalar = 10; ofVec3f offset; if (filename == "path_XZ.txt"){ offset = ofVec3f(0, 0, 0); scalar = 3; } else if (filename == "path_YZ.txt"){ offset = ofVec3f(0, 0, 0); scalar = 3; } else{ offset = ofVec3f(0, 0, .25); scalar = 3; } ofStringReplace(line, "{", ""); ofStringReplace(line, "}", ""); cout<<line<<endl; vector<string> coords = ofSplitString(line, ", "); // get x y z coordinates ofVec3f p = ofVec3f(ofToFloat(coords[0])*scalar,ofToFloat(coords[1])*scalar,ofToFloat(coords[2])*scalar); p += offset; polyline.addVertex(p); } }
//-------------------------------------------------------------- param::param(int _id, int _pattern_id, string _name, ofxSQLite* _sqlite) { id = _id; pattern_id = _pattern_id; name = _name; sqlite = _sqlite; if (id == 0) { // create default values for ( int b=0; b<NUM_BEATS; b++ ) { for ( int s=0; s<NUM_STEPS; s++ ) { values[b][s] = 0.0; } } save(); } else { // load existing values ofxSQLiteSelect sel = sqlite->select("step_data") .from("params") .where("id", id) .execute().begin(); while(sel.hasNext()) { string step_data = sel.getString(); // parse step_data into values char * str = new char[step_data.size() + 1]; std::strcpy ( str, step_data.c_str() ); char * pch; pch = strtok (str," "); int b = 0; int s = 0; while (pch != NULL) { values[b][s] = ofToFloat( pch ); s ++; if (s >= NUM_STEPS) { s = 0; b++; } pch = strtok (NULL, " "); } sel.next(); } } }
void remapBand::setup(xmlParse * config,double hgt) { bar.w=rightBorder=0; blockMargin.x=10; blockMargin.y=5; numBlocksPerBin=4; clearBut.setup("clear blocks",24); clearBut.setAvailable(true); string font=config->prop; for (unsigned int i=0; i<config->size(); i++) { xmlParse xml=config->child[i]; if (xml.label=="instrument") { string col=xml.prop; string title=xml.name; long color=strtol(col.c_str(),NULL,0); int curInst=instruments.size(); unsigned char note, channel; bool percussive=false; double delay=0; map<string,int> list; list["note"]=0; list["channel"]=1; list["percussive"]=2; list["delay"]=3; list["dropdown"]=4; for(int j=0;j<xml.size();j++){ string * node=xml.getSubnode(j); switch (list.find(node[0])->second) { case 0: note=ofToInt(node[1]); break; case 1: channel=ofToInt(node[1]); break; case 2: percussive=true; break; case 3: delay=ofToFloat(node[1]); break; break; default: break; } } instruments.push_back( new remapInst(title,channel,note)); instruments[curInst]->setColor(color); } } configureSize(); }
void Session::newPosition(){ if(index < counter){ for(int i = 0; i < speed; i ++){ if(index < counter) { vector<string> tokens = ofSplitString(rows[index], ";"); float pos_x = ofToFloat(tokens[0]); float pos_y = ofToFloat(tokens[1]); int x = ofToInt(tokens[2]); int y = ofToInt(tokens[3]); int z = ofToInt(tokens[4]); app->addData(pos_x, pos_y, x, y, z); index = index + 1; } else{ break; } } } }
float stockUtility::filterStockList_MarketCap(std::string string){ float marketcapvalue; if(string.compare("N/A")){ marketcapvalue = ofToFloat("0"); } if (string.find("B")) { ofStringReplace(string, "B", "0"); //string.replace('B', '0'); marketcapvalue = ofToFloat(string); return marketcapvalue*1000000000; } if (string.find("M")){ ofStringReplace(string, "M", "0"); marketcapvalue = ofToFloat(string); return marketcapvalue*1000000; } return ofToFloat(string); }
//-------------------------------------------------------------- void testApp::update(){ char ch; if (serial.available()) { while((ch = serial.readByte())>0) { if (ch == ' ') { rotationValue = ofToFloat(recvData); cout << "Received: " << rotationValue << endl; recvData.clear(); //break; } else { recvData += ch; } } } }
//-------------------------------------------------------------- void testApp::update(){ char udpMessage[100000]; udpConnection.Receive(udpMessage,100000); string message=udpMessage; if(message.length()>0) std::cout<<"Message Received"<<message<<"\n\n"; if(message!="") { vector<string> components= ofSplitString(message,","); if(components[0]=="Translation") { ; /*receivedPosition.x=ofToFloat(components[2]); receivedPosition.y=ofToFloat(components[4]); cout<<receivedPosition.x<<" "<<receivedPosition.y;*/ } else if(components[0]=="Scaling Up"||components[0]=="Scaling Down") scaling_factor=ofToFloat(components[1]); else if(components[0]=="Rotate") { if(components[1]=="Z") receivedRotation.y+=ofToFloat(components[2])/100; if(components[1]=="Y") receivedRotation.x+=ofToFloat(components[2])/150; } } }
void CloudsVisualSystem3DModelLoader::loadCameraLineModel( ofVbo& vbo, string loc ){ ofBuffer buffer = ofBufferFromFile( loc ); vbo.clear(); vector<ofVec3f> points; if(buffer.size()) { while (buffer.isLastLine() == false) { string line = buffer.getNextLine(); vector<string> vals = ofSplitString( line, ","); for (int i=0; i<vals.size(); i+=3) { points.push_back( ofVec3f( ofToFloat(vals[i]), ofToFloat(vals[i+1]), ofToFloat(vals[i+2]) ) ); } } } vbo.setVertexData( &points[0], points.size(), GL_STATIC_DRAW ); cameraLinesNumVertices = points.size(); points.clear(); buffer.clear(); }
OFX_AE_NAMESPACE_BEGIN MovieCap::MovieCap(AVLayer *layer) :AVCap(layer) ,frame_rate_(ofGetTargetFrameRate()) ,comp_(NULL) ,use_audio_(true) { const string &lazy = layer_->getParam("lazy"); if(lazy == "") { lazy_seconds_ = 1; } else { lazy_seconds_ = ofToFloat(lazy); } }