//-------------------------------------------------------------- void gFrameApp::update() { ///experimental vidGrabber.update(); if(vidGrabber.isFrameNew()){ ofPixels & pixels = vidGrabber.getPixels(); for(int i = 0; i < pixels.size(); i += pixels.getNumChannels()){ int r = pixels[i]; int g = pixels[i+1]; int b = pixels[i+2]; if ((r+g+b) / 3 > 128) { videoInverted[i] = 255; videoInverted[i+1] = 255; videoInverted[i+2] = 255; } else { videoInverted[i] = 0; videoInverted[i+1] = 0; videoInverted[i+2] = 0; } } videoTexture.loadData(videoInverted); } ///experimental stroke_list.update(); oscUpdate(); tuioClient.getMessage(); simple_flow.update(); simple_flow_2.update(); simple_flow.color = fluidColor; // DMX UPDATE if (ledFrame.getEnabled()) { ledFrame.updateLevel(); ledFrame.setColor(localBrushColor); ledFrame.update(); } canvasFBO.begin(); ofBackground(0); //generate obstacle on the fly //the stroke is drawn to an extra fbo //a simple shader converts the drawing into a black/white image which is then //feed into the obstacle buffers of the two fluids or only one fluid if (stroke_to_obstacle) { // obstacleFBO.begin(); // // convert2GrayShader.begin(); // // ofClear(0); // for(vector<GPoint> stroke : *stroke_list.getAllStrokes()){ // caligraphyStyle.render(stroke, (int)outputRect.width, (int)outputRect.height); // } // convert2GrayShader.end(); // // obstacleFBO.end(); // // simple_flow.addObstacle(obstacleFBO.getTexture()); // //simple_flow_2.addObstacle(obstacleFBO.getTextureReference()); //video to obstacle obstacleFBO.begin(); //obstacle_video.draw(0,0, outputRect.width, outputRect.height); videoTexture.draw(0,0, outputRect.width, outputRect.height); obstacleFBO.end(); simple_flow.addObstacle(obstacleFBO.getTexture()); } //the white background fluid simple_flow_2.draw(); if (stroke_first) { ofBlendMode(OF_BLENDMODE_SCREEN); //the colored foreground fluid simple_flow.draw(); } if (render_stroke) { for(vector<GPoint> stroke : *stroke_list.getAllStrokes()) { //always use claigraphy style caligraphyStyle.render(stroke, (int)outputRect.width, (int)outputRect.height); } } if (!stroke_first) { //the colored foreground fluid simple_flow.draw(); } if(draw_finger_positions){ drawFingerPositions((int)outputRect.width, (int)outputRect.height); } if (render_mapping_aid) { ofPushStyle(); ofSetColor(255,255); mapping_aid.draw(0,0,outputRect.width, outputRect.height); ofPopStyle(); } canvasFBO.end(); // lifetime stroke_list.setLifetime(point_lifetime * 1000); }
void OnClust::oscInsert(uint alphaID, std::list<uint> &L) { // Make a vertex and insert in graph sigma. Vertex alpha; // initialize vertex alpha.setType(Vertex::STAR); alpha.setDegree(0); alpha.setDomCenterNull(); alpha.setID(alphaID); alpha.setInQStatus(false); _graph.insert(std::pair<uint, Vertex>(alphaID, alpha)); uint betaID, betaDomCenterID, alphaDomCenterID; // For all beta in list L. for (auto &it: L){ betaID = it; // Increment degrees _graph[alphaID].incrementDegree(); _graph[betaID].incrementDegree(); // Insert alphaID and betaID in each other's adjacency lists. _graph[alphaID].insertAdjPlanet(betaID); _graph[betaID].insertAdjPlanet(alphaID); /* not really necessary to have list<uint> DomSL, AdjCL; uint DomCenterID; if (!_graph[betaID].isDomCenterNull()){ betaDomCenterID = _graph[betaID].getDomCenter(); DomSL = _graph[betaDomCenterID].getDomSatsList(); for (auto &iter1: DomSL){ DomCenterID = *iter1; AdjCL = _graph[DomCenterID].getAdjCentersList(); sortList(AdjCL); } } */ // Update center adjacency list if beta was a center. if (_graph[betaID].getType() == Vertex::CENTER) { _graph[alphaID].insertAdjCenter(betaID); } else { // **** CHANGE FOR FAST VERSION *** // Get degree of beta's dominant center betaDomCenterID = _graph[betaID].getDomCenter(); // Insert if deg of beta has exceeded the one of its dom center. if ( _graph[betaID].getDegree() > _graph[betaDomCenterID].getDegree() ) { // Insert beta into the priority queue. _graph[betaID].setInQStatus(true); _priorityQ.push(_graph[betaID]); } } } // List iteration ends. // **** CHANGE FOR FAST VERSION *** // If alpha's adjacent Center list is empty if (_graph[alphaID].isAdjCentersListEmpty()){ // Insert alpha into the priority queue. _graph[alphaID].setInQStatus(true); _priorityQ.push(_graph[alphaID]); } else { // Find alpha's dominant center. alphaDomCenterID = vertexIDMaxDeg(_graph[alphaID].getAdjCentersList()); ///////////////////// // cluster evaluation ///////////////////// // ++_center_star_changed; /////// end ///////// // Assign alpha's dominant center. _graph[alphaID].setDomCenter(alphaDomCenterID); // Insert alphaID into alpha's dom center's domsats. _graph[alphaDomCenterID].insertDomSats(alphaID); // If alpha's degree exceeds alpha's dom center's degree. if ( _graph[alphaID].getDegree() > _graph[alphaDomCenterID].getDegree() ) { // Insert alpha into the priority queue. _graph[alphaID].setInQStatus(true); _priorityQ.push(_graph[alphaID]); } } // Update using priority queue. oscUpdate(alphaID); }