//-------------------------------------------------------------- void ofApp::drawFluidObstacle(int _x, int _y, int _width, int _height) { ofPushStyle(); ofEnableBlendMode(OF_BLENDMODE_DISABLED); fluidSimulation.getObstacle().draw(_x, _y, _width, _height); ofPopStyle(); }
//-----------------------------------------------. void guiTypeTextDropDown::render(){ ofPushStyle(); guiBaseObject::renderText(); //draw the background ofFill(); glColor4fv(bgColor.getNormalColorF()); ofRect(hitArea.x, hitArea.y, hitArea.width, hitArea.height); if(bShowDropDown) { for(int i = 0; i < (int) vecDropList.size(); i++) { float bx = hitArea.x; float by = hitArea.y + i * (boxHeight); if(value.getValueI() == i){ glColor4fv(fgColor.getSelectedColorF()); }else{ glColor4fv(bgColor.getNormalColorF()); } ofFill(); ofRect(bx, by, boundingBox.width, boxHeight); ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(bx, by, boundingBox.width, boxHeight); if(i==0) { ofFill(); glColor4fv(outlineColor.getColorF()); ofRect(bx + boundingBox.width - boxHeight*0.5, by, boxHeight*0.5, boxHeight*0.5); } glColor4fv(textColor.getColorF()); displayText.renderString(vecDropList[i], bx + 2, by + boxHeight -4); } } else { float bx = hitArea.x; float by = hitArea.y; ofFill(); glColor4fv(bgColor.getColorF()); ofRect(bx, by, boundingBox.width, boxHeight); ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(bx, by, boundingBox.width, boxHeight); ofFill(); glColor4fv(outlineColor.getColorF()); //ofTriangle(bx + boundingBox.width - 7, by + boxHeight, bx + boundingBox.width - 14, by,bx + boundingBox.width, by); ofRect(bx + boundingBox.width - boxHeight*0.5, by, boxHeight*0.5, boxHeight*0.5); glColor4fv(textColor.getColorF()); displayText.renderString(vecDropList[value.getValueI()], bx + 2, by + boxHeight -4); } ofPopStyle(); }
//-------------------------------------------------------------- void ofApp::draw() { //drawTile( 1, 4, 8 ); //for( auto iter = tileset->GetTiles().begin(); iter != tileset->GetTiles().end(); iter++ ) // Iterate through the layers. for (int i = 0; i < map->GetNumLayers(); ++i) { const Tmx::Layer *layer = map->GetLayer(i); for (int y = 0; y < layer->GetHeight(); ++y) { for (int x = 0; x < layer->GetWidth(); ++x) { drawTile( i, layer, x, y ); } } } // Iterate through all of the object groups. for (int i = 0; i < map->GetNumObjectGroups(); ++i) { // Get an object group. const Tmx::ObjectGroup *objectGroup = map->GetObjectGroup(i); // Iterate through all objects in the object group. for (int j = 0; j < objectGroup->GetNumObjects(); ++j) { // Get an object. const Tmx::Object *object = objectGroup->GetObject(j); // Print information about the object. printf("Object Name: %s\n", object->GetName().c_str()); printf("Object Position: (%03d, %03d)\n", object->GetX(), object->GetY()); printf("Object Size: (%03d, %03d)\n", object->GetWidth(), object->GetHeight()); ofPushMatrix(); ofTranslate(object->GetX(), object->GetY()); ofPushStyle(); ofNoFill(); ofSetColor(255,0,0); ofSetPolyMode(OF_POLY_WINDING_ODD); // this is the normal mode // Print Polygon points. const Tmx::Polygon *polygon = object->GetPolygon(); if (polygon != 0) { ofBeginShape(); for (int i = 0; i < polygon->GetNumPoints(); i++) { const Tmx::Point &point = polygon->GetPoint(i); ofVertex(point.x, point.y); } ofEndShape(); } // Print Polyline points. const Tmx::Polyline *polyline = object->GetPolyline(); if (polyline != 0) { ofBeginShape(); for (int i = 0; i < polyline->GetNumPoints(); i++) { const Tmx::Point &point = polyline->GetPoint(i); ofVertex(point.x, point.y); } ofEndShape(); } ofPopStyle(); ofPopMatrix(); } } }
void kinectCapture::drawNormBlobs(int x, int y, int w, int h){ ofPushMatrix(); ofTranslate(x, y); // for (int i = 0; i < foundBlobs.size(); i++) { // ofSetColor(0, 255, 0); // ofBeginShape(); // for (int j = 0; j < foundBlobs[i].pts.size(); j++) { // ofVertex(foundBlobs[i].pts[j].x * (float)w, foundBlobs[i].pts[j].y * (float)h); // } // ofEndShape(); // ofSetColor(0, 0, 255); // //// DRAW RAW BOUNDING RECT (WITHOUT ANGLE) //// ofRect(foundBlobs[i].boundingRect.x*(float)w, foundBlobs[i].boundingRect.y*(float)h, foundBlobs[i].boundingRect.width*(float)w, foundBlobs[i].boundingRect.height*(float)h); // // //// DRAW MINIMAL SIZED ANGLED BOUNDING RECT // ofPushMatrix(); // ofTranslate(foundBlobs[i].angleBoundingRect.x * w, foundBlobs[i].angleBoundingRect.y * h); // ofRotate(foundBlobs[i].angle+90, 0.0f, 0.0f, 1.0f); // ofTranslate(-(foundBlobs[i].angleBoundingRect.x * w), -(foundBlobs[i].angleBoundingRect.y * h)); // ofNoFill(); // // ofPushStyle(); // ofNoFill(); // ofRect((foundBlobs[i].angleBoundingRect.x - foundBlobs[i].angleBoundingRect.width/2) * w, (foundBlobs[i].angleBoundingRect.y - foundBlobs[i].angleBoundingRect.height/2) * h, foundBlobs[i].angleBoundingRect.width * w, foundBlobs[i].angleBoundingRect.height * h); // // ofPopStyle(); // ofPopMatrix(); // // ofSetColor(255, 0, 0); // //ofDrawBitmapString(ofToString(foundBlobs[i].id), foundBlobs[i].centroid.x*(float)w, foundBlobs[i].centroid.y*(float)h); // font.drawString(ofToString(foundBlobs[i].id), foundBlobs[i].centroid.x*(float)w, foundBlobs[i].centroid.y*(float)h); // } for (int i = 0; i < activeBlobsIds.size(); i++) { ofSetColor(0, 255, 0); ofBeginShape(); for (int j = 0; j < foundBlobsMap[activeBlobsIds[i]].pts.size(); j++) { ofVertex(foundBlobsMap[activeBlobsIds[i]].pts[j].x * (float)w, foundBlobsMap[activeBlobsIds[i]].pts[j].y * (float)h); } ofEndShape(); ofSetColor(0, 0, 255); // DRAW RAW BOUNDING RECT (WITHOUT ANGLE) // ofRect(foundBlobs[i].boundingRect.x*(float)w, foundBlobs[i].boundingRect.y*(float)h, foundBlobs[i].boundingRect.width*(float)w, foundBlobs[i].boundingRect.height*(float)h); // DRAW MINIMAL SIZED ANGLED BOUNDING RECT ofPushMatrix(); ofTranslate(foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.x * w, foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.y * h); ofRotate(foundBlobsMap[activeBlobsIds[i]].angle+90, 0.0f, 0.0f, 1.0f); ofTranslate(-(foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.x * w), -(foundBlobs[i].angleBoundingRect.y * h)); ofNoFill(); ofPushStyle(); ofNoFill(); ofRect((foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.x - foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.width/2) * w, (foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.y - foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.height/2) * h, foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.width * w, foundBlobsMap[activeBlobsIds[i]].angleBoundingRect.height * h); ofPopStyle(); ofPopMatrix(); ofSetColor(255, 0, 0); ofDrawBitmapString(ofToString(foundBlobsMap[activeBlobsIds[i]].id), foundBlobsMap[activeBlobsIds[i]].centroid.x*(float)w, foundBlobsMap[activeBlobsIds[i]].centroid.y*(float)h); //font.drawString(ofToString(foundBlobsMap[activeBlobsIds[i]].id), foundBlobsMap[activeBlobsIds[i]].centroid.x*(float)w, foundBlobsMap[activeBlobsIds[i]].centroid.y*(float)h); } ofPopMatrix(); }
void ofxQuNeo::drawInterface(int x, int y){ int numCols = 4; int numRows = 4; int padWidth = 50; int padHeight = 50; ofPushStyle(); ofPushMatrix(); ofTranslate(x,y); //Draw Pads----------------------- int countpos = 1; for(int k = 4; k>0;k--){ //start in bottom left for(int j = 0; j<4;j++){ ofPushMatrix(); ofTranslate((j*55)+50, (k*55)); ofSetRectMode(OF_RECTMODE_CORNER); ofSetColor(0, 0, 0); ofNoFill(); ofRect(0,0,padWidth, padHeight); float xScale, yScale, pressureScale; pressureScale = ofMap(controlVals[pressNum[countpos-1]], 0, 127, 0, padWidth); xScale = ofMap(controlVals[xNum[countpos-1]], 0, 127, 0, padWidth); yScale = ofMap(controlVals[yNum[countpos-1]], 127, 0, 0, padHeight); ofSetRectMode(OF_RECTMODE_CENTER); ofSetColor(100, 100, 255); ofFill(); ofRect(padWidth/2,(padWidth/2),pressureScale, pressureScale); ofSetRectMode(OF_RECTMODE_CORNER); //draw x/y stuff ofFill(); ofSetColor(0, 0, 255); ofRect(xScale, yScale, 5, 5); //name of pad ofSetColor(0); ofDrawBitmapString(ofToString(countpos), 20,20); ofPopMatrix(); countpos++; } } ofPopMatrix(); //Draw Arrows-------------------- ofPushMatrix(); ofTranslate(x+50, y+320); ofDrawBitmapString("Arrows", 0,40); for (int i=0; i<15; i++){ ofPushMatrix(); ofTranslate(i*15,0); ofSetRectMode(OF_RECTMODE_CENTER); int pressureScale = ofMap(controlVals[arrowPressNum[i]], 0, 127, 0, padHeight); ofNoFill(); ofSetColor(0, 0, 0); ofRect(0,0,10, padHeight); ofSetColor(100, 100, 255); ofFill(); ofRect(0,-pressureScale/2+padHeight/2,10, pressureScale); ofPopMatrix(); } for (int i=0; i<oscPaths.size(); i++){ ofDrawBitmapString(oscPaths[i], 20, 100+i*20); } ofPopMatrix(); //Draw Sliders Buttons---------------------- ofPushMatrix(); ofTranslate(x+50, y); ofSetColor(0); ofDrawBitmapString("Sliders", 0,40); for (int i=0; i<11; i++){ ofPushMatrix(); ofTranslate(i*20,0); ofSetRectMode(OF_RECTMODE_CENTER); int pressureScale = ofMap(controlVals[sliderPressNum[i]], 0, 127, 0, padHeight); int locScale = ofMap(controlVals[sliderLocNum[i]], 127, 0, 0, padHeight); ofNoFill(); ofSetColor(0, 0, 0); ofRect(0,0,10, padHeight); ofSetColor(100, 100, 255); ofFill(); ofRect(0,-pressureScale/2+padHeight/2,10, pressureScale); ofSetColor(0, 0, 0); ofRect(0, locScale-padHeight/2, 10, 5); ofPopMatrix(); } ofPopMatrix(); ofPopStyle(); }
//-------------------------------------------------------------- void ofxMuiButton::draw() { ofPushStyle(); ofPushMatrix(); // initial push ofTranslate(getHitBoxPosition()); //--------- DRAW THE BUTTON BACKGROUND // default ofFill(); ofSetColor(cActiveAreaBackground.get(isTouchOver(),isTouchDown(),isEnabled(),alphaScale)); if(roundFrame) { // assuming that the icon is square ... ofCircle(getHitBoxWidth()/2, getHitBoxHeight()/2, getHitBoxWidth()/2); } else { ofxRect(0, 0, getHitBoxWidth(), getHitBoxHeight()); } ofNoFill(); ofSetColor(cActiveAreaForeground.get(isTouchOver(),isTouchDown(),isEnabled(),alphaScale)); if(useIcon) { int iconWidth = icon->getIcon(getValue())->getWidth(); int iconHeight = icon->getIcon(getValue())->getHeight();; int hitWidth = getHitBoxWidth(); int hitHeight = getHitBoxHeight(); int xlateX = 0; int xlateY = 0; // center the icon ofPushMatrix(); if(iconWidth < hitWidth) { int diffX = hitWidth - iconWidth; xlateX = diffX/2; } else { int diffX = iconWidth - hitWidth; xlateX = -diffX/2; } if(iconHeight < hitHeight) { int diffY = hitHeight - iconHeight; xlateY = diffY/2; } else { int diffY = iconHeight - hitHeight; xlateY = -diffY/2; } ofTranslate(xlateX, xlateY); icon->getIcon(getValue())->draw(0,0); ofPopMatrix(); } else { ofFill(); ofxRect(0, 0, getHitBoxWidth(), getHitBoxHeight()); } ofNoFill(); ofSetColor(cActiveAreaFrame.get(isTouchOver(),isTouchDown(),isEnabled(),alphaScale)); if(roundFrame) { // assuming that the icon is square ... ofCircle(getHitBoxWidth()/2, getHitBoxHeight()/2, getHitBoxWidth()/2); } else { ofxRect(0, 0, getHitBoxWidth(), getHitBoxHeight()); } ofPopMatrix(); // HIT RECT PUSH ofPopStyle(); }
//-------------------------------------------------------------- void ofxMuiTextBlock::draw(float x, float y) { ofPushStyle(); ofPushMatrix(); ofTranslate(x,y); { if(debug) { ofSetColor(255,255,0); ofLine(0,0,0,ofGetHeight()); ofLine(0,0,ofGetWidth(),0); ofPushStyle(); if(isTextWidthLimited()) { ofSetColor(255,0,0); ofLine(getBlockWidth(),0,getBlockWidth(),ofGetHeight()); } if(isTextHeightLimited()) { ofSetColor(255,0,0); ofLine(0,getBlockHeight(),ofGetWidth(),getBlockHeight()); } ofPopStyle(); } ofTranslate(0,font->getSize()); ofSetColor(cTextColor); font->drawString(displayText,0,0); /* if(!displayText.empty()) { ofSetColor(cTextColor); ofPushMatrix(); // TODO: add support for various text alignments ofRectangle drawOffsets = displayStringBoundingBox; switch(orientation) { case OF_ORIENTATION_UNKNOWN: // if unknown, use default case OF_ORIENTATION_DEFAULT: ofTranslate(0, labelFont->getSize()); break; case OF_ORIENTATION_180: ofTranslate(displayStringBoundingBox.width, getContentBoxHeight() - labelFont->getSize()); ofRotateZ(180); break; case OF_ORIENTATION_90_RIGHT: ofTranslate(0,0); ofRotateZ(90); break; case OF_ORIENTATION_90_LEFT: // TODO: this is off in the Y direction ... not sure why. ofTranslate(font->getSize(), getTextBoxHeight()); ofRotateZ(-90); break; } //font->drawString(displayText,drawOffsets.x,drawOffsets.y); ofPopMatrix(); } */ } ofPopMatrix(); ofPopStyle(); }
//-------------------------------------------------------------- void testApp::draw(){ ofClear(255, 255, 255, 0); ofSetColor(255, 255, 255,255); //Draw Flying Videos drawBoids(); //Clear Background ofClear(255, 255, 255, 0); //Tranparent Background) ofBackground(255, 255, 255, 0); //Tranparent Background //Text ofFill(); if (cvImgDisp) { ofSetColor(255, 0, 0); // RED FOR DEBUG }else{ ofSetColor(255, 255, 255,255); // White for display color } drawText(); ofSetColor(210, 229, 247, 255); //BACKGROUND FOR FLYERS ofRect(0,0, ofGetWidth(), ofGetHeight()); //bgImg.draw(0,0); // TEXTURE FOR FLYERS // OR VIDEO TEXTURE //bgVideo.play(); /* bgVideo.draw(0,0,ofGetWidth(), ofGetHeight()); */ // MULTIPLE SEQUENCE /* if(endRecordSequence == true){ bgVideoEndRec.play(); bgVideoEndRec.draw(0,0,ofGetWidth(), ofGetHeight()); bgVideo.stop(); }else { bgVideo.play(); bgVideo.draw(0,0,ofGetWidth(), ofGetHeight()); bgVideoEndRec.stop(); } */ if(posBgImg >= 0 && endRecordSequence){ posBgImg = 0; }else{ posBgImg = videoPos*1-960; } bgImg.draw(posBgImg,0 , 1920, ofGetHeight()); // TEXTURE FOR FLYERS ofSetColor(255, 255, 255,255); ////COVER TEXT //Cutout ofSetColor(255, 255, 255,255); //ofSetColor can change the tint of an image, this resets is cutoutTex.draw((0-videoPos*1.5)+200,(ofGetHeight()/2)-(camHeightScale/2) , camWidthScale, camHeightScale); // correct proportions //Show the 'End Record Sequence' if (endRecordSequence == true) { string goodbye = "Tu voles maintenant sur la Carte Blanche!"; ofPushStyle(); //ofSetColor(28, 20, 255); ofPushMatrix(); ofTranslate(900, (ofGetHeight()/2)+350); ofRotateZ(-90); ofSetColor(255, 255, 255); shimmer.drawString(goodbye, 0, 0); ofSetColor(28, 20, 255); shimmer.drawString(goodbye, 1, 1); ofPopMatrix(); ofPopStyle(); } //Tell people that the buffer is full if that is true if (bufferFull && !endRecordSequence) { string full = "La carte est pleine! L'enregistrement reprendra lors du prochain spectacles"; ofPushStyle(); ofSetColor(28, 20, 255); ofPushMatrix(); ofTranslate(900, (ofGetHeight()/2)+480); ofRotateZ(-90); shimmer.drawString(full, 0, 0); ofPopMatrix(); ofPopStyle(); } //Progress bar for recording //ofSetColor(255-(100-index)*2,0,0,255); //ofSetColor(0, 229, 247, 255); if(endRecordSequence == false){ ofSetColor(255, 0, 0, 50); ofRect(800,(ofGetHeight()/2), 15, 200); ofRect(800,(ofGetHeight()/2), 15, -200); ofSetColor(255, 0, 0, 255); /* ofRect(800,(ofGetHeight()/2), 15, (100-index)*2); ofRect(800,(ofGetHeight()/2), 15, -(100-index)*2); */ //videoProgessBar = videoProgressBar - videoPos; /* if(videoProgressBar == 0){ endRecordSequence =true; }else { endRecordSequence=false; } */ ofRect(800,(ofGetHeight()/2), 15, (100-videoPos/4)*2); ofRect(800,(ofGetHeight()/2), 15, -(100-videoPos/4)*2); // test circle progress // ofCircle((ofGetHeight()/2),(150+index)*2,20); ofSetColor(255, 255, 255, 255); //posBgImg = -1280; /* progressBar.draw(800,(ofGetHeight()/2), 20, 200); progressBar.draw(800,(ofGetHeight()/2), 20, -200); */ /* progressBar.draw(800,(ofGetHeight()/2), 20, (100-index)*2); progressBar.draw(800,(ofGetHeight()/2), 20, -(100-index)*2); */ ofSetColor(210, 229, 247, 120); ofNoFill(); ofRect(794,(ofGetHeight()/2)-205,25,410); }else{ ofRect(800,0, 15, 0); ofRect(800,0, 15, 0); progressBar.draw(800,0, 15, 0); progressBar.draw(800,0, 15, 0); } /* OLD MECANISM FOR THE PROGRESS BAR ofSetColor(255-(100-index)*2,0,0,255); ofRect(800,(ofGetHeight()/2), 20, (100-index)*2); ofRect(800,(ofGetHeight()/2), 20, -(100-index)*2); */ //Debug Functions // shimmer.drawString(ofToString(index), ofGetWidth()-50, ofGetHeight()-50); ofSetColor(0,0,0, 120); //shimmer.drawString(ofToString(showState), ofGetWidth()-50, ofGetHeight()-50); //shimmer.drawString(ofToString(posBgImg), ofGetWidth()-150, ofGetHeight()-100); //shimmer.drawString(ofToString(lowBlob), ofGetWidth()-300, ofGetHeight()-100); //shimmer.drawString(ofToString(highBlob), ofGetWidth()-300, ofGetHeight()-150); /* shimmer.drawString(ofToString(showBoidsHead-showBoidsTail), ofGetWidth()-180, 50); shimmer.drawString("de" , ofGetWidth()-120, 50); shimmer.drawString(ofToString(bufferSize), ofGetWidth()-70, 50); shimmer.drawString(ofToString(posBgImg), ofGetWidth()-200, 100); */ //shimmer.drawString(ofToString(videoPos), ofGetWidth()-70, 50); //shimmer.drawString(ofToString(highBlob), ofGetWidth()-200, 100); if (cvImgDisp) { cvImages(); } //get the last playIndex before the program loops back lastPlayIndex = playIndex; }
bool SceneGame :: draw() { if(!Scene::draw()) return false; float centreX = APP_WIDTH/2; float centreY = APP_HEIGHT/2; ofPushStyle(); if(currentGame == GAME_INVADERS) { for(int i = 0; i<invaders.size(); i++) { Invader& invader = *invaders[i]; if(!invader.enabled) continue; invader.draw(); activeInvaders++; } ofSetColor(255); if((gameState == STATE_PREINTRO)&&(playing)) { if(timeSinceLastStateChange<8) { String s = "READY TO PLAY INVADERS?"; drawStringCentered(s, centreX, centreY-50); float flashspeed = 1.0f; if(modff(timeSinceLastStateChange,&flashspeed)<0.7) { drawStringCentered("YES / NO", centreX, centreY+50); } } else if((timeSinceLastStateChange>9) && (timeSinceLastStateChange<18)) { String s = "I SAID"; drawStringCentered(s, centreX, centreY-100); if(timeSinceLastStateChange>11) { drawStringCentered("ARE YOU READY TO PLAY?", centreX, centreY); float flashspeed = 1.0f; if(modff(timeSinceLastStateChange,&flashspeed)<0.7) { drawStringCentered("YES OR NO", centreX, centreY+100); } } } } else if(gameState == STATE_INTRO) { String s = "PLAYERS GET READY"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } } else if(gameState == STATE_WAITING) { String s = "LEVEL "+ofToString(level)+" CLEARED!"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= "NEXT LEVEL IN "+ ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } } else if(gameState == STATE_GAMEOVER) { ofSetColor(255); drawStringCentered("GAME OVER", centreX, centreY); } } else if(currentGame == GAME_ASTEROIDS) { for(int i = 0; i<asteroids.size(); i++) { Asteroid& asteroid = *asteroids[i]; if(!asteroid.enabled) continue; asteroid.draw(); } if(gameState == STATE_INTRO) { String s = "PLAYERS GET READY"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } } else if(gameState == STATE_WAITING) { String s = "LEVEL "+ofToString(level)+" CLEARED!"; drawStringCentered(s, centreX, centreY-50); int secondsToGo = 5-ceil(timeSinceLastStateChange); if(secondsToGo<=3) { s= "NEXT LEVEL IN "+ ofToString(secondsToGo); drawStringCentered(s, centreX, centreY+50); } //ofDrawBitmapString("LEVEL "+ofToString(level)+" CLEARED " + ofToString(ofGetElapsedTimef()-lastStateChangeTime), 500,500); } else if(gameState == STATE_GAMEOVER) { ofSetColor(255); //ofDrawBitmapString("GAME OVER" + ofToString(ofGetElapsedTimef()-lastStateChangeTime), 500,500); drawStringCentered("GAME OVER", centreX, centreY); } } // ofDrawBitmapString("GAME: " + ofToString(currentGame), 10,500); // ofDrawBitmapString("STATE: " + ofToString(gameState), 10,550); // ofDrawBitmapString("TIME SINCE CHANGE: " + ofToString(timeSinceLastStateChange), 10,600); ofPopStyle(); }
//------------------------------------------------------- void timeNode::draw(){ ofPushStyle(); seqRise.draw(); seqFall.draw(); ofPopStyle(); }
void CloudsVisualSystemLSystems::selfDraw(){ // mat->begin(); glDisable(GL_DEPTH_TEST); ofPushMatrix(); ofPushStyle(); // Grid // ofPushStyle(); // ofEnableBlendMode(OF_BLENDMODE_ADD); glLineWidth(gridCrossWidth); grid.draw(); ofPopStyle(); // Original L-System // ofEnableAlphaBlending(); ofSetColor(255, lsysOriginalAlpha*255); lsysOriginal.draw(); // Dots // ofEnableBlendMode(OF_BLENDMODE_ADD); ofSetColor(255, dotAlpha*255); for(int i = 0; i < dots.size(); i++){ glPointSize(dotSize); glBegin(GL_POINTS); glVertex3f(dots[i].x,dots[i].y,dots[i].z); glEnd(); } ofDisableBlendMode(); ofEnableAlphaBlending(); for (int i = 0; i < lsysNodes.size(); i++) { if ( lsysNodes[i].trailsPct > 0.1 && lsysNodes[i].trailsPct < 0.9){ for(int j = 0; j < lsysNodes[i].trails.size(); j++){ ofMesh mesh; mesh.setMode(OF_PRIMITIVE_LINE_STRIP); for(int k = 0; k < lsysNodes[i].trails[j].size(); k++){ float alpha = ofMap(k, 0,lsysNodes[i].trails[j].size(), 0.0, lsysFlowAlpha); mesh.addColor( ofFloatColor( 1.0, alpha) ); mesh.addVertex(lsysNodes[i].trails[j][k]); } ofFill(); ofSetColor( 255 ); mesh.draw(); } } } // Growing Trace // ofSetColor(255, lsysGrowingAlpha*255); lsysGrowing.draw(); ofPopStyle(); ofPopMatrix(); // mat->end(); }
//---------- void Device::drawWorld() { auto colorSource = this->getColorSource(); auto depthSource = this->getDepthSource(); auto bodySource = this->getBodySource(); if (!depthSource) { ofLogError("ofxKinectForWindows2::Device::drawPrettyMesh") << "No depth source initialised"; return; } //point cloud { //setup some point cloud properties for kicks bool usePointSize = true; #if OF_VERSION_MAJOR > 0 || OF_VERSION_MINOR >= 10 auto mainWindow = std::static_pointer_cast<ofAppGLFWWindow>(ofGetCurrentWindow()); usePointSize = mainWindow ? mainWindow->getSettings().glVersionMajor <= 2 : false; #endif usePointSize = false; if (usePointSize) { glPushAttrib(GL_POINT_BIT); glPointSize(5.0f); glEnable(GL_POINT_SMOOTH); } ofPushStyle(); bool useColor = colorSource.get(); if (useColor) { useColor &= colorSource->getTexture().isAllocated(); } if (useColor) { //bind kinect color camera texture and draw mesh from depth (which has texture coordinates) colorSource->getTexture().bind(); } auto opts = Source::Depth::PointCloudOptions(true, Source::Depth::PointCloudOptions::TextureCoordinates::ColorCamera); auto mesh = depthSource->getMesh(opts); //draw point cloud mesh.drawVertices(); //draw triangles ofSetColor(255, 150); mesh.drawWireframe(); //draw fills faded ofSetColor(255, 50); mesh.drawFaces(); if (useColor) { //unbind colour camera colorSource->getTexture().unbind(); } ofPopStyle(); //clear the point cloud drawing attributes if (usePointSize) { glPopAttrib(); } } //bodies and floor if (bodySource) { bodySource->drawWorld(); ofPushMatrix(); ofRotate(90, 0, 0, 1); ofMultMatrix(bodySource->getFloorTransform()); ofDrawGridPlane(5.0f); ofPopMatrix(); } //draw the view cones of depth and colour cameras ofPushStyle(); ofNoFill(); ofSetLineWidth(2.0f); ofSetColor(100, 200, 100); depthSource->drawFrustum(); if (colorSource) { ofSetColor(200, 100, 100); colorSource->drawFrustum(); } ofPopStyle(); }
//-------------------------------------------------------------- void ofApp::drawSource(int _x, int _y, int _width, int _height) { ofPushStyle(); ofEnableBlendMode(OF_BLENDMODE_DISABLED); cameraFbo.draw(_x, _y, _width, _height); ofPopStyle(); }
//-------------------------------------------------------------- void ofApp::drawMask(int _x, int _y, int _width, int _height) { ofPushStyle(); ofEnableBlendMode(OF_BLENDMODE_DISABLED); velocityMask.draw(_x, _y, _width, _height); ofPopStyle(); }
void openTableImageGroup::draw() { float current_rotation = m_rotation - 45.0; float rotation_inc = 90.0 / m_images.size(); ofPath path; ofPoint axis( 0, 0, 1.0); for ( int i = 0; i < m_images.size(); i++ ) { if ( m_images[ i ].isLoaded() ) { ofPushMatrix(); ofPoint dim(m_images[ i ].m_image->getWidth(),m_images[ i ].m_image->getHeight()); float scale = MIN(160./dim.x, 120./dim.y); dim *= scale; ofTranslate( m_position ); ofRotate( current_rotation ); m_images[ i ].m_image->draw( 0, 0, dim.x, dim.y ); ofPopMatrix(); // // update outline path // dim /= 2.; ofPoint topleft( -dim.x, -dim.y ); ofPoint topright( dim.x, -dim.y ); ofPoint bottomright( dim.x, dim.y ); ofPoint bottomleft( -dim.x, dim.y ); topleft.rotate(current_rotation, axis); topleft += m_position; topright.rotate(current_rotation, axis); topright += m_position; bottomright.rotate(current_rotation, axis); bottomright += m_position; bottomleft.rotate(current_rotation, axis); bottomleft += m_position; path.newSubPath(); path.moveTo( topleft ); path.lineTo( topright ); path.lineTo( bottomright ); path.lineTo( bottomleft ); path.close(); // // // current_rotation += rotation_inc; } } if ( m_annotation.length() > 0 ) { ofApp* app = ( ofApp* ) ofGetAppPtr(); //ofRectangle bounds = app->m_default_font.getStringBoundingBox(m_annotation, 0, 0, 24.); ofRectangle bounds = app->m_default_font.getBBox(m_annotation, 24., 0, 0); ofPoint dim( bounds.width, bounds.height ); ofPushStyle(); ofPushMatrix(); ofTranslate( m_position ); ofRotate( m_rotation ); ofTranslate( -( dim.x/2. ), 120.0 ); ofSetColor(255, 255, 255, 127); ofRect( -8, -( dim.y / 2 + 16 ), dim.x + 16, dim.y + 16 ); ofSetColor(ofColor::black); //app->m_default_font.drawString(m_annotation, 0, 0, 24.); app->m_default_font.draw(m_annotation, 24., 0, 0); ofPopMatrix(); ofPopStyle(); // // add to outline // ofPoint position = m_position; dim.x += 16; dim.y += 16; dim /= 2.; ofPoint topleft( -dim.x, -dim.y + 112. ); ofPoint topright( dim.x, -dim.y + 112. ); ofPoint bottomright( dim.x, dim.y + 112. ); ofPoint bottomleft( -dim.x, dim.y + 112. ); topleft.rotate(m_rotation, axis); topleft += position; topright.rotate(m_rotation, axis); topright += position; bottomright.rotate(m_rotation, axis); bottomright += position; bottomleft.rotate(m_rotation, axis); bottomleft += position; path.newSubPath(); path.moveTo( topleft ); path.lineTo( topright ); path.lineTo( bottomright ); path.lineTo( bottomleft ); path.close(); } // // convert path to polyline for hit test // m_hit_lock.lock(); m_outline = path.getOutline(); m_hit_lock.unlock(); /* ofPushStyle(); path.setStrokeWidth( 1 ); path.setStrokeColor( ofColor::red ); path.setFillColor( ofColor( 255, 0, 0, 128 ) ); path.draw(); ofSetColor( ofColor::green ); ofNoFill(); for ( auto& poly : m_outline ) { poly.draw(); } ofPopStyle(); */ }
void Trigger :: draw(ofRectangle area, int motionTargetThreshold) { if(settings!=NULL) { settings->update(deltaTime, values); settings->draw(elapsedTime, pos, unitPower, active, scale, angle); if(elapsedTime-lastTriggerTime<0.15) { ofPushMatrix(); ofPushStyle(); ofTranslate(pos.x, pos.y); float size = ofMap(elapsedTime - lastTriggerTime, 0, 0.15, 1, 0); size*=size; size*=settings->radius*5; ofScale(size, size); ofSetColor(settings->getColour()); flashImage.draw(-0.5, -0.5, 1,1); ofScale(0.5,0.5); flashImage.draw(-0.5, -0.5, 1,1); ofPopStyle(); ofPopMatrix(); } } if(lastSettings!=NULL) { lastSettings->update(deltaTime, values); lastSettings->draw(elapsedTime, pos, unitPower, active, lastScale, angle); } if(!active) return; if(showDebugData) { ofPushMatrix(); ofPushStyle(); ofTranslate(pos); ofSetColor(100,0,0); ofNoFill(); ofRect(-triggerSampleSize/2, -triggerSampleSize/2, triggerSampleSize, triggerSampleSize); ofTranslate(0, motionValueCount*-2); ofFill(); for(float i = -0.5; i<=0.5 ; i++){ ofPushMatrix(); ofBeginShape(); ofScale(i,1); ofVertex(-1,0); float lastvalue = -1; for(int i = 0; i<motionValues.size(); i++) { float value = ofClamp(motionValues[i]*20, 0, 50); if(value!=lastvalue) { ofVertex(lastvalue,(i*2)-1); ofVertex(value,i*2); ofVertex(value,(i*2)+1); } lastvalue = value; } ofVertex(0,motionValues.size()*2); ofVertex(-1,motionValues.size()*2); ofEndShape(); ofPopMatrix(); } ofPopMatrix(); for(int i = 0; i<vertMotionSamples.size(); i++) { float sample = vertMotionSamples[i]; ofSetColor(ofMap(sample, 0, 255,0,255,true)); if(sample<motionTargetThreshold) ofSetColor(50,0,0); ofNoFill(); float ypos = ofMap(i, 0, vertMotionSamples.size(), area.getTop(), area.getBottom()); ofCircle(pos.x, ypos, 3); ofRect(pos.x - (multiSampleSize/2), ypos-(multiSampleSize/2), multiSampleSize, multiSampleSize); } ofPopStyle(); } else if(sampleBrightness>0) { ofPushStyle(); for(int i = 0; i<vertMotionSamples.size(); i++) { // ofSetColor(ofMap(sample, 0, 255,0,255,true)); //if(sample<motionTargetThreshold) ofSetColor(50,0,0); ofNoFill(); float ypos = ofMap(i, 0, vertMotionSamples.size(), area.getTop(), area.getBottom()); if(ypos > pos.y) { float sample = vertMotionSamples[i]; ofSetColor(sampleBrightness * 100 ); ofSetLineWidth(1* scale); ofCircle(pos.x, ypos, 3* scale); if(i<vertMotionSamples.size()-1) { ofLine(pos.x, ypos+(3* scale), pos.x, ofMap(i+1, 0, vertMotionSamples.size(), area.getTop(), area.getBottom())-(3* scale)); } ofSetColor(ofMap(sample, 0, 255,0,80,true) * sampleBrightness); ofFill(); ofCircle(pos.x, ypos, 2* scale); } } ofPopStyle(); } }
//------------------------------------------- void ofxAssimpModelLoader::draw(ofPolyRenderMode renderType) { if(scene){ ofPushStyle(); #ifndef TARGET_OPENGLES glPushAttrib(GL_ALL_ATTRIB_BITS); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glPolygonMode(GL_FRONT_AND_BACK, ofGetGLPolyMode(renderType)); #endif glEnable(GL_NORMALIZE); ofPushMatrix(); ofTranslate(pos); ofRotate(180, 0, 0, 1); ofTranslate(-scene_center.x, -scene_center.y, scene_center.z); if(normalizeScale) { ofScale(normalizedScale , normalizedScale, normalizedScale); } for(int i = 0; i < (int)rotAngle.size(); i++){ ofRotate(rotAngle[i], rotAxis[i].x, rotAxis[i].y, rotAxis[i].z); } ofScale(scale.x, scale.y, scale.z); if(getAnimationCount()) { updateGLResources(); } for(int i = 0; i < (int)modelMeshes.size(); i++){ ofxAssimpMeshHelper & meshHelper = modelMeshes.at(i); // Texture Binding if(bUsingTextures && meshHelper.texture.isAllocated()){ meshHelper.texture.bind(); } if(bUsingMaterials){ meshHelper.material.begin(); } // Culling if(meshHelper.twoSided) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); ofEnableBlendMode(meshHelper.blendMode); #ifndef TARGET_OPENGLES meshHelper.vbo.drawElements(GL_TRIANGLES,meshHelper.indices.size()); #else switch(renderType){ case OF_MESH_FILL: meshHelper.vbo.drawElements(GL_TRIANGLES,meshHelper.indices.size()); break; case OF_MESH_WIREFRAME: meshHelper.vbo.drawElements(GL_LINES,meshHelper.indices.size()); break; case OF_MESH_POINTS: meshHelper.vbo.drawElements(GL_POINTS,meshHelper.indices.size()); break; } #endif // Texture Binding if(bUsingTextures && meshHelper.texture.bAllocated()){ meshHelper.texture.unbind(); } if(bUsingMaterials){ meshHelper.material.end(); } } ofPopMatrix(); #ifndef TARGET_OPENGLES glPopClientAttrib(); glPopAttrib(); #endif ofPopStyle(); } }
//-------------------------------------------------------------- void testApp::draw(){ ofEnableAlphaBlending(); ofBackground(0,0,0); ofSetColor(255,255,255,255); vidGrabber.draw(20,20,160,120); ofDrawBitmapString("LIVE GRABBER", 22,32); if(currentVideoSource == 0) { ofSetColor(isRecording ? 0 : 255,255,0); ofNoFill(); ofRect(20,20,160,120); } ofSetColor(255,255,255,255); vidIpCam.draw(20,140,160,120); ofDrawBitmapString("LIVE WEB", 22,152); if(currentVideoSource == 1) { ofSetColor(isRecording ? 0 : 255,255,0); ofNoFill(); ofRect(20,140,160,120); } ofSetColor(255,255,255,255); vidPlayer.draw(20,260,160,120); ofDrawBitmapString("VID", 22,272); if(currentVideoSource == 2) { ofSetColor(isRecording ? 0 : 255,255,0); ofNoFill(); ofRect(20,260,160,120); } string keys = ""; keys += "Keys:\n"; keys += "Select the Source (ABOVE LEFT)\n"; keys += " [1] Next Video Source\n"; keys += " [s] Video Grabber Settings\n"; keys += "\n"; keys += "Select the Buffer Player (RIGHT)\n"; keys += " [`] Next Buffer Player\n"; keys += "\n"; keys += "All settings below apply to the\n"; keys += "current player and buffer.\n"; keys += " [SPACE] Toggle Recording\n"; keys += " [x] Clear Buffer\n"; keys += " [?] Load Test Video Into Buffer\n"; keys += " [p] Next Buffer Mode\n"; keys += " [q] Next Loop Mode\n"; keys += "\n"; keys += " [[] Loop Point (start) (DOWN)\n"; keys += " [{] Loop Point (end) (DOWN)\n"; keys += " []] Loop Point (start) (UP)\n"; keys += " [}] Loop Point (end) (UP)\n"; keys += " [c] Clear Loop Points\n"; keys += "\n"; keys += " [-] Decrease Speed\n"; keys += " [=] Increase Speed\n"; keys += "\n"; keys += " [_] Decrease Position\n"; keys += " [+] Increase Position\n"; ofSetColor(255); ofDrawBitmapString(keys,20,400); if(isRecording) { if(currentVideoSource == 0 && vidGrabber.isFrameNew()) { ofxSharedVideoFrame frame(new ofImage()); frame->setFromPixels(vidGrabber.getPixelsRef()); bufferPlayers[currentBufferPlayer]->getVideoBuffer()->bufferFrame(frame); } else if(currentVideoSource == 1 ) {//&& vidIpCam.isFrameNew()) { // TODO ofxSharedVideoFrame frame(new ofImage()); frame->setFromPixels(vidIpCam.getPixelsRef()); bufferPlayers[currentBufferPlayer]->getVideoBuffer()->bufferFrame(frame); } else if(currentVideoSource == 2 && vidPlayer.isFrameNew() ) { ofxSharedVideoFrame frame(new ofImage()); frame->setFromPixels(vidPlayer.getPixelsRef()); bufferPlayers[currentBufferPlayer]->getVideoBuffer()->bufferFrame(frame); } } int x = 320; int y = 20; for(int i = 0; i < bufferPlayers.size(); i++) { ofSetColor(255); ofFill(); bufferPlayers[i]->draw(x,y); if(currentBufferPlayer == i) { ofSetColor(255,255,0); } else { ofSetColor(255,127); } ofNoFill(); ofRect(x,y,camWidth,camHeight); if(!bufferPlayers[i]->getVideoBuffer()->isLoading()) { float p = bufferPlayers[i]->getVideoBuffer()->getPercentFull(); ofFill(); ofSetColor(255,255,0,127); ofRect(x,y+camHeight-5,camWidth*p,5); } { ofPushStyle(); float ff = bufferPlayers[i]->getFrame() / (float)bufferPlayers[i]->getSize(); ofSetRectMode(OF_RECTMODE_CENTER); ofSetColor(0,255,0); ofRect(x + camWidth*ff,y+camHeight-2.5,3,10); ofPopStyle(); } { ofPushStyle(); float ff = bufferPlayers[i]->getLoopPointStart() / (float)bufferPlayers[i]->getSize(); ofSetRectMode(OF_RECTMODE_CENTER); ofSetColor(0,0,255); ofRect(x + camWidth*ff,y+camHeight-2.5,3,10); ofPopStyle(); } { ofPushStyle(); float ff = bufferPlayers[i]->getLoopPointEnd() / (float)bufferPlayers[i]->getSize(); ofSetRectMode(OF_RECTMODE_CENTER); ofSetColor(0,0,255); ofRect(x + camWidth*ff,y+camHeight-2.5,3,10); ofPopStyle(); } ofSetColor(255); // draw some stats string stats = bufferPlayers[i]->toString(); ofDrawBitmapString(stats, x + 20, y + 20); x += (camWidth + 0); if((x + 320)> ofGetWidth()) { y+= camHeight + 0; x = 320; } } ofDisableAlphaBlending(); }
//-------------------------------------------------------------- void ofApp::drawScene(bool isPreview){ ofEnableDepthTest(); if (isPreview) { ofPushStyle(); ofSetColor(150, 100, 100); ofDrawGrid(1.0f, 5.0f, true); ofSetColor(255); //-- //draw camera preview // headTrackedCamera.transformGL(); ofPushMatrix(); ofScale(0.002f, 0.002f, 0.002f); ofNode().draw(); ofPopMatrix(); ofMultMatrix(headTrackedCamera.getProjectionMatrix().getInverse()); ofPushStyle(); ofNoFill(); ofDrawBox(2.0f); ofPopStyle(); headTrackedCamera.restoreTransformGL(); // //-- //-- //draw window preview // window.clear(); window.addVertex(windowTopLeft); window.addVertex(windowBottomLeft); window.addVertex(windowBottomRight); window.setMode(OF_PRIMITIVE_LINE_STRIP); window.draw(); glPointSize(3.0f); window.drawVertices(); // //-- } ofPushStyle(); ofNoFill(); ofColor col(200,100,100); for (float z = 0.0f; z > -40.0f; z-= 0.1f){ col.setHue(int(-z * 100.0f + ofGetElapsedTimef() * 10.0f) % 360); ofSetColor(col); ofRect(-windowWidth / 2.0f, -windowHeight / 2.0f, z, windowWidth, windowHeight); } ofPopStyle(); ofPushStyle(); ofEnableSmoothing(); ofSetColor(255); ofSetLineWidth(5.0f); ofBeginShape(); for (unsigned int i=0; i<headPositionHistory.size(); i++) { ofPoint vertex(headPositionHistory[i].x, headPositionHistory[i].y, -float( headPositionHistory.size() - i ) * 0.05f); ofCurveVertex(vertex); } ofEndShape(false); ofPopStyle(); ofDisableDepthTest(); }
//-------------------------------------------------------------- void testApp::draw() { glEnable( GL_DEPTH_TEST ); camera.begin(); ofSetLineWidth(1.f); if(bDrawDebug) world.drawDebug(); ofEnableLighting(); light.enable(); light.setPosition(shapes[0]->getPosition()); ofSetColor(255, 255, 255); shapes[0]->draw(); ofSetColor(100., 100., 100.); if(!bDropBox) { boundsMat.begin(); for(int i = 0; i < bounds.size()-1; i++) { bounds[i]->draw(); } boundsMat.end(); } else { ofNoFill(); boundsShape->transformGL(); ofDrawBox(ofVec3f(0, 0,0), boundsWidth); boundsShape->restoreTramsformGL(); ofFill(); } ofDisableAlphaBlending(); ofDisableBlendMode(); glPushAttrib(GL_ALL_ATTRIB_BITS); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glEnable(GL_NORMALIZE); glDisable(GL_CULL_FACE); ofPoint scale = assimpModel.getScale(); ofSetColor(0, 0, 0); logoMat.begin(); for(int i = 0; i < logos.size(); i++) { logos[i]->transformGL(); ofScale(scale.x,scale.y,scale.z); assimpModel.getMesh(0).drawFaces(); logos[i]->restoreTramsformGL(); } glPopAttrib(); logoMat.end(); ofSetColor(15,197,138); ofPushStyle(); shapesMat.begin(); for(int i = 0; i < shapes.size(); i++) { shapes[i]->draw(); } shapesMat.end(); ofPopStyle(); light.disable(); ofDisableLighting(); camera.end(); glDisable(GL_DEPTH_TEST); int totalShapes = shapes.size() + logos.size(); ofVec3f gravity = world.getGravity(); stringstream ss; ss << "Draw Debug (d): " << bDrawDebug << endl; ss << "Total Shapes: " << totalShapes << endl; ss << "Add logos(o)" << endl; ss << "add spherers (s)" << endl; ss << "add boxes (b)" << endl; ss << "Gravity(up/down/left/right): x=" << gravity.x << " y= " << gravity.y << " z= " << gravity.z << endl; ofSetColor(255, 255, 255); ofDrawBitmapString(ss.str().c_str(), 20, 20); }
//------------------------------------------- void ofxAssimpModelLoader::draw(ofPolyRenderMode renderType) { if(scene == NULL) { return; } ofPushStyle(); if(!ofGetGLProgrammableRenderer()){ #ifndef TARGET_OPENGLES glPushAttrib(GL_ALL_ATTRIB_BITS); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glPolygonMode(GL_FRONT_AND_BACK, ofGetGLPolyMode(renderType)); #endif glEnable(GL_NORMALIZE); } ofPushMatrix(); ofMultMatrix(modelMatrix); for(unsigned int i=0; i<modelMeshes.size(); i++) { ofxAssimpMeshHelper & mesh = modelMeshes[i]; ofPushMatrix(); ofMultMatrix(mesh.matrix); if(bUsingTextures){ if(mesh.hasTexture()) { ofTexture * tex = mesh.getTexturePtr(); if(tex->isAllocated()) { tex->bind(); } } } if(bUsingMaterials){ mesh.material.begin(); } if(mesh.twoSided) { glEnable(GL_CULL_FACE); } else { glDisable(GL_CULL_FACE); } ofEnableBlendMode(mesh.blendMode); #ifndef TARGET_OPENGLES mesh.vbo.drawElements(GL_TRIANGLES,mesh.indices.size()); #else switch(renderType){ case OF_MESH_FILL: mesh.vbo.drawElements(GL_TRIANGLES,mesh.indices.size()); break; case OF_MESH_WIREFRAME: mesh.vbo.drawElements(GL_LINES,mesh.indices.size()); break; case OF_MESH_POINTS: mesh.vbo.drawElements(GL_POINTS,mesh.indices.size()); break; } #endif if(bUsingTextures){ if(mesh.hasTexture()) { ofTexture * tex = mesh.getTexturePtr(); if(tex->isAllocated()) { tex->unbind(); } } } if(bUsingMaterials){ mesh.material.end(); } ofPopMatrix(); } ofPopMatrix(); if(!ofGetGLProgrammableRenderer()){ #ifndef TARGET_OPENGLES glPopClientAttrib(); glPopAttrib(); #endif } ofPopStyle(); }
//-------------------------------------------------------------- void ofApp::draw(){ ofRectangle previewWindow(20, 20, 640, 480); ofRectangle playbackWindow(20+640, 20, 640, 480); // draw the background boxes ofPushStyle(); ofSetColor(0); ofFill(); ofDrawRectangle(previewWindow); ofDrawRectangle(playbackWindow); ofPopStyle(); // draw the preview if available if(vidRecorder->hasPreview()){ ofPushStyle(); ofFill(); ofSetColor(255); // fit it into the preview window, but use the correct aspect ratio ofRectangle videoGrabberRect(0,0,vidGrabber.getWidth(),vidGrabber.getHeight()); videoGrabberRect.scaleTo(previewWindow); vidGrabber.draw(videoGrabberRect); ofPopStyle(); } else{ ofPushStyle(); // x out to show there is no video preview ofSetColor(255); ofSetLineWidth(3); ofDrawLine(20, 20, 640+20, 480+20); ofDrawLine(20+640, 20, 20, 480+20); ofPopStyle(); } // draw the playback video if(recordedVideoPlayback.isLoaded()){ ofPushStyle(); ofFill(); ofSetColor(255); // fit it into the preview window, but use the correct aspect ratio ofRectangle recordedRect(ofRectangle(0,0,recordedVideoPlayback.getWidth(),recordedVideoPlayback.getHeight())); recordedRect.scaleTo(playbackWindow); recordedVideoPlayback.draw(recordedRect); ofPopStyle(); } ofPushStyle(); ofNoFill(); ofSetLineWidth(3); if(vidRecorder->isRecording()){ //make a nice flashy red record color int flashRed = powf(1 - (sin(ofGetElapsedTimef()*10)*.5+.5),2)*255; ofSetColor(255, 255-flashRed, 255-flashRed); } else{ ofSetColor(255,80); } ofDrawRectangle(previewWindow); ofPopStyle(); //draw instructions ofPushStyle(); ofSetColor(255); ofDrawBitmapString("' ' space bar to toggle recording", 680, 540); ofDrawBitmapString("'v' switches video device", 680, 560); ofDrawBitmapString("'a' switches audio device", 680, 580); //draw video device selection ofDrawBitmapString("VIDEO DEVICE", 20, 540); for(int i = 0; i < videoDevices.size(); i++){ if(i == vidRecorder->getVideoDeviceID()){ ofSetColor(255, 100, 100); } else{ ofSetColor(255); } ofDrawBitmapString(videoDevices[i], 20, 560+i*20); } //draw audio device; int startY = 580+20*videoDevices.size(); ofDrawBitmapString("AUDIO DEVICE", 20, startY); startY += 20; for(int i = 0; i < audioDevices.size(); i++){ if(i == vidRecorder->getAudioDeviceID()){ ofSetColor(255, 100, 100); } else{ ofSetColor(255); } ofDrawBitmapString(audioDevices[i], 20, startY+i*20); } ofPopStyle(); }
void Calibration::onDraw(ofEventArgs &data) { if (isVisible()) { // ofPushStyle(); // ofEnableBlendMode(OF_BLENDMODE_ALPHA); // // if(bdrawGrid) // // { // ofSetColor(255, 255, 255, 5); // drawGrid(20,20); // drawDotCalibration(); // // } // ofPopStyle(); if(bDrawWhiteBg) ofRect(0,0,ofGetWidth(), ofGetHeight()); //ps3 image position for calibration float pos_cam_calib_x = windowCenter.x - (ps3eye_texture.getWidth()/2); float pos_cam_calib_y = windowCenter.y - (ps3eye_texture.getHeight()/2) ; if(bDrawWhiteBg) ps3eye_texture.draw( pos_cam_calib_x , pos_cam_calib_y ); warper.begin(); warper.draw(); warper.end(); //ofDrawBitmapString("Calibration Mode: Press \"g\" to hide GUI, Press W to enter Warp Mode", windowCenter.x-300, ofGetHeight()-100); if(bCalibDot) { ofPushStyle(); ofSetColor(255, 0, 0, 255); ofCircle( calibDot.x, calibDot.y, 40); ofPopStyle(); } if (bDebugContour) { for(int i = 0; i < contourFinder.nBlobs; i++) { ofRectangle r = contourFinder.blobs.at(i).boundingRect; ofVec4f pos_w = warper.fromScreenToWarpCoord(pos_cam_calib_x + r.x, pos_cam_calib_y + r.y, 1); float calib_pos_x = (pos_w.x/ps3eye.getWidth()) * ofGetWidth(); float calib_pos_y = (pos_w.y/ps3eye.getHeight()) * ofGetHeight(); printf("blob scaled %f %f\n", calib_pos_x, calib_pos_y); //ofCircle(calib_pos_x, calib_pos_y, 2); ofLine(calib_pos_x, 0.0, calib_pos_x, ofGetHeight()); ofLine(0.0, calib_pos_y, ofGetWidth(), calib_pos_y); } } } }
void ofxTLTrackHeader::draw(){ ofRectangle trackRect = track->getDrawRect(); float footerStartY = trackRect.y + trackRect.height; footerRect = ofRectangle(bounds.x, footerStartY, bounds.width, footerHeight); if(footerRect.width != footerStripeWidth){ recalculateFooterStripes(); } ofPushStyle(); if(track->hasFocus()){ ofFill(); ofSetColor(timeline->getColors().highlightColor, 50); ofRect(bounds.x, bounds.y, bounds.width, bounds.height); } // TODO: set these somewhere else instead of setting it every frame here // set name if it's empty and we're not editing if(nameField.text != track->getDisplayName() && !nameField.getIsEnabled()){ nameField.text = track->getDisplayName(); } if(timeline->areHeadersEditable() && !nameField.getIsEnabled()){ nameField.enable(); } if(!timeline->areHeadersEditable() && nameField.getIsEnabled()){ nameField.disable(); } if(nameField.getIsEditing()){ track->getTimeline()->presentedModalContent(this); } nameField.bounds.x = bounds.x; nameField.bounds.y = bounds.y; ofNoFill(); if(bounds.height == 0){ ofSetColor(getTimeline()->getColors().textColor, 100); } else{ ofSetColor(getTimeline()->getColors().textColor); } if(getTrack()->getDrawRect().height > 0 || bounds.height > 0){ nameField.draw(); } ofSetColor(track->getTimeline()->getColors().outlineColor); ofRect(bounds); //draw grippy lines on the footer draggable element if(footerHeight > 0){ if(draggingSize){ footerStripes.setStrokeColor(track->getTimeline()->getColors().highlightColor); footerStripes.draw(footerRect.x, footerRect.y); } else if(hoveringFooter){ footerStripes.setStrokeColor(track->getTimeline()->getColors().outlineColor); footerStripes.draw(footerRect.x, footerRect.y); } } ofPopStyle(); }
void ofxTLBeatTicker::draw(){ if (!isSetup || disabled) return; ofPushStyle(); int textH, textW; string text; if(viewIsDirty){ refreshTickMarks(); } drawBPMGrid = true; tickerMarks.setStrokeColor( ofColor(0, 0, 240) ); tickerMarks.setStrokeWidth(1); tickerMarks.draw(bounds.x, bounds.y); if(drawBPMGrid){ if(viewIsDirty){ updateBPMPoints(); } ofPushStyle(); ofSetColor(0, 0, 0, 200); ofSetLineWidth(1); int siz = bpmScreenPoints.size(); int howmany; if (siz > 20) howmany = siz / 15; else if (siz > 12) howmany = 4; else howmany = 4; for(int i = 0; i < bpmScreenPoints.size(); i++) { if (isOnScreen(bpmScreenPoints[i].screenX)) { int bi = floor(bpmScreenPoints[i].beat); //if ((bi) % 4 == 1) { // draw bpms indices if ((bi) % howmany == 1) { // draw bpms indices #if DRAW_FXCKING_GRID ofLine(bpmScreenPoints[i].screenX, getBottomEdge(), bpmScreenPoints[i].screenX, totalDrawRect.y+totalDrawRect.height); #endif text = tostr(bi); textW = timeline->getFont().stringWidth(text); timeline->getFont().drawString(text, bpmScreenPoints[i].screenX - textW/2, getBottomEdge()-20); } } } ofPopStyle(); } textH = timeline->getFont().getLineHeight(); textW = 3; //draw current frame int currentFrameX; if (timeline->getIsFrameBased()) { //text = ofToString(timeline->getCurrentFrame()); text = tostr(timeline->millisecToBeat(hoverTime)); currentFrameX = screenXForIndex(timeline->getCurrentFrame()); } else{ //text = timeline->formatTime(timeline->getCurrentTime()); text = tostr(timeline->millisecToBeat(hoverTime)); currentFrameX = screenXForTime(timeline->getCurrentTime()); //currenttimeline->normalizedXtoScreenX(timeline->beatToNormalizedX(currentPoint), zoomBounds); //;timeline->millisToScreenX(timeline->beatToMillisec(measures[0].beat)); } currentFrameX = ofClamp(currentFrameX, bounds.getMinX(), bounds.getMaxX()); //draw playhead line ofSetLineWidth(1); ofLine(currentFrameX, totalDrawRect.y, currentFrameX, totalDrawRect.y+totalDrawRect.height); //text = tostr(timeline->millisecToBeat(hoverTime)+1 - startBeat); unsigned long startBeat = timeline->normalizedXToBeat(zoomBounds.min);// * timeline->getDurationInMilliseconds(); text = tostr( timeline->normalizedXToBeat( screenXtoNormalizedX( millisToScreenX(hoverTime), zoomBounds) ) + 1); //cout << "ofxTLBeatTicker: hoverTime: " << hoverTime << " text:"<< text << endl; float screenX = ofClamp(millisToScreenX(hoverTime), bounds.getMinX(), bounds.getMaxX()); timeline->getFont().drawString(text, screenX, bounds.y+textH+25); ofPopStyle(); }
void update() { #ifdef INSTALL if(cam.update()) { ofPixels& pixels = cam.getColorPixels(); #else cam.update(); if(cam.isFrameNew()) { ofPixels& pixels = cam.getPixelsRef(); #endif // next two could be replaced with one line ofxCv::rotate90(pixels, rotated, rotate ? 270 : 0); ofxCv:flip(rotated, rotated, 1); Mat rotatedMat = toCv(rotated); if(tracker.update(rotatedMat)) { ofVec2f position = tracker.getPosition(); vector<FaceTrackerData*> neighbors = data.getNeighborsCount(position, neighborCount); FaceTrackerData curData; curData.load(tracker); if(!neighbors.empty()) { nearestData = *faceCompare.nearest(curData, neighbors); if(nearestData.label != lastLabel) { similar.loadImage(nearestData.getImageFilename()); #ifdef INSTALL whitePoint = getWhitePoint(similar); #else whitePoint.set(1, 1, 1); #endif } lastLabel = nearestData.label; } if(faceCompare.different(curData, currentData) && faceCompare.different(curData, neighbors)) { saveFace(curData, rotated); currentData.push_back(pair<ofVec2f, FaceTrackerData>(position, curData)); } } presence.update(tracker.getFound()); if(presence.wasTriggered()) { presenceFade.stop(); } if(presence.wasUntriggered()) { for(int i = 0; i < currentData.size(); i++) { data.add(currentData[i].first, currentData[i].second); } currentData.clear(); presenceFade.start(); } } } void draw() { ofBackground(255); CGDisplayHideCursor(NULL); ofSetColor(255); if(similar.isAllocated()) { shader.begin(); shader.setUniformTexture("tex", similar, 0); shader.setUniform3fv("whitePoint", (float*) &whitePoint); similar.draw(0, 0); shader.end(); } ofPushStyle(); if(presenceFade.getActive()) { ofSetColor(0, ofMap(presenceFade.get(), 0, 1, 0, 128)); ofFill(); ofRect(0, 0, ofGetWidth(), ofGetHeight()); ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 32)); data.drawBins(); ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 64)); data.drawData(); } ofSetColor(255, 64); ofNoFill(); if(!tracker.getFound()) { ofCircle(tracker.getPosition(), 10); } tracker.draw(); ofPopStyle(); #ifndef INSTALL drawFramerate(); #endif }
void CloudsVisualSystemPaintBrush::drawPaint(){ canvasDst.begin(); ofClear(0,0); ofPushStyle(); ofDisableDepthTest(); ofEnableAlphaBlending(); // ofSetColor(255, 255); ofSetColor(255, .999999999*255); canvasSrc.draw(0, 0); ofSetColor(255, 255); //MA: replaced ofGetMouseX() with GetCloudsInputX() ofCircle(GetCloudsInputX(), GetCloudsInputY(), 20); // ofSetColor(255, 255, 255, fadeAmount*255); // ofEnableBlendMode(OF_BLENDMODE_SUBTRACT); // ofRect(0,0,canvasDst.getWidth(),canvasDst.getHeight()); ofDisableAlphaBlending(); ofEnableAlphaBlending(); ofSetColor(255); for(int i = particles.size()-1; i >= 0 ; i--){ particles[i].addNoise(ofGetElapsedTimef(), particlesTurbulence); particles[i].update(); if (particles[i].getVel().length() < 1.0 ){ particles.erase(particles.begin()+i); } else { particles[i].draw(); particles[i].trail.draw(); } } vector<int> toRemove; for (map<int, Brush *>::iterator it = brushes.begin(); it != brushes.end(); it++) { Brush * brush = it->second; if (brush->bDown) { brush->draw(); } else { toRemove.push_back(it->first); } } ofPopStyle(); canvasDst.end(); swap(canvasSrc, canvasDst); while(particles.size() > 500) { particles.erase(particles.begin()); } // get rid of any idle brushes for (int i = 0; i < toRemove.size(); i++) { delete brushes[toRemove[i]]; brushes.erase(toRemove[i]); } }
void AudioSample::draw(float x, float y, float w, float h) { ofPushStyle(); ofPushMatrix(); ofTranslate(x, y+(h/2)); ofSetColor(0,255,0); ofNoFill(); ofSetLineWidth(1); //ofLine(x,y+h/2,x+w,y+h/2); ofBeginShape(); //ofVertex(x+w,y+h/2); //ofVertex(x,y+h/2); for(int i = 0; i<samples.size(); i++) { int sampleindex = ((i-numSamples+1)+absolutePosition) %numSamples; float sample = 0; if(sampleindex>=0) sample = samples[sampleindex]; ofVertex(ofMap(i,0,numSamples, 0, w), ofMap(sample, -1,1,-h/2,h/2)); } ofEndShape(false); /* if(volumesUpdated) { ofFill(); ofSetColor(0,100,100); ofBeginShape(); for(int i = 0; i<volumes.size(); i++) { int volumeindex = ((i-numSamples+1)+absolutePosition) %numSamples; float volume = 0; if(volumeindex>=0) volume = volumes[volumeindex]; ofVertex(ofMap(i,0,numSamples, 0, w), ofMap(volume, 0,1,h/2, 0)); } for(int i = volumes.size()-1; i<=0; i++) { int volumeindex = ((i-numSamples+1)+absolutePosition) %numSamples; float volume = 0; if(volumeindex>=0) volume = volumes[volumeindex]; ofVertex(ofMap(i,0,numSamples, 0, w), ofMap(volume, 0,1,h/2, h)); } ofEndShape(true); } */ ofPopMatrix(); ofPopStyle(); }
void ofxRGBDCaptureGui::draw(ofEventArgs& args){ if(fullscreenPoints && currentTab == TabPlayback){ drawPointcloud(depthSequence.currentDepthRaw, true); return; } bool drawCamera = providerSet && depthImageProvider->deviceFound(); if(currentTab == TabCalibrate){ if(!drawCamera){ ofPushStyle(); ofSetColor(255, 0, 0); ofDrawBitmapString("Camera not found. Plug and unplug the device and restart the application.", previewRect.x + 30, previewRect.y + 30); ofPopStyle(); } else{ depthImageProvider->getRawIRImage().draw(previewRect); calibrationPreview.draw(0, btnheight*2); alignment.drawDepthImages(); } } else if(currentTab == TabRecord){ if(!drawCamera){ ofPushStyle(); ofSetColor(255, 0, 0); ofDrawBitmapString("Camera not found. Plug and unplug the device and restart the application.", previewRect.x + 30, previewRect.y + 30); ofPopStyle(); } else{ if( currentRenderMode == RenderPointCloud){ drawPointcloud(depthImageProvider->getRawDepth(), false); } else{ ofPushStyle(); ofSetColor(255, 255, 255, 60); ofLine(320, btnheight*2, 320, btnheight*2+480); ofLine(0, btnheight*2+240, 640, btnheight*2+240); ofPopStyle(); //depthImageProvider->getDepthImage().draw(previewRect); depthImage.draw(previewRect); } } } else if(currentTab == TabPlayback) { if(currentRenderMode == RenderPointCloud){ drawPointcloud(depthSequence.currentDepthRaw, false); } else { updateDepthImage(depthSequence.currentDepthRaw); depthImage.draw(previewRect); } //draw timeline timeline.draw(); } if(currentTabObject != NULL){ ofPushStyle(); ofRectangle highlightRect = ofRectangle(currentTabObject->x,currentTabObject->y+currentTabObject->height*.75, currentTabObject->width,currentTabObject->height*.25); ofSetColor(timeline.getColors().highlightColor); ofRect(highlightRect); ofPopStyle(); } if(currentRenderModeObject != NULL){ ofPushStyle(); ofRectangle highlightRect = ofRectangle(currentRenderModeObject->x,currentRenderModeObject->y+currentRenderModeObject->height*.75, currentRenderModeObject->width,currentRenderModeObject->height*.25); ofSetColor(timeline.getColors().highlightColor); ofRect(highlightRect); ofPopStyle(); } for(int i = 0; i < btnTakes.size(); i++){ if(btnTakes[i].isSelected){ ofPushStyle(); ofSetColor(timeline.getColors().highlightColor); ofRectangle highlighRect(btnTakes[i].button->x,btnTakes[i].button->y, btnTakes[i].button->width, btnTakes[i].button->height*.25); ofRect(highlighRect); ofPopStyle(); } ofPushStyle(); ofSetColor(timeline.getColors().disabledColor); float percentComplete = float(btnTakes[i].takeRef->framesConverted) / float(btnTakes[i].takeRef->numFrames); float processedWidth = btnTakes[i].button->width*percentComplete; ofRectangle highlighRect(btnTakes[i].button->x + processedWidth, btnTakes[i].button->y, btnTakes[i].button->width-processedWidth, btnTakes[i].button->height); ofRect(highlighRect); ofPopStyle(); } //draw save meter if buffer is getting full if(recorder.isRecording()){ ofPushStyle(); ofSetColor(255, 0, 0); ofNoFill(); ofSetLineWidth(5); ofRect(previewRect); ofPopStyle(); } if(recorder.numFramesWaitingSave() > 0){ ofPushStyle(); float width = recorder.numFramesWaitingSave()/2000.0 * btnRecordBtn->width; ofFill(); ofSetColor(255,0, 0); ofRect(btnRecordBtn->x,btnRecordBtn->y,width,btnRecordBtn->height); if(ofGetFrameNum() % 30 < 15){ ofSetColor(255, 0, 0, 40); ofRect(*btnRecordBtn); } ofPopStyle(); } }
//-------------------------------------------------------------- void ofApp::update(){ deltaTime = ofGetElapsedTimef() - lastTime; lastTime = ofGetElapsedTimef(); simpleCam.update(); if (simpleCam.isFrameNew()) { ofPushStyle(); ofEnableBlendMode(OF_BLENDMODE_DISABLED); cameraFbo.begin(); if (doFlipCamera) simpleCam.draw(cameraFbo.getWidth(), 0, -cameraFbo.getWidth(), cameraFbo.getHeight()); // Flip Horizontal else simpleCam.draw(0, 0, cameraFbo.getWidth(), cameraFbo.getHeight()); cameraFbo.end(); ofPopStyle(); opticalFlow.setSource(cameraFbo.getTexture()); opticalFlow.update(deltaTime); velocityMask.setDensity(cameraFbo.getTexture()); velocityMask.setVelocity(opticalFlow.getOpticalFlow()); velocityMask.update(); } fluidSimulation.addVelocity(opticalFlow.getOpticalFlowDecay()); fluidSimulation.addDensity(velocityMask.getColorMask()); fluidSimulation.addTemperature(velocityMask.getLuminanceMask()); mouseForces.update(deltaTime); for (int i=0; i<mouseForces.getNumForces(); i++) { if (mouseForces.didChange(i)) { switch (mouseForces.getType(i)) { case FT_DENSITY: fluidSimulation.addDensity(mouseForces.getTextureReference(i), mouseForces.getStrength(i)); break; case FT_VELOCITY: fluidSimulation.addVelocity(mouseForces.getTextureReference(i), mouseForces.getStrength(i)); particleFlow.addFlowVelocity(mouseForces.getTextureReference(i), mouseForces.getStrength(i)); break; case FT_TEMPERATURE: fluidSimulation.addTemperature(mouseForces.getTextureReference(i), mouseForces.getStrength(i)); break; case FT_PRESSURE: fluidSimulation.addPressure(mouseForces.getTextureReference(i), mouseForces.getStrength(i)); break; case FT_OBSTACLE: fluidSimulation.addTempObstacle(mouseForces.getTextureReference(i)); default: break; } } } fluidSimulation.update(); if (particleFlow.isActive()) { particleFlow.setSpeed(fluidSimulation.getSpeed()); particleFlow.setCellSize(fluidSimulation.getCellSize()); particleFlow.addFlowVelocity(opticalFlow.getOpticalFlow()); particleFlow.addFluidVelocity(fluidSimulation.getVelocity()); // particleFlow.addDensity(fluidSimulation.getDensity()); particleFlow.setObstacle(fluidSimulation.getObstacle()); } particleFlow.update(); }