//======================================================================== int main( ){ ofGLFWWindowSettings mainSettings; mainSettings.resizable = false; mainSettings.setGLVersion(4, 1); mainSettings.decorated = false; ofGLFWWindowSettings guiSettings; guiSettings.resizable = true; guiSettings.setGLVersion(4, 1); // Get screen widths and heights from Quartz Services // See https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/index.html CGDisplayCount displayCount; CGDirectDisplayID displays[32]; // Grab the active displays CGGetActiveDisplayList(32, displays, &displayCount); int numDisplays= displayCount; // print display info. cout<<numDisplays<<" display(s) detected."<<endl; for (int i = 0; i < displayCount; i++){ cout << displays[i] << "\t(" << CGDisplayPixelsWide(displays[i]) << "x" << CGDisplayPixelsHigh(displays[i]) << ")"<< endl; } CGRect mainDisplayBounds= CGDisplayBounds ( displays[0] ); if(numDisplays == 1 ){ float divisions = 4.0; // one display: palce gui and mainWindow in a default arrangement mainSettings.width = round(mainDisplayBounds.size.width * (divisions-1) / divisions); mainSettings.height = round((mainSettings.width * (9.0 / 16.0)) / 2.0); mainSettings.setPosition(ofVec2f(round(mainDisplayBounds.size.width / divisions) ,mainDisplayBounds.origin.y)); mainSettings.decorated = true; guiSettings.width = round(mainDisplayBounds.size.width - 100); guiSettings.height = mainDisplayBounds.size.height - 100; guiSettings.setPosition(ofVec2f(mainDisplayBounds.origin.x, mainDisplayBounds.origin.y + 80)); cout << "configured default one display setup" << endl; } else if (numDisplays > 1){ // two displays: palce resizeable gui on first and fill second with undecorated mainWindow - will also work with dual head configuraions for projectors guiSettings.width = mainDisplayBounds.size.width; guiSettings.height = mainDisplayBounds.size.height - 100; guiSettings.setPosition(ofVec2f(mainDisplayBounds.origin.x, mainDisplayBounds.origin.y)); CGRect secondDisplayBounds= CGDisplayBounds ( displays[1] ); mainSettings.width = secondDisplayBounds.size.width; mainSettings.height = secondDisplayBounds.size.height; mainSettings.setPosition(ofVec2f(secondDisplayBounds.origin.x,secondDisplayBounds.origin.y)); // CGError e = CGDisplaySetStereoOperation(displays[1], true, true, kCGConfigureForAppOnly); // if(e == kCGErrorRangeCheck) cout << "no hardware stereo" << endl; // if(e == kCGErrorSuccess) cout << "hardware stereo" << endl; if (numDisplays > 2 ) { // three or more displays: palce resizeable gui on first and fill second and third with undecorated mainWindow, if they are same size. CGRect thirdDisplayBounds= CGDisplayBounds ( displays[2] ); if(secondDisplayBounds.size.width == thirdDisplayBounds.size.width && secondDisplayBounds.size.height == thirdDisplayBounds.size.height){ mainSettings.width = secondDisplayBounds.size.width * 2; mainSettings.setPosition(ofVec2f(1,1)); cout << "configured default three display setup" << endl; } } else { cout << "configured default two display setup" << endl; } } shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(mainSettings); guiSettings.shareContextWith = mainWindow; shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(guiSettings); //guiWindow->setVerticalSync(false); shared_ptr<ofApp> mainApp(new ofApp); mainApp->setupGui(guiWindow, mainWindow); ofAddListener(guiWindow->events().draw,mainApp.get(),&ofApp::drawGui); // gui events to main app gui listener functions #define guiEventMacro(NAME) ofAddListener(guiWindow->events() . NAME , mainApp.get(), &ofApp::NAME ## Gui); guiEventMacro(keyPressed); guiEventMacro(keyReleased); guiEventMacro(mouseMoved); guiEventMacro(mouseDragged); guiEventMacro(mousePressed); guiEventMacro(mouseReleased); guiEventMacro(mouseEntered); guiEventMacro(mouseExited); guiEventMacro(windowResized); ofRunApp(mainWindow, mainApp); ofRunMainLoop(); }
dt_ui_home::dt_ui_home() : drag_start_posw( ofVec2f(0,0) ), drag_target_circle( NULL ) { }
// 力をリセット void Particle::resetForce(){ force= ofVec2f(-0.2, 0); }
void LaserManager :: renderPreview() { // do dots first ofPushStyle(); ofMesh mesh; vector <ofVec3f> vertices; vector <ofVec2f> texCoords; ofImage* image = &pointPreviewImage; vertices.push_back(ofVec3f( -0.5, -0.5 )); vertices.push_back(ofVec3f( -0.5, 0.5 )); vertices.push_back(ofVec3f( 0.5, -0.5 )); vertices.push_back(ofVec3f( 0.5, 0.5 )); texCoords.clear(); texCoords.push_back(ofVec2f(0,0)); texCoords.push_back(ofVec2f(0, image->height)); texCoords.push_back(ofVec2f(image->width, 0)); texCoords.push_back(ofVec2f(image->width, image->height)); mesh.setMode(OF_PRIMITIVE_TRIANGLES); vector<LaserShape*> newshapes = (shapesHistory.size()>0) ? shapesHistory.back() : shapes; for(int i = 0; i<newshapes.size(); i++) { LaserShape* shape = newshapes[i]; // Is it a dot? LaserDot * dot = dynamic_cast<LaserDot*>(shape); if(dot) { int vertexIndex = mesh.getNumVertices(); for(int i = 0; i<vertices.size(); i++) { ofVec3f v = vertices[i]; v*=dot->intensity*10; v+=dot->getStartPos(); mesh.addVertex(v); mesh.addColor(dot->colour); mesh.addTexCoord(texCoords[i]); } mesh.addTriangle(vertexIndex, vertexIndex+1, vertexIndex+2); mesh.addTriangle(vertexIndex+1, vertexIndex+2, vertexIndex+3); // if you want a brighter spot in the middle... /* vertexIndex = mesh.getNumVertices(); ofColor brighterColour = dot->colour; brighterColour.r+=50; brighterColour.g+=50; brighterColour.b+=50; for(int i = 0; i<vertices.size(); i++) { ofVec3f v = vertices[i]; v*=dot->intensity*5; v+=dot->startPos; mesh.addVertex(v); mesh.addColor(brighterColour); mesh.addTexCoord(texCoords[i]); } mesh.addTriangle(vertexIndex, vertexIndex+1, vertexIndex+2); mesh.addTriangle(vertexIndex+1, vertexIndex+2, vertexIndex+3); */ } } image->bind(); mesh.draw(); image->unbind(); mesh.clear(); mesh.setMode(OF_PRIMITIVE_LINE_STRIP); for(int i = 0; i<newshapes.size(); i++) { LaserShape* shape = newshapes[i]; // Is it a dot? LaserCircle * circle = dynamic_cast<LaserCircle*>(shape); if(circle) { ofVec3f v(0,-circle->radius); mesh.addColor(ofColor::black); mesh.addVertex(v + circle->pos); for(int i = 0; i<=360; i+=20) { v.set(0, -circle->radius); v.rotate(i, ofVec3f(0,0,1)); mesh.addColor(circle->colour); mesh.addVertex(v+circle->pos); } v.set(0, -circle->radius); mesh.addColor(ofColor::black); mesh.addVertex(v+circle->pos); } // Is it a line? LaserLine * line = dynamic_cast<LaserLine*>(shape); if(line) { mesh.addColor(ofColor::black); mesh.addVertex(line->getStartPos()); mesh.addColor(line->colour); mesh.addVertex(line->getStartPos()); mesh.addColor(line->colour); mesh.addVertex(line->getEndPos()); mesh.addColor(ofColor::black); mesh.addVertex(line->getEndPos()); } LaserSpiral* spiralptr = dynamic_cast<LaserSpiral*>(shape); if(spiralptr) { mesh.addColor(ofColor::black); mesh.addVertex(spiralptr->getStartPos()); LaserSpiral& spiral = *spiralptr; float revolutions = ((spiral.radius2 - spiral.radius1)/spiralSpacing); float maxAngle = 360 * revolutions; float currentAngle = 0; ofVec2f pos; float speed = 0; float maxSpeed = 20; float rotateSpeed = 1; ofPolyline path; while (currentAngle<=maxAngle + 360) { pos.set(ofMap(currentAngle, 0, maxAngle, spiral.radius1, spiral.radius2, true), 0); pos.rotate(currentAngle); pos+=spiral.pos; //rotateSpeed = ofMap(currentAngle, 1, 45,0,maxSpeed, true); // should be a setting! currentAngle+=rotateSpeed; path.addVertex(pos); } float totaldistance = path.getPerimeter(); vector<float> unitDistances = getPointsAlongDistance(totaldistance, accelerationLine, speedLine); for(int i = 0; i<unitDistances.size(); i++) { pos = path.getPointAtLength(min(unitDistances[i]*totaldistance, totaldistance-0.01f)); mesh.addVertex(pos); mesh.addColor(spiral.colour); } mesh.addColor(ofColor::black); mesh.addVertex(spiralptr->getEndPos()); } LaserPolyline* laserpoly = dynamic_cast<LaserPolyline*>(shape); if(laserpoly) { if(laserpoly->previewMesh.getVertices().size() ==0 ) { drawLaserPolyline(*laserpoly, true); } ofSetColor(255); ofNoFill(); ofSetLineWidth(2); laserpoly->previewMesh.draw(); //ofSetLineWidth(3); //laserpoly->previewMesh.draw(); } } ofSetLineWidth(1); mesh.draw(); vector<ofFloatColor>& colours = mesh.getColors(); for(int i = 0; i<colours.size(); i++) { colours[i].r*=0.2; colours[i].g*=0.2; colours[i].b*=0.2; } ofSetLineWidth(5); mesh.draw(); ofSetLineWidth(9); mesh.draw(); /* // Is it a circle? LaserCircle * circle = dynamic_cast<LaserCircle*>(shape); if(circle) { path.clear(); path.setFilled(true); path.setColor(circle->colour); //path.setStrokeWidth(2); path.circle(circle->pos, circle->radius); path.draw(); } // Is it a line? LaserLine * line = dynamic_cast<LaserLine*>(shape); if(line) { drawLaserLine(*line); } // Is it a spiral? LaserSpiral * spiral = dynamic_cast<LaserSpiral*>(shape); if(spiral) { drawLaserSpiral(*spiral); } */ ofPopStyle(); }
GaussianBlurFilter::GaussianBlurFilter(float width, float height, float blurSize, float bloom) :Abstract3x3PingPongFilter(width, height, ofVec2f(1, 1)) { _name = "Gaussian Blur"; _blurSize = blurSize; _bloom = bloom; _addParameter(new ParameterF("blurSize", blurSize)); _addParameter(new ParameterF("bloom", bloom)); _setupShader(); }
void nodeManager::updateNodePosition(string t_index, float x, float y) { mNodes[t_index]->setRawPos_rel(ofVec2f(x,y)); if(mNodes[t_index]->getChanged() == CLAMOUR_NONE)mNodes[t_index]->setChanged(CLAMOUR_POSITION); //don't let position override on/off messages }
void ImageProcessor::cpiIsUnityScale(bool &b){ if (b) { (static_pointer_cast<PixelatePass>(post[9]))->setResolution(ofVec2f((int)piRes->x, (int)(piRes->y*heigth/width))); } }
ofVec2f ofxBox2dBaseShape::getVelocity() { return ofVec2f(body->GetLinearVelocity().x, body->GetLinearVelocity().y); }
void Particle::updateAttractionForce(float inputX,float inputY){ mouseAttraction= ofVec2f((inputX-pos.x),(inputY-pos.y))/(60+ofRandom(50)-25) ; }
void ofxMtPhoto::tuioUpdated(ofxTuioCursor &tuioCursor){ ofVec2f loc = ofVec2f(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); if ( isOver(loc) ){ // ACTUALIZA la LOCacion de los dedos grabados for ( int i = 0; i < cursorsOnBorder.size(); i++) if (cursorsOnBorder[i].idN == tuioCursor.getSessionId()) cursorsOnBorder[i].loc = loc; // Si hay un sólo dedo -> mueve la imagen if (cursorsOnBorder.size() == 1 ) { // ofVec2f newForce = cursorsOnBorder[0].loc - oldLoc[0]; // newForce.normalize(); // Lo normalizo para q la velocidad no se dispare // acc += newForce; // oldLoc[0] = cursorsOnBorder[0].loc; pos = loc; } // Si hay dos Dedos -> gira, escala y mueve else if (cursorsOnBorder.size() == 2) { vel *= 0.5; // Si lo agarra con dos dedos frena la velocidad que tenía de forma dramática int sta = -1; // algo como un NULL parameter int din = -1; // algo como un NULL parameter // encuentra cual es el estático y el dinámico for ( int i = 0; i < cursorsOnBorder.size(); i++) if (cursorsOnBorder[i].loc == oldLoc[i]) sta = i; else din = i; // una vez encontrados, calcula las transformaciones if ((sta != -1) && (din != -1) && (din != sta)){ // Recupera la Direccion, distancia y rotacion VIEJA ofVec2f Di = oldLoc[sta] - oldLoc[din]; float di = Di.length(); float ri = -1*atan2(Di.x,Di.y)+(PI/2); // Obtiene la Direccion, distancia y rotacion NUEVA ofVec2f Dii = oldLoc[sta] - cursorsOnBorder[din].loc; float dii = Dii.length(); float rii = -1*atan2(Dii.x,Dii.y)+(PI/2); // Calcula el porcentaje ( de 0 a 1) de re-escalamiento float scaleF = dii / di; // (<#float value#>, , <#float inputMax#>, <#float outputMin#>, <#float outputMax#>, <#bool clamp#>) ; // Calcula los grados de rotación float rotateF = rii - ri; // Calcula el desplazamiento a partir de coordenadas polares. ofVec2f oldStaCursorToCenter = pos - oldLoc[sta] ; float oldAngleToCenter = -1*atan2(oldStaCursorToCenter.x,oldStaCursorToCenter.y)+(PI/2); float oldRadioToCenter = oldStaCursorToCenter.length(); float newRadioToCenter = oldRadioToCenter * scaleF; float newAngleToCenter = oldAngleToCenter + rotateF; ofVec2f newStaCursorToCenter = ofVec2f(newRadioToCenter*cos(newAngleToCenter),newRadioToCenter*sin(newAngleToCenter)); // Actualiza los valores resize(scaleF); rotate(rotateF); pos = oldLoc[sta] + newStaCursorToCenter; } oldLoc[0] = cursorsOnBorder[0].loc; oldLoc[1] = cursorsOnBorder[1].loc; } } }
void ofxBlur::end() { base.end(); ofPushStyle(); ofSetColor(255); ofVec2f xDirection = ofVec2f(scale, 0).getRotatedRad(rotation); ofVec2f yDirection = ofVec2f(0, scale).getRotatedRad(rotation); for(int i = 0; i < ping.size(); i++) { ofFbo& curPing = ping[i]; ofFbo& curPong = pong[i]; // resample previous result into ping curPing.begin(); int w = curPing.getWidth(); int h = curPing.getHeight(); if(i > 0) { ping[i - 1].draw(0, 0, w, h); } else { base.draw(0, 0, w, h); } curPing.end(); // horizontal blur ping into pong curPong.begin(); blurShader.begin(); blurShader.setUniformTexture("source", curPing.getTexture(), 0); blurShader.setUniform2f("direction", xDirection.x, xDirection.y); curPing.draw(0, 0); blurShader.end(); curPong.end(); // vertical blur pong into ping curPing.begin(); blurShader.begin(); blurShader.setUniformTexture("source", curPong.getTexture(), 0); blurShader.setUniform2f("direction", yDirection.x, yDirection.y); curPong.draw(0, 0); blurShader.end(); curPing.end(); } // render ping back into base if(ping.size() > 1) { int w = base.getWidth(); int h = base.getHeight(); ofPlanePrimitive plane; plane.set(w, h); plane.mapTexCoordsFromTexture(ping[0].getTexture()); base.begin(); combineShader.begin(); for(int i = 0; i < ping.size(); i++) { string name = "s" + ofToString(i); combineShader.setUniformTexture(name.c_str(), ping[i].getTexture(), 1 + i); } combineShader.setUniform1f("brightness", brightness); ofPushMatrix(); ofTranslate(w / 2, h / 2); plane.draw(); ofPopMatrix(); combineShader.end(); base.end(); } else { base.begin(); ping[0].draw(0, 0); base.end(); } ofPopStyle(); }
Particle::Particle() { Particle( ofVec2f( ofGetWidth()/2, ofGetHeight()/2 ) ); }
void testApp::drawBola4(ofVec2f pos, float radius, float rot) { ofVec2f vx = ofVec2f(1,0); ofVec2f centroScreen = ofVec2f(ofGetWidth()/2, ofGetHeight()/2); ofVec2f posCentro = pos-centroScreen; float angulo = vx.angle(posCentro); while(angulo<0) {angulo+=360.0;} ofPushMatrix(); ofPushStyle(); ofFill(); ofTranslate(pos.x,pos.y,0); if(angulo>=0 && angulo<90) { float rr = 2*radius; ofSetColor(ofColor::royalBlue, 200); bola.draw(-rr,-rr,2*rr,2*rr); ofTranslate(-posCentro.x,-posCentro.y,0); ofSetColor(ofColor::royalBlue, 80); ofSetLineWidth(0.2); ofLine(0,0, posCentro.length()*cos(angulo*DEG_TO_RAD), posCentro.length()*sin(angulo*DEG_TO_RAD)); ofPolyline arco; arco.arc(ofPoint(0,0), posCentro.length(), posCentro.length(),0, 90); arco.draw(); } else if(angulo>=90 && angulo<180) { float rr = 6*radius; ofSetColor(ofColor::green, 200); bola.draw(-rr,-rr,2*rr,2*rr); } else if(angulo>=180 && angulo<270) { // ofSetColor(ofColor::deepPink, 200); // bola.draw(-rr,-rr,2*rr,2*rr); ofSetColor(150 + ofRandom(155)); ofCircle(0,0,radius/8); } else if(angulo>=270 && angulo<360) { ofEnableBlendMode(OF_BLENDMODE_ADD); if(fRed) { float rr = 2*radius; ofSetColor(ofColor::red, 150); // ofSetColor(ofColor::darkBlue , 150); bola.draw(-rr,-rr,2*rr,2*rr); ofPushMatrix(); ofTranslate(-pos.x, -pos.y, 0); ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0); float rot = 2*(315-angulo); ofRotate(rot); ofTranslate(posCentro.x, posCentro.y,0); ofSetColor(ofColor::darkRed , 150); rr = 2*radius; bola.draw(-rr,-rr,2*rr,2*rr); ofPopMatrix(); } else { float rr = 0.7*radius; ofRotate(rot); ofSetColor(ofColor::red, 150); // ofSetColor(ofColor::darkBlue , 150); ofPushMatrix(); ofTranslate(radius,0,0); bola.draw(-rr,-rr,2*rr,2*rr); ofPopMatrix(); ofSetColor(ofColor::blue, 150); ofPushMatrix(); ofRotateZ(120); ofTranslate(radius,0,0); bola.draw(-rr,-rr,2*rr,2*rr); ofPopMatrix(); ofSetColor(ofColor::green, 150); ofPushMatrix(); ofRotateZ(240); ofTranslate(radius,0,0); bola.draw(-rr,-rr,2*rr,2*rr); ofPopMatrix(); } ofDisableBlendMode(); } ofPopStyle(); ofPopMatrix(); }
//------------------ void Card::gravity() { applyForce( ofVec2f( 0.0, 0.1 )); }
void nodeManager::distributeNodes(vector<string> clients, string pattern, map<string, float> params, bool dimp, bool posp) { float w_prop = (float)screenData::width/screenData::height; if(pattern == "RANDOM_CIRCLE") { ofVec2f c(params["X"], params["Y"]); if(posp)c *= ofVec2f(w_prop,1.0); float r = params["RADIUS"]; for(int i = 0; i < clients.size(); i++) { if(!mNodes[clients[i]]->getIsDistributable())continue; ofVec2f p(0,ofRandom(0,r)); p = p.getRotated(ofRandom(-180,180)); if(dimp)p *= ofVec2f(w_prop,1.0); mNodes[clients[i]]->setRawPos_abs(p+c); mNodes[clients[i]]->setAnimOverride(20); } } else if(pattern == "CIRCUM") { ofVec2f c(params["X"], params["Y"]); if(posp)c *= ofVec2f(w_prop,1.0); float r = params["RADIUS"]; float interval = (float)360.0/clients.size(); for(int i = 0; i < clients.size(); i++) { if(!mNodes[clients[i]]->getIsDistributable())continue; ofVec2f p(0,r); p = p.getRotated(-180 + i * interval); if(dimp)p *= ofVec2f(w_prop,1.0); mNodes[clients[i]]->setRawPos_abs(p+c); mNodes[clients[i]]->setAnimOverride(20); } } else if(pattern == "XY") { ofVec2f c(params["X"], params["Y"]); if(posp)c *= ofVec2f(w_prop,1.0); for(int i = 0; i < clients.size(); i++) { if(!mNodes[clients[i]]->getIsDistributable())continue; mNodes[clients[i]]->setRawPos_abs(c); mNodes[clients[i]]->setAnimOverride(20); } } else if(pattern == "GRID") { ofVec2f c(params["X"], params["Y"]); int rl = params["ROW_LENGTH"]; int numRows = clients.size()/rl; if(posp)c *= ofVec2f(w_prop,1.0); ofVec2f w(params["WIDTH"]/rl, params["HEIGHT"]/(float)numRows); if(dimp)c *= ofVec2f(w_prop, 1.0); sort(clients.begin(), clients.end(), sortByIndex); for(int i = 0; i < clients.size(); i++) { if(!mNodes[clients[i]]->getIsDistributable())continue; ofVec2f p(c.x + w.x * (float)(i%rl), c.y + w.y * floor(i/rl)); mNodes[clients[i]]->setRawPos_abs(p); mNodes[clients[i]]->setAnimOverride(20); } } }
ofVec2f Particle::getLoc() { ofVec2f outLoc = ofVec2f(loc.begin()->x, loc.begin()->y); return outLoc; }
void nodeManager::switchOnNode(string t_index, float x, float y) { mNodes[t_index]->setRawPos_rel(ofVec2f(x, y)); switchOnNode(t_index); }
//-------------------------------------------------------------- void testApp::setup(){ particleSystem = ofxParticleSystem(100); particleSystem.addForce(ofVec2f(0, -1)); }
ImageProcessor::ImageProcessor(string name_):VisualLayer(name_){ fbo.allocate(width, heigth); bloom.setName("bloom"); contrast.setName("contrast"); kaleidoscope.setName("kaleidoscope"); noise.setName("noise"); pixelate.setName("pixelate"); pixelate.add(isPixelate.set("active", false)); pixelate.add(piIsUnityScale.set("Unity scale", true)); pixelate.add(piRes.set("Res", ofVec2f(100, 100), ofVec2f(3,3), ofVec2f(100, 100))); edge.setName("edge"); god.setName("god"); bloom.add(isBloom.set("active", false)); contrast.add(isContrast.set("active", false)); contrast.add(coContrast.set("contrast", 1.0, 0.0, 2.0)); contrast.add(coBrightness.set("brightness", 1.0, 0.0, 20.0)); contrast.add(coMultiple.set("multiple", 1.0, 0.0, 5.0)); kaleidoscope.add(isKaleidoscope.set("active", false)); kaleidoscope.add(kaSegments.set("Segments",2.0,0.0,15.0)); noise.add(isNoise.set("active", false)); noise.add(noFreq.set("Frequency", 4.0, 0.0, 10)); noise.add(noAmp.set("Amplitude", .1, 0.0, .5)); noise.add(noSpeed.set("Speed", .1, 0.0, 2.5)); edge.add(isEdge.set("active", false)); edge.add(edHue.set("hue",0.5,0,1)); edge.add(edSat.set("saturation",0.0,-100,0)); bleach.setName("bleach"); bleach.add(isBleach.set("active",false)); bleach.add(blOpacity.set("opacity",1.0,-5.0,5.0)); rgbshift.setName("RGBShift"); rgbshift.add(isRGBShift.set("active", false)); rgbshift.add(rgAngle.set("angle",0.0,0.0,TWO_PI)); rgbshift.add(rgAmount.set("amount",0.005,0.0,0.1)); god.add(isGod.set("active", false)); zoomBlur.setName("zoomBlur"); zoomBlur.add(isZoomBlur.set("active",false)); zoomBlur.add(zbCenterX.set("center x", 0.5, 0, 1)); zoomBlur.add(zbCenterY.set("center y", 0.5, 0, 1)); zoomBlur.add(zbExposure.set("exposure", 0.48, 0, 5)); zoomBlur.add(zbDensity.set("density", 0.25, 0, 1)); zoomBlur.add(zbWeight.set("weight", 0.25, 0, 1)); zoomBlur.add(zbClamp.set("clamp", 1, 0, 1)); // Setup post-processing chain post.init(width,heigth); post.createPass<BloomPass>()->setEnabled(isBloom); post.createPass<ContrastPass>()->setEnabled(isContrast); post.createPass<KaleidoscopePass>()->setEnabled(isKaleidoscope); post.createPass<NoiseWarpPass>()->setEnabled(isNoise); post.createPass<EdgePass>()->setEnabled(isEdge); post.createPass<BleachBypassPass>()->setEnabled(isBleach); post.createPass<RGBShiftPass>()->setEnabled(isRGBShift); post.createPass<GodRaysPass>()->setEnabled(isGod); post.createPass<ZoomBlurPass>()->setEnabled(isZoomBlur); post.createPass<PixelatePass>()->setEnabled(isPixelate); isBloom.addListener(this, &ImageProcessor::cIsBloom); isContrast.addListener(this, &ImageProcessor::cIsContrast); coContrast.addListener(this, &ImageProcessor::ccoContrast); coBrightness.addListener(this, &ImageProcessor::ccoBrightness); coMultiple.addListener(this, &ImageProcessor::ccoMultiple); isKaleidoscope.addListener(this, &ImageProcessor::cisKaleidoscope); kaSegments.addListener(this, &ImageProcessor::ckaSegments); noFreq.addListener(this, &ImageProcessor::cnoFreq); noAmp.addListener(this, &ImageProcessor::cnoAmp); noSpeed.addListener(this, &ImageProcessor::cnoSpeed); isGod.addListener(this, &ImageProcessor::cisGod); isNoise.addListener(this, &ImageProcessor::cisNoise); isPixelate.addListener(this, &ImageProcessor::cisPixelate); piRes.addListener(this, &ImageProcessor::cpiRes); isEdge.addListener(this, &ImageProcessor::cisEdge); edHue.addListener(this, &ImageProcessor::cedHue); edSat.addListener(this, &ImageProcessor::cedSat); isRGBShift.addListener(this, &ImageProcessor::cisRGBShift); rgAmount.addListener(this, &ImageProcessor::crgAmount); rgAngle.addListener(this, &ImageProcessor::crgAngle); isZoomBlur.addListener(this, &ImageProcessor::cisZoomBlur); zbCenterX.addListener(this, &ImageProcessor::czbCenterX); zbCenterY.addListener(this, &ImageProcessor::czbCenterY); zbExposure.addListener(this, &ImageProcessor::czbExposure); zbDecay.addListener(this, &ImageProcessor::czbDecay); zbDensity.addListener(this, &ImageProcessor::czbDensity); zbWeight.addListener(this, &ImageProcessor::czbWeight); zbClamp.addListener(this, &ImageProcessor::czbClamp); gui.add(bloom); gui.add(contrast); gui.add(kaleidoscope); gui.add(noise); gui.add(edge); gui.add(bleach); gui.add(rgbshift); // gui.add(god); gui.add(zoomBlur); gui.add(pixelate); }
void xmlLoader::loadZone(zone &z, ofxXmlSettings &XML) { z.setName(XML.getValue("NAME", "default")); z.setPos_rel(ofVec2f(XML.getValue("X", 0.5), XML.getValue("Y",0.5))); ofPath p; loadEvents(z, XML); if(XML.tagExists("DRAW_TYPE"))z.setDrawType(XML.getValue("DRAW_TYPE", "debugZone")); if(XML.pushTag("DRAW_PARAMS")) { vector<parameter> p; xmlLoader::loadParams( p ,XML); for(int i = 0; i < p.size(); i++)z.setDrawParameter(p[i]); XML.popTag(); } pathFactory::createPath(p, z.getDrawData().getShapeType(), XML.getValue("X_DIM",1.0),XML.getValue("Y_DIM", 1.0), z.getDrawData().getParameter("size").abs_val); z.setEdgeTemplate(p); if(XML.tagExists("ATTACK_SECS"))z.setAttSecs(XML.getValue("ATTACK_SECS", 0.01)); // could be in a param if necessary later if(XML.tagExists("DECAY_SECS"))z.setDecSecs(XML.getValue("DECAY_SECS", 0.2)); // if(XML.tagExists("ENV_TYPE"))z.setEnvType(XML.getValue("ENV_TYPE", "AR")); if(XML.tagExists("SOUND_TYPE"))z.setSoundType(XML.getValue("SOUND_TYPE","brownExploder")); if(XML.pushTag("SOUND_PARAMS")) { if(XML.tagExists("FILE"))z.setSoundFile(XML.getValue("FILE", "default")); vector<parameter> p; xmlLoader::loadParams( p ,XML); for(int i = 0; i < p.size(); i++)z.setSoundParameter(p[i]); XML.popTag(); } if(XML.pushTag("ON_RULE")) { zoneRule r; xmlLoader::loadRule(r, XML); z.setOnRule(r); XML.popTag(); } if(XML.pushTag("OFF_RULE")) { zoneRule r; xmlLoader::loadRule(r, XML); z.setOffRule(r); XML.popTag(); } loadReactions(z, XML); loadSounds(z, XML); }
//-------------------------------------------------------------- void ofApp::setup() { ofBackground(50); ofSetFrameRate(30); //ofDisableArbTex(); receiver.setup(7771); ofLoadImage(meshTexture, "texture.jpg"); //-------------------------------------------------------------- ofMesh customMesh; customMesh.setMode(OF_PRIMITIVE_TRIANGLES); customMesh.addVertex(ofVec3f(-100, -100)); customMesh.addVertex(ofVec3f(-100, 100)); customMesh.addVertex(ofVec3f(100, -100)); customMesh.addVertex(ofVec3f(100, 100)); customMesh.addTexCoord(ofVec2f(0, 0)); customMesh.addTexCoord(ofVec2f(0, 1)); customMesh.addTexCoord(ofVec2f(1, 0)); customMesh.addTexCoord(ofVec2f(1, 1)); customMesh.addIndex(0); customMesh.addIndex(3); customMesh.addIndex(1); customMesh.addIndex(0); customMesh.addIndex(2); customMesh.addIndex(3); //-------------------------------------------------------------- ofSpherePrimitive sphere(100, 20, OF_PRIMITIVE_TRIANGLES); //-------------------------------------------------------------- model.loadModel("head.dae"); //-------------------------------------------------------------- meshIndex = 0; meshes.push_back(customMesh); meshes.push_back(sphere.getMesh()); meshes.push_back(model.getMesh(0)); //-------------------------------------------------------------- //fftLive.setup(); rawIndex = 0; eegValues.resize(512); // samples per second fftLive.setup(); fftLive.setBufferSize(eegValues.size()); // must be set manually for a custom signal //-------------------------------------------------------------- string guiPath = "audio.xml"; gui.setup("audio", guiPath, 20, 20); gui.add(meshIndex.setup("meshIndex", 0, 0, meshes.size()-1)); gui.add(bUseTexture.setup("bUseTexture", false)); gui.add(bUseAudioInput.setup("bUseAudioInput", false)); gui.add(audioPeakDecay.setup("audioPeakDecay", 0.915, 0.9, 1.0)); gui.add(audioMaxDecay.setup("audioMaxDecay", 0.995, 0.9, 1.0)); gui.add(audioMirror.setup("audioMirror", true)); gui.loadFromFile(guiPath); }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetLogLevel(OF_LOG_VERBOSE); glEnable(GL_DEPTH_TEST); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> clouds; mesh.load(ofToDataPath("out.ply")); cloud = ofxPCL::toPCL<ofxPCL::PointXYZCloud>(mesh); textures.resize(2); textures.at(0).loadImage(ofToDataPath("tex0.jpg")); textures.at(1).loadImage(ofToDataPath("tex1.jpg")); pcl::SacModel model_type = pcl::SACMODEL_PLANE; float distance_threshold = 30; int min_points_limit = 10; int max_segment_count = 30; pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients()); pcl::PointIndices::Ptr inliers(new pcl::PointIndices()); pcl::SACSegmentation<pcl::PointXYZ> seg; seg.setOptimizeCoefficients(false); seg.setModelType(model_type); seg.setMethodType(pcl::SAC_RANSAC); seg.setDistanceThreshold(distance_threshold); seg.setMaxIterations(500); pcl::PointCloud<pcl::PointXYZ>::Ptr temp(new pcl::PointCloud<pcl::PointXYZ>(*cloud)); const size_t original_szie = temp->points.size(); pcl::ExtractIndices<pcl::PointXYZ> extract; int segment_count = 0; while (temp->size() > original_szie * 0.3) { if (segment_count > max_segment_count) break; segment_count++; seg.setInputCloud(temp); seg.segment(*inliers, *coefficients); if (inliers->indices.size() < min_points_limit) break; pcl::PointCloud<pcl::PointXYZ>::Ptr filterd_point_cloud(new pcl::PointCloud<pcl::PointXYZ>); extract.setInputCloud(temp); extract.setIndices(inliers); extract.setNegative(false); extract.filter(*filterd_point_cloud); if (filterd_point_cloud->points.size() > 0) { clouds.push_back(filterd_point_cloud); } extract.setNegative(true); extract.filter(*temp); ofMesh m; pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals(new pcl::PointCloud<pcl::PointNormal>); ofxPCL::normalEstimation(filterd_point_cloud, cloud_with_normals); m = ofxPCL::triangulate(cloud_with_normals, 100); m.clearColors(); jointMesh.addVertices(m.getVertices()); jointMesh.addColors(m.getColors()); ofVec3f center = m.getCentroid(); ofVec3f planeNormal(coefficients->values[0], coefficients->values[1], coefficients->values[2]); ofVec3f tangent, bitangent; ofVec3f arb(0, 1, 0); tangent = arb.cross(planeNormal).normalize(); bitangent = planeNormal.cross(tangent).normalize(); for(int j = 0; j < m.getNumVertices(); j++) { float x = m.getVertex(j).dot(tangent) * 0.001; x = x - (long)x; if(x < 0) x += 1; float y = m.getVertex(j).dot(bitangent) * 0.001; y = y - (long)y; if(y < 0) y += 1; m.addTexCoord(ofVec2f(x, y)); } meshes.push_back(m); } ofxPCL::convert(temp, meshResidual); ofLogVerbose() << clouds.size() << " meshes extracted"; center = jointMesh.getCentroid(); }
void LaserManager:: setup (int width, int height) { appWidth = width; // ofGetWidth(); appHeight = height;//ofGetHeight(); shouldBeConnected = false; showSyncTest = false; //connectButton = false; minPoints = 1000; restartCount = 0; white.set(1,1,1); black.set(0,0,0); //endCount = 1; //blankCount = 0; pmin.set(0,0); pmax.set(appWidth, appHeight); testPattern = 0; numTestPatterns = 5; showMovePoints = false; showLaserPath = true; intensity = 1; float x1 = APP_WIDTH * 0.2; float x2 = APP_WIDTH * 0.8; float y1 = APP_HEIGHT * 0.2; float y2 = APP_HEIGHT * 0.8; //RectangleUI* maskRectangle = &(RectangleUI)maskRectangleParam; //maskRectangle.set(0, 0, APP_WIDTH, APP_HEIGHT/4*3); //maskRectangle.initUI(ofRectangle(0,0,APP_WIDTH, APP_HEIGHT)); //maskRectangleBrightness = 1; warp.label = "laserWarp"; warp.setDstPoint(0, ofVec2f(x1,y1)); warp.setDstPoint(1, ofVec2f(x2,y1)); warp.setDstPoint(2, ofVec2f(x2,y2)); warp.setDstPoint(3, ofVec2f(x1,y2)); warp.setSrcPoint(0, ofVec2f(x1,y1)); warp.setSrcPoint(1, ofVec2f(x2,y1)); warp.setSrcPoint(2, ofVec2f(x2,y2)); warp.setSrcPoint(3, ofVec2f(x1,y2)); warp.useBarrelingCorrection = true; warp.loadSettings(); intensity = 1; parameters.setName("Laser Manager"); connectButton.setup("Etherdream connect"); connectButton.addListener(this, &LaserManager::connectButtonPressed); //parameters.add(&connectButton); parameters.add(etherdreamStatus.set("status", "test")); parameters.add(intensity.set("intensity", 1, 0, 1)); parameters.add(testPattern.set("test pattern", 0, 0, numTestPatterns)); parameters.add(delay.set("sync delay", 0, 0, 0.4)); parameters.add(pps.set("points per second", 80000, 30000, 100000)); parameters.add(maskMarginTop.set("mask margin top", 0, 0, appHeight)); parameters.add(maskMarginBottom.set("mask margin bottom", appHeight*0.7, 0, appHeight)); parameters.add(maskMarginLeft.set("mask margin left", 0, 0, appWidth)); parameters.add(maskMarginRight.set("mask margin right", appWidth, 0, appWidth)); parameters.add(showWarpPoints.set("show warp points", false)); //parameters.add(colourCorrection.set("colour correction", ofColor(255,255,255),ofColor(200,200,200), ofColor(255,255,255))); parameters.add(colourChangeDelay.set("colour change offset", -6, -15, 15)); parameters.add(flipX.set("flip x", true)); parameters.add(flipY.set("flip y", true)); parameters.add(showMovePoints.set("laser move points", false)); parameters.add(showSyncTest.set("show sync test", false)); parameters.add(showLaserPath.set("show laser path", true)); parameters.add(renderLaserPreview.set("render laser preview", true)); parameters.add(showPostTransformPreview.set("show post transform preview", false)); parameters.add(moveSpeed.set("move speed", 3,2,20)); parameters.add(movePointsPadding.set("move points padding", 1,0,20)); parameters.add(shapePreBlank.set("shape pre blank points", 1, 0, 20)); parameters.add(shapePostBlank.set("shape post blank points", 1, 0, 20)); parameters.add(dotMaxPoints.set("dot max points", 7, 0, 100)); parameters.add(accelerationLine.set("line acceleration", 0.5, 0.01, 4)); parameters.add(speedLine.set("line speed", 20,2, 40)); parameters.add(overlapCircle.set("circle overlap", 20,0, 100)); parameters.add(accelerationCircle.set("circle acceleration", 0.5, 0.01, 4)); parameters.add(speedCircle.set("circle speed", 20,2, 40)); parameters.add(speedEasedLine.set("eased line speed", 8, 2, 20)); parameters.add(paddingEasedLine.set("eased line padding", 1,0, 20)); parameters.add(spiralSpacing.set("spiral spacing", 10,1, 20)); // where is this getting set up? homographyParameters.setName("Laser Homography"); redParams.add(red100.set("red 100", 1,0,1)); redParams.add(red75.set("red 75", 0.75,0,1)); redParams.add(red50.set("red 50", 0.5,0,1)); redParams.add(red25.set("red 25", 0.25,0,1)); redParams.add(red0.set("red 0", 0,0,0.5)); greenParams.add(green100.set("green 100", 1,0,1)); greenParams.add(green75.set("green 75", 0.75,0,1)); greenParams.add(green50.set("green 50", 0.5,0,1)); greenParams.add(green25.set("green 25", 0.25,0,1)); greenParams.add(green0.set("green 0", 0,0,0.5)); blueParams.add(blue100.set("blue 100", 1,0,1)); blueParams.add(blue75.set("blue 75", 0.75,0,1)); blueParams.add(blue50.set("blue 50", 0.5,0,1)); blueParams.add(blue25.set("blue 25", 0.25,0,1)); blueParams.add(blue0.set("blue 0", 0,0,0.5)); redParams.setName("Laser red calibration"); greenParams.setName("Laser green calibration"); blueParams.setName("Laser blue calibration"); colourChangeDelay = -6; warp.visible = true; warp.dragSpeed = 1; //connectToEtherdream(); // TODO make port adjustable if(useTCP) { TCP.setup(11999); //TCP.setMessageDelimiter("\0"); } maskMarginTop.addListener(this, &LaserManager::updateMaskRectangleParam); maskMarginBottom.addListener(this, &LaserManager::updateMaskRectangleParam); maskMarginLeft.addListener(this, &LaserManager::updateMaskRectangleParam); maskMarginRight.addListener(this, &LaserManager::updateMaskRectangleParam); updateMaskRectangle(); }
ofVec2f CloudsHUDController::getSize(bool bScaled){ return ofVec2f(hudBounds.width, hudBounds.height) * (bScaled? scaleAmt : 1.0); }
//-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ if(button==0) { Dragger->released(ofVec2f(x,y)); } }
ofVec2f CloudsHUDController::getCenter(bool bScaled){ return ofVec2f(hudBounds.width * 0.5, hudBounds.height * 0.5) * (bScaled? scaleAmt : 1.0); }
void Particle::setup(float positionX, float positionY, float velocityX, float velocityY){ // 位置を設定 position = ofVec2f(positionX, positionY); // 初期速度を設定 velocity = ofVec2f(velocityX, velocityY); }
void ofxRGBDRenderer::setSimplification(int level){ simplify = level; if (simplify <= 0) { simplify = 1; } else if(simplify > 8){ simplify = 8; } baseIndeces.clear(); int w = 640 / simplify; int h = 480 / simplify; for (int y = 0; y < h-1; y++){ for (int x=0; x < w-1; x++){ ofIndexType a,b,c; a = x+y*w; b = x+(y+1)*w; c = (x+1)+y*w; baseIndeces.push_back(a); baseIndeces.push_back(b); baseIndeces.push_back(c); a = (x+1)+y*w; b = x+(y+1)*w; c = (x+1)+(y+1)*w; baseIndeces.push_back(a); baseIndeces.push_back(b); baseIndeces.push_back(c); } } indexMap.clear(); for (int y = 0; y < 480; y+=simplify){ for (int x=0; x < 640; x+=simplify){ IndexMap m; m.valid = false; indexMap.push_back(m); } } simpleMesh.clearVertices(); for (int y = 0; y < 640; y++){ for (int x=0; x < 480; x++){ simpleMesh.addVertex(ofVec3f(0,0,0)); } } if(addColors){ simpleMesh.clearColors(); for (int y = 0; y < 640; y++){ for (int x=0; x < 480; x++){ simpleMesh.addColor(ofFloatColor(1.0,1.0,1.0,1.0)); } } } if(calculateTextureCoordinates){ simpleMesh.clearTexCoords(); for (int y = 0; y < 640; y++){ for (int x=0; x < 480; x++){ simpleMesh.addTexCoord(ofVec2f(0,0)); } } } //cout << "AFTER SETUP base indeces? " << baseIndeces.size() << " index map? " << indexMap.size() << endl; }
void Particle::addForce(float forceX, float forceY){ force += ofVec2f(forceX, forceY); }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ int rand = floor( ofRandom( jointList.size() ) ); jointList[rand].applyForce( ofVec2f(ofRandom(-10, 10), 0) ); }