//-------------------------------------------------------------- void ofApp::draw() { ofBackground(backColor); ofPushStyle(); // These are the different playmodes See the Functions for their descriptions if (playbackMode == 0) { // Default playOneBufferTriggered(); } else if (playbackMode == 1) { // Default Plus Live Image playLiveImageWithBufferTriggered(); } else if (playbackMode == 2) { // Dream State 1 - Day Dreaming playAllBuffersLayered(); } else if (playbackMode == 3) { // Dream State 2 - Sequential Dreaming playBuffersWithNoOneThere(); } else if (playbackMode == 4) { // Default Sequential playAllBuffersSequentiallyTriggered(); } else if (playbackMode == 5) { // Delayed Shadow playSlowShadow(); } else if (playbackMode == 6) { // Shadow Reversed playSlowMirroredShadow(); } else { // Nothing } ofPopStyle(); if (drawMask) { ofEnableAlphaBlending(); ofSetColor(255, 255); masks[whichMask].draw(0,0,ofGetWidth(),ofGetHeight()); ofDisableAlphaBlending(); } ofPushStyle(); // Draw all the CV Stuff if(drawCV == true) { openCV.draw(); } // Draw only the Live input in Grayscale if(drawLiveImage == true) { openCV.drawLive(); } ofPopStyle(); ofPushStyle(); // Show the previous Buffers if (showPreviousBuffers) { // Draw the Mini Buffers if (!buffers.empty()) { for (int i = 0; i < buffers.size(); i++) { buffers[i].drawMini(0, 0+(i*240/4)); } } } ofPopStyle(); // Debug for information about the buffers and openCV if (canDrawData == true) { drawData(); } }
void Firefly::changeDir() { followPoint.x = ofRandom(ofGetWidth()); followPoint.y = ofRandom(ofGetHeight()); }
void ShaderToy::setup() { texture.allocate(ofGetWidth(),ofGetHeight(),GL_RGBA); shader.load("shaders/shadertoy"); }
void testApp::handleAnchorsUpdate(SConnection *_connection) { if (_connection == NULL) return; if (_connection->fromAnchor() != NULL && _connection->toAnchor() != NULL) { SmurfAnchor *fromAnchor = _connection->fromAnchor(); if (fromAnchor == NULL) return; float fSid = fromAnchor->getOwnerSid(); if (fSid == -FLT_MAX) return; Smurf *from = smurfFloor->brain->findSmurf(fSid); if (from == NULL || from->getTuio() == NULL) return; ofxTuioPoint *fromPt = new ofxTuioPoint( from->getTuio()->getPosition().getX(), from->getTuio()->getPosition().getY() ); SmurfAnchor *toAnchor = _connection->toAnchor(); if (toAnchor == NULL) return; float tSid = toAnchor->getOwnerSid(); if (tSid == -FLT_MAX) return; Smurf *to = smurfFloor->brain->findSmurf(tSid); if (to == NULL || to->getTuio() == NULL) return; ofxTuioPoint *toPt = new ofxTuioPoint( to->getTuio()->getPosition().getX(), to->getTuio()->getPosition().getY() ); float angle = PI-fromPt->getAngle(toPt); ((ofxTuioObject*)fromAnchor->getTuio())->update( fromPt->getX()+cosf(angle)*((from->getRadius()+1)/ofGetWidth()), fromPt->getY()+sinf(angle)*((from->getRadius()+1)/ofGetHeight()), ((ofxTuioObject*)fromAnchor->getTuio())->getAngle(), fromAnchor->getTuio()->getXSpeed(), fromAnchor->getTuio()->getYSpeed(), 0.0f, fromAnchor->getTuio()->getMotionSpeed(), fromAnchor->getTuio()->getMotionAccel() ); ((ofxTuioObject*)toAnchor->getTuio())->update( toPt->getX()-cosf(angle)*((to->getRadius()+1)/ofGetWidth()), toPt->getY()-sinf(angle)*((to->getRadius()+1)/ofGetHeight()), ((ofxTuioObject*)toAnchor->getTuio())->getAngle(), toAnchor->getTuio()->getXSpeed(), toAnchor->getTuio()->getYSpeed(), 0.0f, toAnchor->getTuio()->getMotionSpeed(), toAnchor->getTuio()->getMotionAccel() ); delete fromPt; delete toPt; } }
//-------------------------------------------------------------- void testApp::keyPressed (int key){ switch(key) { case ' ': gui.toggleDraw(); glClear(GL_COLOR_BUFFER_BIT); break; case 'f': ofToggleFullscreen(); break; case 'p': static char fileNameStr[255]; sprintf(fileNameStr, "output_%0.4i.png", ofGetFrameNum()); static ofImage imgScreen; imgScreen.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); printf("Saving file: %s\n", fileNameStr); imgScreen.saveImage(fileNameStr); break; case 'q': if (smurfFloor->getBPM() <= 295) { // really quicken the beat // In my case just got the griffin knob linked to this smurfFloor->setBPM(smurfFloor->getBPM()+5); } break; case 's': if (smurfFloor->getBPM() > 5 ) { // really slow down the beat // In my case just got the griffin knob linked to this smurfFloor->setBPM(smurfFloor->getBPM()-5); } break; case 'a': if (smurfFloor->getBPM() <= 299) { // quicken the beat // In my case just got the griffin knob linked to this smurfFloor->setBPM(smurfFloor->getBPM()+1); } break; case 'z': if (smurfFloor->getBPM() > 1) { // slow down the beat // In my case just got the griffin knob linked to this smurfFloor->setBPM(smurfFloor->getBPM()-1); } break; case 'h': // help smurfFloor->setVerbose(smurfFloor->isVerbose()?false:true); break; #ifdef TARGET_OS_MAC case 'g': // gesture smurfFloor->toggleGesture(); break; #endif case 'c': // gesture smurfFloor->toggleConnectionMode(); break; case 'w': // wave if (smurfFloor->getWaveSpeed() > 1) { smurfFloor->setWaveSpeed(smurfFloor->getWaveSpeed()-1); } break; case 'x': // wave if (smurfFloor->getWaveSpeed() <= 20) { smurfFloor->setWaveSpeed(smurfFloor->getWaveSpeed()+1); } break; } }
//-------------------------------------------------------------- void testApp::draw(){ tex.draw(0,0, ofGetWidth(), ofGetHeight()); }
//------------------------------- void ofxControlPanel::draw(){ if( hidden ) return; ofPushStyle(); ofEnableAlphaBlending(); float panelH = boundingBox.height; if( minimize ){ panelH = topBar.height; } glPushMatrix(); glTranslatef(boundingBox.x, boundingBox.y, 0); //draw the background ofFill(); glColor4fv(bgColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); //draw the outline ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); ofLine(0, topBar.height, boundingBox.width, topBar.height); glPopMatrix(); ofRect(minimizeButton.x, minimizeButton.y, minimizeButton.width, minimizeButton.height); ofPushStyle(); ofFill(); if( saveDown )glColor4fv(fgColor.getSelectedColorF()); else glColor4fv(fgColor.getColorF()); ofRect(saveButton.x, saveButton.y, saveButton.width,saveButton.height); ofSetColor(255, 255, 255); if(bUseTTFFont) { guiTTFFont.drawString("save", saveButton.x + 3, saveButton.y + saveButton.height -4); } else { ofDrawBitmapString("save", saveButton.x + 3, saveButton.y + saveButton.height -3); } ofPopStyle(); ofPushStyle(); ofFill(); if( restoreDown )glColor4fv(fgColor.getSelectedColorF()); else glColor4fv(fgColor.getColorF()); ofRect(restoreButton.x, restoreButton.y, restoreButton.width,restoreButton.height); ofSetColor(255, 255, 255); if(bUseTTFFont) { guiTTFFont.drawString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -4); } else { ofDrawBitmapString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -3); } ofPopStyle(); ofPushMatrix(); ofTranslate(2,0,0); glColor4fv(textColor.getColorF()); guiBaseObject::renderText(); ofPopMatrix(); if( !minimize ){ //don't let gui elements go out of their panels glEnable(GL_SCISSOR_TEST); glScissor(boundingBox.x, ofGetHeight() - ( boundingBox.y + boundingBox.height - (-2 + topSpacing) ), boundingBox.width - borderWidth , boundingBox.height); for(int i = 0; i < (int) panelTabs.size(); i++){ if( i == selectedPanel){ ofPushStyle(); ofFill(); glColor4fv(fgColor.getSelectedColorF()); ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); glColor4fv(outlineColor.getColorF()); ofPopStyle(); } glColor4fv(outlineColor.getColorF()); ofNoFill(); ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); } glPushMatrix(); glTranslatef(hitArea.x, hitArea.y, 0); for(int i = 0; i < (int) panels.size(); i++){ if( i == selectedPanel )panels[i]->render(); } glPopMatrix(); glDisable(GL_SCISSOR_TEST); } ofPopStyle(); }
//-------------------------------------------------------------- void testApp::update(){ for (int i = 0; i < particles.size(); i++){ particles[i].resetForce(); } for (int i = 0; i < particles.size(); i++){ particles[i].addAttractionForce(-500, particles[i].initialY, 2000, 2); //particles[i].addRepulsionForce(mouseX, mouseY, 125, 2.5); // get the force from the vector field: ofVec2f frc; frc = VF.getForceFromPos(particles[i].pos.x, particles[i].pos.y); particles[i].addForce(frc.x, frc.y); for (int j = 0; j < i; j++){ particles[i].addRepulsionForce(particles[j], 50, 0.4); } } for (int i = 0; i < particles.size(); i++){ //particles[i].addCounterClockwiseForce(mouseX, mouseY, 1000, 0.1); //particles[i].addClockwiseForce(mouseX, mouseY, 200, 1); //if (particles[i].magic) { if (i % 20 == 0){ //particles[i].magic) { ofVec2f vel = particles[i].vel; vel.normalize(); VF.addVectorCircle(particles[i].pos.x, particles[i].pos.y, vel.x * 0.2, vel.y * 0.2, 60, 1.3) ; //VF.addInwardCircle(particles[i].pos.x, particles[i].pos.y, 150, 0.4) ; VF.addInwardCircle(particles[i].pos.x, particles[i].pos.y, 150, 0.7) ; //particles[i].addAttractionForce(-500, particles[i].initialY, 2000, 5); } particles[i].addDampingForce(); particles[i].update(); if (particles[i].pos.x < 0) { particles[i].setInitialCondition(ofGetWidth(), ofRandom(ofGetHeight()), -10, 0); if (ofGetElapsedTimef() - timer > 1) { timer = ofGetElapsedTimef(); particles[i].magic = true; } } } if (ofGetElapsedTimef() - recordTimer > (1/2)) { recordTimer = ofGetElapsedTimef(); if (recording) savePDF = true; } //VF.fadeField(0.99f); VF.fadeField(0.91f); }
//-------------------------------------------------------------- void ofApp::draw(){ ofBackground(0, 0, 0); ofDrawBitmapStringHighlight("Rot :"+ofToString(view.getRotate()), 10, 500); ofMatrix4x4 headView; headView = tracking.getLastHeadView(transform.getHeadView()); ofMatrix4x4 translate; translate.makeTranslationMatrix(ofVec3f(0.06, 0, 0)); view.makeIdentityMatrix(); view=headView*translate; transform.setMatrix(view); ofSetColor(255, 0, 255); ofDrawBitmapStringHighlight("HeadView: "+ofToString(transform.getHeadView(), 10), 10, 100); ofDrawBitmapStringHighlight("Gyro :" + ofToString(tracking.mTracker.getLastGyro()), 10, 200); ofDrawBitmapStringHighlight("Accel :"+ofToString(tracking.mTracker.getLastAccel()), 10, 300); node.setTransformMatrix(view); cam.setOrientation(node.getOrientationQuat()); // cam.setOrientation(rot*cam.getOrientationQuat()); ofSetColor(255, 0, 255); ofDrawBitmapStringHighlight("HeadView: "+ofToString(transform.getHeadView(), 10), 10, 100); ofDrawBitmapStringHighlight("Gyro :" + ofToString(tracking.mTracker.getLastGyro()), 10, 200); ofDrawBitmapStringHighlight("Accel :"+ofToString(tracking.mTracker.getLastAccel()), 10, 300); ofDrawBitmapStringHighlight("Rot :"+ofToString(view.getRotate()), 10, 400); ofDrawBitmapStringHighlight("Cardboard Camera", ofGetWidth()-ofGetHeight(), ofGetHeight()/2-20); cam.begin(ofRectangle(ofGetWidth()-ofGetHeight(), ofGetHeight()/2, ofGetHeight()/2, ofGetHeight()/2)); ofSetColor(255, 0, 255); ofPushMatrix(); // ofVec3f axis; // float angle; // rot.getRotate(angle, axis); // ofRotate(angle, axis.x, axis.y, axis.z); planet.drawWireframe(); ofSetColor(255, 255, 0); ofDrawBox(50, 0, 0, 10, 10, 10); ofDrawBox(0, 50, 0, 10, 10, 10); ofDrawBox(0, 0, 50, 10, 10, 10); ofDrawBox(0, 50, 50, 10, 10, 10); ofDrawBox(50, 50, 50, 10, 10, 10); ofDrawBox(-50, 0, 0, 10, 10, 10); ofDrawBox(0, -50, 0, 10, 10, 10); ofDrawBox(0, 0, -50, 10, 10, 10); ofDrawBox(0, -50, -50, 10, 10, 10); ofDrawBox(-50, -50, -50, 10, 10, 10); ofPopMatrix(); cam.end(); ofDrawBitmapStringHighlight("EasyCam View", ofGetWidth()-ofGetHeight()/2, ofGetHeight()/2-20); easycam.lookAt(node); easycam.begin(ofRectangle(ofGetWidth()-ofGetHeight()/2, ofGetHeight()/2, ofGetHeight()/2, ofGetHeight()/2)); node.draw(); easycam.end(); easycam.lookAt(cam); easycam.begin(ofRectangle(ofGetWidth()-ofGetHeight()/2, 0, ofGetHeight()/2, ofGetHeight()/2)); cam.draw(); easycam.end(); }
//-------------------------------------------------------------- void ofApp::setup(){ cam.setDesiredFrameRate(30); cam.setDeviceID(1); cam.initGrabber(ofGetWidth(), ofGetHeight()); }
//-------------------------------------------------------------- void testApp::draw(){ if(loader.isAllocated() && !playerSetup){ loader.draw(0,0, ofGetWidth(), ofGetHeight()); } firstFrame = false; }
//-------------------------------------------------------------- void testApp::draw(){ ofBackground(0); ofSetColor(255); ofSetLineWidth(2.0); ofPushMatrix(); { // ofDrawBitmapString("Press 'f' for filter UI", 20, 20); ofTranslate(titleWidth, 0); ofSetColor(0x65, 0xb4, 0xad); wave1.draw(); ofTranslate(-titleWidth, 0); roboto.drawString("Inner", 10, (1 * (ofGetHeight() / 6)) / 2); ofSetColor(255); ofTranslate(titleWidth, ofGetHeight() / 6); ofSetColor(0x91, 0xc3, 0xae); wave2.draw(); ofTranslate(-titleWidth, 0); roboto.drawString("Metropolitan", 10, (1 * (ofGetHeight() / 6)) / 2); ofSetColor(255); ofTranslate(titleWidth, ofGetHeight() / 6); ofSetColor(0xdb, 0xd5, 0xa9); wave3.draw(); ofTranslate(-titleWidth, 0); roboto.drawString("Greater - North", 10, (1 * (ofGetHeight() / 6)) / 2); ofSetColor(255); ofTranslate(titleWidth, ofGetHeight() / 6); ofSetColor(0xf1, 0xa5, 0xa2); wave4.draw(); ofTranslate(-titleWidth, 0); roboto.drawString("Greater - South", 10, (1 * (ofGetHeight() / 6)) / 2); ofSetColor(255); ofTranslate(titleWidth, ofGetHeight() / 6); ofSetColor(0xea, 0x5b, 0xa6); wave5.draw(); ofTranslate(-titleWidth, 0); roboto.drawString("Greater - East", 10, (1 * (ofGetHeight() / 6)) / 2); ofSetColor(255); ofTranslate(titleWidth, ofGetHeight() / 6); ofSetColor(0xb0, 0xd4, 0xb0); wave6.draw(); ofTranslate(-titleWidth, 0); roboto.drawString("Greater - West", 10, (1 * (ofGetHeight() / 6)) / 2); ofSetColor(255); } ofPopMatrix(); }
void TitleScreen::draw( int iScaler, ofTrueTypeFont _font, bool bIsLefty, bool bUsingController ) { ofTrueTypeFont helvetica; helvetica = _font; if ( iWhichPrototype < 1 ) { iWhichPrototype = 8; } if ( iWhichPrototype > 8 ) { iWhichPrototype = 1; } ofSetRectMode( OF_RECTMODE_CORNER ); ofSetColor( 0 ); helvetica.drawString( "Hello! Welcome to Protoville, home of the prototype.", ofGetWidth() / 2 - iScaler * 16.5, iScaler * 3 ); if ( !bChoseControls ) { helvetica.drawString( "Please choose your control affiliation.", ofGetWidth() / 2 - iScaler * 12, iScaler * 5 ); } else { helvetica.drawString( "Please choose your awesome prototype.", ofGetWidth() / 2 - iScaler * 12, iScaler * 7 ); } //-------------------- if ( !bChoseControls ) { if ( bIsLefty) { ofSetColor( 0 ); } else { ofSetColor( 0 ); ofRect( ofGetWidth() / 2 - iScaler * 11.5, ofGetHeight() / 2 - iScaler * 1.5, iScaler * 22, iScaler * 2 ); ofSetColor( 255 ); } helvetica.drawString( "I am so dextrous (right-handed).", ofGetWidth() / 2 - iScaler * 11, ofGetHeight() / 2 ); if ( bIsLefty) { ofSetColor( 0 ); ofRect( ofGetWidth() / 2 - iScaler * 11.5, ofGetHeight() / 2 + iScaler * 0.75, iScaler * 22, iScaler * 2 ); ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "I feel quite sinister (left-handed).", ofGetWidth() / 2 - iScaler * 11, ofGetHeight() / 2 + iScaler * 2 ); } else { ofPushMatrix();{ ofTranslate( -iScaler * 6, -iScaler * 2 ); ofSetColor( 0 ); ofRect( ofGetWidth() / 2 - iScaler * 0.65, ofGetHeight() / 2 - iScaler * 1.5 + iScaler * 2 * ( iWhichPrototype - 1 ), iScaler * 14.5, iScaler * 2 ); if ( iWhichPrototype == 1 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto1: Tutorial", ofGetWidth() / 2, ofGetHeight() / 2 ); if ( iWhichPrototype == 2 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto2: Boss", ofGetWidth() / 2, ofGetHeight() / 2 + iScaler * 2 ); if ( iWhichPrototype == 3 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto3: Piano groove", ofGetWidth() / 2, ofGetHeight() / 2 + iScaler * 4 ); if ( iWhichPrototype == 4 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto4: Flight!", ofGetWidth() / 2, ofGetHeight() / 2 + iScaler * 6 ); if ( iWhichPrototype == 5 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto5: Solo!", ofGetWidth() / 2, ofGetHeight() / 2 + iScaler * 8 ); if ( iWhichPrototype == 6 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto6: Solo--gym", ofGetWidth() / 2, ofGetHeight() / 2 + iScaler * 10 ); if ( iWhichPrototype == 7 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto7: Surfin' USA", ofGetWidth() / 2, ofGetHeight() / 2 + iScaler * 12 ); if ( iWhichPrototype == 8 ) { ofSetColor( 255 ); } else { ofSetColor( 0 ); } helvetica.drawString( "Proto8: Learn to Surf", ofGetWidth() / 2, ofGetHeight() / 2 + iScaler * 14 ); }ofPopMatrix(); } //-------------------- ofSetColor( 0 ); ofPushMatrix();{ ofTranslate( ofGetWidth() / 2 + iScaler * 18, ofGetHeight() / 2 + iScaler ); helvetica.drawString( "[^]", 0, 0 ); ofRotate( 180 ); helvetica.drawString( "[^]", float( iScaler * 0.6 ), float( iScaler * 0.68 ) ); }ofPopMatrix(); helvetica.drawString( "Headphones recommended.", ofGetWidth() /2 - iScaler * 9, ofGetHeight() - iScaler * 5 ); string sContinue; if ( bUsingController == true ) { sContinue = "A"; } else { sContinue = "ENTER"; } helvetica.drawString( "Press " + sContinue + " to continue.", ofGetWidth() /2 - iScaler * 8.75, ofGetHeight() - iScaler * 3 ); }
//-------------------------------------------------------------- void testApp::draw(){ ofBackground(0); ofSetColor(255); // drawString(500,500, "this is at est!"); string s = ofToString(mouseX) + "/" + ofToString(mouseY) + " : " + ofToString(ofGetWidth()) + "/" + ofToString(ofGetHeight()); string si = "i=" + ofToString(i); string sf = "f=" + ofToString(f); ofDrawBitmapString(si, i+10,i+15); ofLine(i, 0, i, ofGetHeight()); ofLine(0, i, ofGetWidth(), i); // ofEnableSmoothing(); ofDrawBitmapString(sf, f+10,f+15); ofLine(f, 0, f, ofGetHeight()); ofLine(0, f, ofGetWidth(), f); // ofDisableSmoothing(); ofSetColor(255); ofFill(); ofDrawBitmapString(s, mouseX, mouseY-10); ofSetColor(0,255,0); ofLine(mouseX, 0, mouseX, ofGetHeight()); ofLine(0, mouseY, ofGetWidth(), mouseY); ofRect(100, 100, 100, 100); ofSetColor(255,100); ofNoFill(); ofPushMatrix(); ofTranslate(10, i+10); ofRect(0, 0, 100, 100); // ofRect(400, 400, 100, 100); ofPopMatrix(); ofPushMatrix(); ofTranslate(i+10, 400); ofRect(0, 0, 100, 100); // ofRect(400, 400, 100, 100); ofPopMatrix(); ofSetColor(255,0,0); ofSetLineWidth(1); float line_vertex[]= { (int)(i+32),(int)0,(int)(i+32),(int)ofGetHeight() }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, line_vertex); glDrawArrays(GL_LINES, 0, 2); float line_vertex2[]= { (int)(i+35),(int)0,(int)(i+35),(int)ofGetHeight() }; ofSetColor(0,255,0); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, line_vertex2); glDrawArrays(GL_LINES, 0, 2); float line_vertex3[]= { (int)0, (int)(i+32),(int)ofGetWidth(),(int)(i+32) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, line_vertex3); glDrawArrays(GL_LINES, 0, 2); float line_vertex4[]= { (int)0, (int)(i+35),(int)ofGetWidth(),(int)(i+35) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, line_vertex4); glDrawArrays(GL_LINES, 0, 2); }
void SceneWave::update() { // mScopeMappingInterpreter->getWavePoints(mSamples[0], mPts, ofRectangle(0, ofGetHeight()/2, ofGetWidth(), ofGetHeight()/2)); mRectangle.set(0, 0, ofGetWidth(), ofGetHeight()); }
void lineScene::setup(openNIManager * _oni, flowManager * _flow ){ oni = _oni; flow = _flow; width = 1920; height = 1080; bDrawMoire = true; bDrawBody = true; distanceScale = 10; lineWidth = 2; lineLength = linesLength = 1000; llArm = true; rlArm = true; luArm = true; ruArm = true; llLeg = true; rlLeg = true; luLeg = true; ruLeg = true; // bgColor.set(0.0); lineColor.set(1.0); //init gui dims float dim = 16; float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; float length = 255-xInit; //gui! gui = new ofxUICanvas(0, 0, length+xInit, ofGetHeight()); gui->addFPSSlider("FPS SLIDER", length-xInit, dim*.25, 60); gui->addSpacer(length-xInit, 1); gui->addSlider("lineWidth", 0.1, 10, &lineWidth, length-xInit, dim); gui->addSlider("lineLength", 1, 2000, &lineLength, length-xInit, dim); gui->addSlider("linesWidth", 0.1, 10, &linesWidth, length-xInit, dim); gui->addSlider("linesLength", 1, 2000, &linesLength, length-xInit, dim); gui->addSlider("distanceScale", 0.1, 1.0, &distanceScale, length-xInit, dim); gui->addSpacer(length-xInit, 1); gui->addLabelToggle("drawBody", &bDrawBody); gui->addLabelToggle("drawMoire", &bDrawMoire); gui->addSpacer(length-xInit, 1); gui->addLabelToggle("llArm", &llArm); gui->addLabelToggle("rlArm", &rlArm); gui->addLabelToggle("luArm", &luArm); gui->addLabelToggle("ruArm", &ruArm); gui->addLabelToggle("llLeg", &llLeg); gui->addLabelToggle("rlLeg", &rlLeg); gui->addLabelToggle("luLeg", &luLeg); gui->addLabelToggle("ruLeg", &ruLeg); gui->addSpacer(length-xInit, 1); gui->addLabel("LINES"); gui->addSlider("red", 0.0, 1.0, &lineColor.r, length-xInit, dim); gui->addSlider("green", 0.0, 1.0, &lineColor.g, length-xInit, dim); gui->addSlider("blue", 0.0, 1.0, &lineColor.b, length-xInit, dim); gui->addSlider("alpha", 0.0, 1.0, &lineColor.a, length-xInit, dim); gui->setDrawBack(false); gui->setVisible(false); }
SceneWave::SceneWave() { mRectangle.set(0, 0, ofGetWidth(), ofGetHeight()); }
void ShadersState::mouseDragged(int x, int y, int button){ xRot = y / (float)ofGetHeight() * 360; yRot = x / (float)ofGetWidth() * 360; }
//-------------------------------------------------------------- void testApp::update() { int i; float x = 100; float y = (int)( ofGetHeight() * 0.5 ); float w = ofGetWidth() - 200; float h = 200; float d = 140; for( int i=0; i<RIBBON_MAX_LENGTH; i++ ) { float p = i / (float)( RIBBON_MAX_LENGTH - 1 ); float z = d * sin( p * 2 * PI ); rps[ i * 3 + 0 ] = x + w * p; rps[ i * 3 + 1 ] = y; rps[ i * 3 + 2 ] = z; float cl = 0.7; rcl[ i * 4 + 0 ] = cl; rcl[ i * 4 + 1 ] = cl; rcl[ i * 4 + 2 ] = cl; rcl[ i * 4 + 3 ] = cl; rcl[ i * 4 + 4 ] = cl; rcl[ i * 4 + 5 ] = cl; rcl[ i * 4 + 6 ] = cl; rcl[ i * 4 + 7 ] = cl; } ribbonRotation = 2 * sin( ++ribbonRotationCount / 1000 * PI ); ofxVec3f upAxis = ofxVec3f( 0, 1, 0 ); for( int i=0; i<RIBBON_MAX_LENGTH; i++ ) { if( i < RIBBON_MAX_LENGTH - 1 ) { float t0x = rps[ i * 3 + 0 ]; // xyz position of 1st trail point. float t0y = rps[ i * 3 + 1 ]; float t0z = rps[ i * 3 + 2 ]; float t1x = rps[ i * 3 + 3 ]; // xyz position of 2nd trail point. float t1y = rps[ i * 3 + 4 ]; float t1z = rps[ i * 3 + 5 ]; ofxVec3f t0 = ofxVec3f( t0x, t0y, t0z ); // position vector of 1st trail point. ofxVec3f t1 = ofxVec3f( t1x, t1y, t1z ); // position vector of 2nd trail point. ofxVec3f v1 = t0 - t1; v1.normalize(); ofxVec3f ya = ofxVec3f( upAxis ); ofxVec3f v2 = ya.cross( v1 ); ofxVec3f v3 = v1.cross( v2 ).normalize(); rvd[ i * 3 + 0 ] = v3.x; rvd[ i * 3 + 1 ] = v3.y; rvd[ i * 3 + 2 ] = v3.z; float w = h * 0.5; float xOff = v3.x * w; float yOff = v3.y * w; float zOff = v3.z * w; rvt[ i * 6 + 0 ] = t0x - xOff; rvt[ i * 6 + 1 ] = t0y - yOff; rvt[ i * 6 + 2 ] = t0z - zOff; rvt[ i * 6 + 3 ] = t0x + xOff; rvt[ i * 6 + 4 ] = t0y + yOff; rvt[ i * 6 + 5 ] = t0z + zOff; } else { rvd[ i * 3 + 0 ] = 0; rvd[ i * 3 + 1 ] = 0; rvd[ i * 3 + 2 ] = 0; rvt[ i * 6 + 0 ] = rps[ i * 3 + 0 ]; rvt[ i * 6 + 1 ] = rps[ i * 3 + 1 ]; rvt[ i * 6 + 2 ] = rps[ i * 3 + 2 ]; rvt[ i * 6 + 3 ] = rps[ i * 3 + 0 ]; rvt[ i * 6 + 4 ] = rps[ i * 3 + 1 ]; rvt[ i * 6 + 5 ] = rps[ i * 3 + 2 ]; } upAxis.rotate( ribbonRotation, ofxVec3f( 1, 0, 0 ) ); } }
void ShadersState::draw(){ if (cargarArchivos){ if (!shader.load("Basic.vert", "Basic.frag")) ofLogError()<<".....Error cargando los archivos....."; cargarArchivos = false; } ofBackgroundGradient(ofColor(64), ofColor(0), OF_GRADIENT_BAR); if(lastR != R || lastr != r || lastHCells != hCells || lastVCells != vCells){ delete torus; torus = new Torus(hCells, vCells, R, r); } glEnable(GL_DEPTH_TEST); GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0}; GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; GLfloat position[] = {ofGetWidth() / 2, ofGetHeight() / 2, 1000, 1.0}; glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, specular); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glPushMatrix(); glTranslatef(0, 0, -400); glTranslatef(ofGetWidth() / 2, ofGetHeight() / 2, 0.0); glRotatef(xRot, 1, 0, 0); glRotatef(yRot, 0, 1, 0); glTranslatef(-ofGetWidth() / 2, -ofGetHeight() / 2, 0.0); if(torus){ if(shade){ shader.begin(); shader.setUniform2f("size", ofGetWidth(), ofGetHeight()); shader.setUniform2f("center", ofGetMouseX(), ofGetMouseY()); shader.setUniform3f("lightPosition", ofGetMouseX(), ofGetMouseY(), 500); shader.setUniform1f("radius", 100); shader.setUniform1f("amplitude", 10); shader.setUniform1i("periods", periods); shader.setUniform1f("phase", phase); } torus->draw(ofPoint(ofGetWidth() / 2, ofGetHeight() / 2, -100), this->ambient, this->diffuse, this->specular, shininess, renderMode); if(shade){ shader.end(); } } glPopMatrix(); glDisable(GL_LINE_SMOOTH); glDisable(GL_POINT_SMOOTH); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); if(drawGui) gui.draw(); lastR = R; lastr = r; lastHCells = hCells; lastVCells = vCells; }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(ofColor::beige); ofEnableSmoothing(); v.setup(ofGetWidth()/2, ofGetHeight()/2); }
void Person::sleep(){ cout << "I'm sleeping!" << endl; ofEllipse(ofGetWidth()/2, ofGetHeight()/2, 100, 100); }
//-------------------------------------------------------------- void testApp::update(){ ofBackground(33, 33, 76); smurfFloor->think(); if(resizeFluid) { fluidSolver.setSize(fluidCellsX, fluidCellsX / window.aspectRatio); fluidDrawer.setup(&fluidSolver); resizeFluid = false; } tuio.getMessage(); ///------------------------------------------------------ windowResized(ofGetWidth(), ofGetHeight()); // force this at start (cos I don't think it is called) // do finger stuff list<ofxTuioCursor*>cursorList = tuio.getTuioCursors(); for(list<ofxTuioCursor*>::iterator it=cursorList.begin(); it != cursorList.end(); it++) { ofxTuioCursor *tcur = (*it); float vx = tcur->getXSpeed() * tuioCursorSpeedMult; float vy = tcur->getYSpeed() * tuioCursorSpeedMult; if(vx == 0 && vy == 0) { vx = ofRandom(-tuioStationaryForce, tuioStationaryForce); vy = ofRandom(-tuioStationaryForce, tuioStationaryForce); } addToFluid(tcur->getX(), tcur->getY(), vx, vy, true); } for (int i=0; i<smurfFloor->brain->getSmurfs()->size(); i++ ) { Smurf* s = smurfFloor->brain->getSmurfs()->at(i); ofxTuioObject *blob = (ofxTuioObject*) s->getTuio(); //addToFluid(blob->getX(), blob->getY(), blob->getMotionSpeed(), blob->getMotionSpeed(), false); addToFluid(blob->getX(), blob->getY(), blob->getRotationAccel(), blob->getRotationAccel(), true); } for (int i=0; i<smurfFloor->brain->getConnections()->size(); i++ ) { SConnection *connection = smurfFloor->brain->getConnections()->at(i); if (connection != NULL) { handleAnchorsUpdate(connection); } } for (int i=0; i<smurfFloor->waves->size(); i++ ) { SWave* w = smurfFloor->waves->at(i); if (w->getFid() != -1) { for (float cc=0.0;cc<15.0;cc++) { float vx = ofRandom(-tuioStationaryForce, tuioStationaryForce); float vy = ofRandom(-tuioStationaryForce, tuioStationaryForce); float x = (w->getX() + cosf(ofDegToRad(cc*24.0))*w->getRadius())/ofGetWidth(); float y = (w->getY() + sinf(ofDegToRad(cc*24.0))*w->getRadius())/ofGetHeight(); //Smurf *s = smurfFloor->brain->findSmurf(w->getFid()); //if (s != NULL && w->getX(),w->getRadius() addToFluid( x, y, 0.001, 0.001, true ); } } } fluidSolver.update(); // save old mouse position (openFrameworks doesn't do this automatically like processing does) pmouseX = mouseX; pmouseY = mouseY; }
//----------------------------------------------------------------------------------- void ofxCairoTexture::setupScreenPerspective(float width, float height, ofOrientation orientation, bool vFlip, float fov, float nearDist, float farDist){ if(!b3D) return; if(width == 0) width = ofGetWidth(); if(height == 0) height = ofGetHeight(); if( orientation == OF_ORIENTATION_UNKNOWN ) orientation = ofGetOrientation(); float viewW = ofGetViewportWidth(); float viewH = ofGetViewportHeight(); float eyeX = viewW / 2; float eyeY = viewH / 2; float halfFov = PI * fov / 360; float theTan = tanf(halfFov); float dist = eyeY / theTan; float aspect = (float) viewW / viewH; if(nearDist == 0) nearDist = dist / 10.0f; if(farDist == 0) farDist = dist * 10.0f; projection.makePerspectiveMatrix(fov,aspect,nearDist,farDist); modelView.makeLookAtViewMatrix(ofVec3f(eyeX,eyeY,dist),ofVec3f(eyeX,eyeY,0),ofVec3f(0,1,0)); //note - theo checked this on iPhone and Desktop for both vFlip = false and true switch(orientation) { case OF_ORIENTATION_180: modelView.glRotate(-180,0,0,1); if(vFlip){ modelView.glScale(-1,-1,1); modelView.glTranslate(width,0,0); }else{ modelView.glTranslate(width,-height,0); } break; case OF_ORIENTATION_90_RIGHT: modelView.glRotate(-90,0,0,1); if(vFlip){ modelView.glScale(1,1,1); }else{ modelView.glScale(1,-1,1); modelView.glTranslate(-width,-height,0); } break; case OF_ORIENTATION_90_LEFT: modelView.glRotate(90,0,0,1); if(vFlip){ modelView.glScale(1,1,1); modelView.glTranslate(0,-height,0); }else{ modelView.glScale(1,-1,1); modelView.glTranslate(0,0,0); } break; case OF_ORIENTATION_DEFAULT: default: if(vFlip){ modelView.glScale(-1,-1,1); modelView.glTranslate(-width,-height,0); } break; } };
//-------------------------------------------------------------- void testApp::setup(){ //ofEnableSmoothing(); smurfFloor = new Smurfloor(60, 5); smurfCfg = new SmurfCfg(); sender = new ofxOscSender(); receiver = new ofxOscReceiver(); synthUtils = new FMFUtils(); ofAddListener(tuio.objectAdded,smurfFloor->brain,&SmurfBrain::objectAdded); ofAddListener(tuio.objectRemoved,smurfFloor->brain,&SmurfBrain::objectRemoved); ofAddListener(tuio.objectUpdated,smurfFloor->brain,&SmurfBrain::objectUpdated); ofAddListener(tuio.cursorAdded,smurfFloor->brain,&SmurfBrain::tuioAdded); ofAddListener(tuio.cursorRemoved,smurfFloor->brain,&SmurfBrain::tuioRemoved); ofAddListener(tuio.cursorUpdated,smurfFloor->brain,&SmurfBrain::tuioUpdated); tuio.start(smurfCfg->getTuioPort()); // Init GUI fluidSolver.setDeltaT(FLUID_DEFAULT_DT); gui.addSlider("fluidCellsX", fluidCellsX, 20, 400); gui.addButton("resizeFluid", resizeFluid); gui.addSlider("fs.viscocity", fluidSolver.viscocity, 0.0, 0.0001f, 0.5); gui.addSlider("fs.colorDiffusion", fluidSolver.colorDiffusion, 0.0, 0.1, 0.5); gui.addSlider("fs.fadeSpeed", fluidSolver.fadeSpeed, 0.0, .03, 0.5); gui.addSlider("fs.solverIterations", fluidSolver.solverIterations, 1, 20); gui.addSlider("fd.drawMode", fluidDrawer.drawMode, 0, FLUID_DRAW_MODE_COUNT-1); gui.addToggle("fs.doRGB", fluidSolver.doRGB); gui.addToggle("fs.doVorticityConfinement", fluidSolver.doVorticityConfinement); gui.addToggle("drawFluid", drawFluid); gui.addToggle("drawParticles", drawParticles); gui.addToggle("renderUsingVA", renderUsingVA); gui.addToggle("fs.wrapX", fluidSolver.wrap_x); gui.addToggle("fs.wrapY", fluidSolver.wrap_y); gui.setAutoSave(true); gui.loadFromXML(); ofSetLogLevel(OF_LOG_VERBOSE); // setup fluid stuff fluidSolver.setup(100, 100); fluidSolver.enableRGB(true).setFadeSpeed(0.002).setDeltaT(0.5).setVisc(0.00015).setColorDiffusion(0.2); fluidDrawer.setDrawMode(0); fluidDrawer.setup(&fluidSolver); fluidCellsX = 120; drawFluid = true; drawParticles = false; renderUsingVA = false; ofBackground(33, 33, 76); ofSetVerticalSync(false); windowResized(ofGetWidth(), ofGetHeight()); // force this at start (cos I don't think it is called) resizeFluid = true; //--------------------------------------------------- sender->setup(smurfCfg->getOscSendAddress(), smurfCfg->getOscSendPort() ); receiver->setup(smurfCfg->getOscReceivePort()); // Use config file at some point here // BPM is set to 60 smurfFloor->setOscSender(sender); smurfFloor->setOscReceiver(receiver); smurfFloor->setSmurfCfg(smurfCfg); smurfFloor->brain->loadGestures(); // create a DAC FMFDac *DAC = synthUtils->createDAC(-440.0); smurfFloor->brain->getSmurfs()->push_back(DAC); }
//----------------------------------------------------------------------------------- void ofxCairoTexture::setupScreenOrtho(float width, float height, ofOrientation orientation, bool vFlip, float nearDist, float farDist){ if(!b3D) return; if(width == 0) width = ofGetWidth(); if(height == 0) height = ofGetHeight(); if( orientation == OF_ORIENTATION_UNKNOWN ) orientation = ofGetOrientation(); float viewW = ofGetViewportWidth(); float viewH = ofGetViewportHeight(); ofSetCoordHandedness(OF_RIGHT_HANDED); if(vFlip) { ofSetCoordHandedness(OF_LEFT_HANDED); } projection.makeOrthoMatrix(0, viewW, 0, viewH, nearDist, farDist); modelView.makeIdentityMatrix(); //note - theo checked this on iPhone and Desktop for both vFlip = false and true switch(orientation) { case OF_ORIENTATION_180: modelView.glRotate(-180,0,0,1); if(vFlip){ modelView.glScale(-1,-1,1); modelView.glTranslate(width,0,0); }else{ modelView.glTranslate(width,-height,0); } break; case OF_ORIENTATION_90_RIGHT: modelView.glRotate(-90,0,0,1); if(vFlip){ modelView.glScale(1,1,1); }else{ modelView.glScale(1,-1,1); modelView.glTranslate(-width,-height,0); } break; case OF_ORIENTATION_90_LEFT: modelView.glRotate(90,0,0,1); if(vFlip){ modelView.glScale(1,1,1); modelView.glTranslate(0,-height,0); }else{ modelView.glScale(1,-1,1); modelView.glTranslate(0,0,0); } break; case OF_ORIENTATION_DEFAULT: default: if(vFlip){ modelView.glScale(-1,-1,1); modelView.glTranslate(-width,-height,0); } break; } };
//-------------------------------------------------- void ofSaveScreen(string filename) { ofImage screen; screen.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR); screen.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); screen.saveImage(filename); }
void ofPage::draw(){ if(melodyCounter.elapsed() > 2200000){//set to 200ms after last note onset? //printf("MELODY FINISHED\n"); cout << "\nMELODY FINISHED " << bMelodyFinished << endl;//debug? cout << "\nMELODY TIME = " << melodyCounter.elapsed() << endl;//debug? bMelodyFinished = true; //bMelodyStart = false; //melodyCounter.reset();//bug? } if(currentPage == 0){ showStars = false; ofEnableAlphaBlending(); ofSetColor(0, 0, 0); buttonText.drawString("Playtime",sin(ofGetElapsedTimeMillis()/102.0f) * 1 +79,382+sin(ofGetElapsedTimeMillis()/102.0f)); buttonText.drawString("Credits",sin(ofGetElapsedTimeMillis()/102.0f) * 1 +716,500+sin(ofGetElapsedTimeMillis()/102.0f)); buttonText.drawString("Practice",sin(ofGetElapsedTimeMillis()/102.0f) * 1 +79,500+sin(ofGetElapsedTimeMillis()/102.0f)); buttonText.drawString("Options",sin(ofGetElapsedTimeMillis()/102.0f) * 1 +716,382+sin(ofGetElapsedTimeMillis()/102.0f)); ofDisableAlphaBlending(); playTrumpetSingle = false; playPianoSingle = false; playTrumpetMelody = false; playPianoMelody = false; } if(howTo == true){ ofEnableAlphaBlending(); ofSetColor(255, 255, 255, 255); //howToPage.draw(0,0,1024,768); ofDisableAlphaBlending(); } if (currentPage > 0 && currentPage < 28){ float timer = ofGetElapsedTimeMillis() - startTime; if(showStars == true && bMelodyFinished){//only permit after melody finished bGuessedWrong = false; greyStarCounter.start(); //printf("greyStarCounter is : ""%lld\n",greyStarCounter.elapsed()); } else tom1play = false, tom2play = false; if (bGuessedWrong == true && bMelodyFinished) { showStars = false; greyStarCounter.start();//start timer ofSetColor(255); if (greyStarCounter.elapsed() < 500000){ star1a.draw(ofGetWidth()/2-100,ofGetHeight()/2 -300); star1b.draw(ofGetWidth()/2-100,ofGetHeight()/2-300); star1c.draw(ofGetWidth()/2-100,ofGetHeight()/2-300); star2a.draw(ofGetWidth()/2-400,ofGetHeight()/2-300); star2b.draw(ofGetWidth()/2-400,ofGetHeight()/2-300); star2c.draw(ofGetWidth()/2-400,ofGetHeight()/2-300); star3a.draw(ofGetWidth()/2,ofGetHeight()/2-300); star3b.draw(ofGetWidth()/2,ofGetHeight()/2-300); star3c.draw(ofGetWidth()/2,ofGetHeight()/2-300); star4a.draw(ofGetWidth()/2-300,ofGetHeight()/2-400); star4b.draw(ofGetWidth()/2-300,ofGetHeight()/2-400); star4c.draw(ofGetWidth()/2-300,ofGetHeight()/2-400); } else if (greyStarCounter.elapsed() > 500000 && greyStarCounter.elapsed() <= 1000000){//explode stars greyCounter++; star1a.draw(ofGetWidth()/2-100,ofGetHeight()/2-300-greyCounter); star1b.draw(ofGetWidth()/2-100+greyCounter,ofGetHeight()/2-300); star1c.draw(ofGetWidth()/2-100-greyCounter,ofGetHeight()/2-300); star2a.draw(ofGetWidth()/2-400-greyCounter,ofGetHeight()/2-300); star2b.draw(ofGetWidth()/2-400,ofGetHeight()/2-300+greyCounter); star2c.draw(ofGetWidth()/2-400+greyCounter,ofGetHeight()/2-300); star3a.draw(ofGetWidth()/2+greyCounter,ofGetHeight()/2-300); star3b.draw(ofGetWidth()/2-greyCounter,ofGetHeight()/2-300); star3c.draw(ofGetWidth()/2,ofGetHeight()/2-300-greyCounter); star4a.draw(ofGetWidth()/2-300,ofGetHeight()/2-400-greyCounter); star4b.draw(ofGetWidth()/2-300-greyCounter,ofGetHeight()/2-400); star4c.draw(ofGetWidth()/2-300+greyCounter,ofGetHeight()/2-400); } if(greyStarCounter.elapsed() > 1000000){//allow fall to start early //printf("POSITION CHANGE IS NOW....:"); greyCounter2+=4; //int rot = 20; //ofRotateZ(rot); star1a.draw((ofGetWidth()/2-100),ofGetHeight()/2-300-34+greyCounter2*1); star1b.draw(ofGetWidth()/2-100+33,ofGetHeight()/2-300+greyCounter2*1.9); star1c.draw(ofGetWidth()/2-100-33,ofGetHeight()/2-300+greyCounter2*1.3); star2a.draw(ofGetWidth()/2-400-33,ofGetHeight()/2-300+greyCounter2*1.6); star2b.draw(ofGetWidth()/2-400,ofGetHeight()/2-300+32+greyCounter2*1.5); star2c.draw(ofGetWidth()/2-400+33,ofGetHeight()/2-300+greyCounter2*1.21); star3a.draw(ofGetWidth()/2+33,ofGetHeight()/2-300+greyCounter2*1,13); star3b.draw(ofGetWidth()/2-33,ofGetHeight()/2-300+greyCounter2*1.23); star3c.draw(ofGetWidth()/2,ofGetHeight()/2-300-34+greyCounter2*1.96); star4a.draw(ofGetWidth()/2-300,ofGetHeight()/2-400-34+greyCounter2*1.3); star4b.draw(ofGetWidth()/2-300-33,ofGetHeight()/2-400+greyCounter2*1.8); star4c.draw(ofGetWidth()/2-300+33,ofGetHeight()/2-400+greyCounter2*1.7); } if(greyStarCounter.elapsed() > 3000000){ bGuessedWrong = false; } //printf("fade counter is: ""%d\n",greyCounter); //printf("greyStarCounter is : ""%lld\n",greyStarCounter.elapsed()); ofSetColor(0); franklinBook14.drawString("Better Luck Next Time!", 100, 400); } // some information about the timer string info = "FPS: "+ofToString(ofGetFrameRate(),0)+"\n"; info += "Timer:"+ofToString(timer/1000.0, 1)+" seconds\n"; ofSetColor(0); //ofDrawBitmapString(info, ofGetScreenWidth()-200, 20); //playPage.draw(0,0,1024,768); fadePage = true; //show the dots and question mark if(showDots == true){ ofSetColor(0, 0, 0, 200); float dotTimer = ((ofGetElapsedTimeMillis() - startDotTime)); // some information about the timer if(dotTimer >= 0 && dotTimer < 3000){ dotsText.drawString(".", 50, 350); } if(dotTimer >= 454.00 && dotTimer < 3000){ dotsText.drawString(".", 150, 350); } if(dotTimer >= 1004.00 && dotTimer < 3000){ dotsText.drawString(".", 250, 350); } if(dotTimer >= 1470.00 && dotTimer < 3000){ dotsText.drawString(".", 350, 350); } if(dotTimer >= 2004.00 && dotTimer < 4000){ dotsText.drawString("?", 450, 350); } //printf("Fade Time is: ""%f\n",dotTimer); // printf("StartTime is: ""%f\n",startTime); if(currentPage == 5){ //float startPress = ((ofGetElapsedTimeMillis() - startDotTime)); if(bGuessedWrong){ float guessTime = ((ofGetElapsedTimeMillis() - startDotTime)); float trial1Time = (dotTimer - guessTime); printf("Trial 1 Time was: ""%f\n",trial1Time); } } } //method to allow pressing back of home button top left users requested this. if(showOptionsTab == true){ float delayTime = 0; delayTime = currentFrame*secondTime*fadeUpTime; if(delayTime > 200){ homeButtonBack = true; delayTime = 0; printf("%f\n",delayTime); } } if(currentFrame >= secondTime*2){//&& currentFrame < secondTime*2){ float go1 = 0; //float startFade = secondTime/20; //currentFrame = 0; go1 = (currentFrame-secondTime*2)*secondTime*fadeUpTime; if (go1 > 150) { go1 = 150; } //printf("%.1f\n", go1); //printf("%d\n",currentPage); ofEnableAlphaBlending(); //dim page and stop interaction and music if options are on display if(showOptionsTab == true || showSettings == true){ ofSetColor(255, 255, 255, 100); //allow homeButon to send user back to playMode ofEnableAlphaBlending(); ofSetColor(255, 255, 255, 150); homeButton.draw(sin(ofGetElapsedTimeMillis()/100.0f) * 1 + 20, 20 + sin(ofGetElapsedTimeMillis()/100.0f)); ofDisableAlphaBlending(); } else ofSetColor(255, 255, 255, go1); ofEnableAlphaBlending(); homeButton.draw(20,20); if(currentPage <27){//show right arrow up till last book page then allow home key to move on final page. rightArrow.draw(938,710); } if(currentPage > 1){//only show left arrow from page 2 leftArrow.draw(10,710); } ofDisableAlphaBlending(); } } else if (showCredits == true){ if(currentFrame >= 0){ float go2 = 0; go2 = currentFrame*secondTime*fadeUpTime; if (go2 > 150) { go2 = 150; } //printf("%.1f\n", go2); ofSetColor(255,255,255,255); //credits.draw(0,0,1024,768); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, go2); homeButton.draw(sin(ofGetElapsedTimeMillis()/100.0f) * 1 + 20, 20 + sin(ofGetElapsedTimeMillis()/100.0f)); ofDisableAlphaBlending(); } else if(showCredits == false){ ofSetColor(255, 255, 255, 255); } } //set up for the options tab if (showOptionsTab == true) { ofEnableAlphaBlending(); ofSetColor(255, 255, 255, 255);//reset page to stop bleed from previous page optionsTab.draw(311,56); returnArrow.draw(sin(ofGetElapsedTimeMillis()/105.0f) * 1+573, 232+sin(ofGetElapsedTimeMillis()/105.0f)); homeButton.draw(sin(ofGetElapsedTimeMillis()/101.0f) * 1+574, 334+sin(ofGetElapsedTimeMillis()/101.0f)); ofDisableAlphaBlending(); } //set up for the settings tab if (showSettings == true) { ofEnableAlphaBlending(); ofSetColor(255, 255, 255, 255);//reset page to stop bleed from previous page settingsPage.draw(311,56); //optionsTab.draw(0,0,1024,768); returnArrow.draw(sin(ofGetElapsedTimeMillis()/105.0f) * 1+573, 132 + sin(ofGetElapsedTimeMillis()/105.0f)); ofDisableAlphaBlending(); } if (howTo == true || currentPage == 27){ fadePage = false; showCredits = false; float go3 = 0; go3 = currentFrame*secondTime*fadeUpTime; if (go3 > 150) { go3 = 150; } //printf("%.1f\n", go2); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, go3); homeButton.draw(sin(ofGetElapsedTimeMillis()/100.0f) * 1 + 20, 20 + sin(ofGetElapsedTimeMillis()/100.0f)); ofDisableAlphaBlending(); } if(currentPage == 27){ float go3 = 0; go3 = currentFrame*secondTime*fadeUpTime; if (go3 > 150) { go3 = 150; } //printf("%.1f\n", go2); ofEnableAlphaBlending(); ofSetColor(255, 255, 255, go3); homeButton.draw(sin(ofGetElapsedTimeMillis()/100.0f) * 1 + 20, 20 + sin(ofGetElapsedTimeMillis()/100.0f)); ofDisableAlphaBlending(); } //update a star to display where needs pressing ofEnableAlphaBlending(); float go = fadeFrame*secondTime*fadeUpTime; if (go > 180) { go = go*-1 + 360;//make the dot fade up and down if(go == 0){ fadeFrame = 0; } } //dim page and stop interaction and music if options are on display if(showOptionsTab == true || showSettings == true){ ofSetColor(255, 255, 255, 100); } else ofSetColor(255, 255, 255, go); //All text for pages displays here if(currentPage == 1 && bGuessedWrong == false && bGuessedPiano == false && bGuessedTrumpet == false){ ofSetColor(0, 0, 0); franklinBook14.drawString("This is Giles the Bear! \n\n\n\nHe can't hear very well. \n\n\n\nCan you help him hear \n\nwhat the music is? ", 120, 200); } if(currentPage == 2){ ofSetColor(0, 0, 0); franklinBook14.drawString("Press the Piano! \n\nWhat do you hear?. \n\n\n\nNow press the trumpet.\n\nCan you hear it is different? ", 120, 150); } if(currentPage == 3 && bGuessedWrong == false && bGuessedPiano == false && bGuessedTrumpet == false){ ofSetColor(0, 0, 0); franklinBook14.drawString("Can you tell Giles what \n\ninstrument is playing?\n\n\n\nIs it a piano?\n\n\n\nOr is it a trumpet? \n\n\n\nPress Giles's ear to hear the tune!", 100, 70); } if(currentPage == 4 && showDots == false){ ofSetColor(0, 0, 0); franklinBook14.drawString("Are you ready to start?\n\n\n\nListen out for the last note. \n\n\n\nCan you tell Giles what \n\nthe instrument is?", 100, 70); } if(currentPage >= 4){ ofSetColor(0, 0, 0); switch(currentPage){ case 4 : trials.drawString("Trial 1", trialXpos, 50);//Trial no data kept break; case 5 : trials.drawString("Trial 2", trialXpos, 50);//Trial no data kept break; //*** START COLLECTING TIME DATA HERE *** case 6 : trials.drawString("Trial 3", trialXpos, trialYpos); break; case 7 : trials.drawString("Trial 4", trialXpos, trialYpos); break; case 8 : trials.drawString("Trial 5", trialXpos, trialYpos); break; case 9 : trials.drawString("Trial 6", trialXpos, trialYpos); break; case 10 : trials.drawString("Trial 7", trialXpos, trialYpos); break; case 11 : trials.drawString("Trial 8", trialXpos, trialYpos); break; case 12 : trials.drawString("Trial 9", trialXpos, trialYpos); break; case 13 : trials.drawString("Trial 10", trialXpos, trialYpos); break; case 14 : trials.drawString("Trial 11", trialXpos, trialYpos); break; case 15 : trials.drawString("Trial 12", trialXpos, trialYpos); break; case 16 : trials.drawString("Trial 13", trialXpos, trialYpos); break; case 17 : trials.drawString("Trial 14", trialXpos, trialYpos); break; case 18 : trials.drawString("Trial 15", trialXpos, trialYpos); break; case 19 : trials.drawString("Trial 16", trialXpos, trialYpos); break; case 20 : trials.drawString("Trial 17", trialXpos, trialYpos); break; case 21 : trials.drawString("Trial 18", trialXpos, trialYpos); break; case 22 : trials.drawString("Trial 19", trialXpos, trialYpos); break; case 23 : trials.drawString("Trial 20", trialXpos, trialYpos); break; } } currentFrame++;//counter keeps the timing of the book fadeFrame ++;//all animation fades //printf("Page number is: ""%d\n",currentPage); }
//-------------------------------------------------------------- void menu::setup() { ofLogNotice("menu - SETUP - inicio"); ofSetVerticalSync(true); ofBackgroundHex(0x000000); ofSetLogLevel(OF_LOG_NOTICE); ofEnableAntiAliasing(); ofEnableSmoothing(); box2d.init(); box2d.setGravity(0, 0); box2d.setFPS(30.0); bola.loadImage("images/dot.png"); ladoPart1 = 5; ladoPart2 = 10; // Cargar colores coloresBN.push_back(ofColor(0)); coloresBN.push_back(ofColor(150)); coloresBN.push_back(ofColor(255)); // Modos dibujo bDraw4Forces = true; fRed = true; // centro centroScreen = ofVec2f(ofGetWidth()/2, W_HEIGHT/2); // ofGetHeight()/2); // Borde Negro circular borde.clear(); ofColor ctmp = ofColor::black; borde.setFillColor(ctmp); //http://www.openframeworks.cc/documentation/graphics/ofPath.html#show_setPolyWindingMode borde.setPolyWindingMode(OF_POLY_WINDING_ODD); // rectangulo borde.rectangle(0,0,ofGetWidth(),ofGetHeight()); borde.setCircleResolution(60); // Paso a posicion de la pantall centrada en ancho y ajustada al borde superior // borde.circle(ofGetWidth()/2,ofGetHeight()/2,ofGetHeight()/2*0.95); // centro = ofVec2f(ofGetWidth()/2.0, ofGetHeight()/2.0); // distConf = ofGetHeight()/2.0*0.9; borde.circle(ofGetWidth()/2, W_HEIGHT/2,W_HEIGHT/2*0.95); centro = ofVec2f(ofGetWidth()/2.0, W_HEIGHT/2.0); distConf = W_HEIGHT/2.0*0.9; minDisInt = 25; // fbos fbo1.allocate(ofGetHeight()/2,W_HEIGHT/2);// ofGetHeight()/2); fbo2.allocate(ofGetHeight()/2,W_HEIGHT/2);// ofGetHeight()/2); fbo3.allocate(ofGetHeight()/2,W_HEIGHT/2);// ofGetHeight()/2); fbo4.allocate(ofGetHeight()/2,W_HEIGHT/2);// ofGetHeight()/2); // // crear Botones TUIO // //buttonSpeed1.set(centro.x-rMed-(dRad*0.9/2),centro.y-(dRad*0.9/2), dRad*0.9,dRad*0.9); menuButton button1; button1.set(0, 0, centro.x, centro.y); // button1.setup("E·M", ofColor::fromHex(0xF70D1A) ); // ferrary red button1.setup(EM, ofColor::fromHex(0xF70D1A) , &mdisplay); // ferrary red buttons.push_back(button1); menuButton button2; button2.set(centro.x, 0, centro.x, centro.y); button2.setup(FUERTE, ofColor::chartreuse, &mdisplay); buttons.push_back(button2); menuButton button3; button3.set(centro.x,centro.y, centro.x, centro.y); button3.setup(GRAVEDAD, ofColor::skyBlue, &mdisplay);// fromHex(0x64E986) ); // Algae Green // Emerald buttons.push_back(button3); menuButton button4; button4.set(0, centro.y, centro.x, centro.y); button4.setup(DEBIL, ofColor::pink , &mdisplay); buttons.push_back(button4); touchElements.addObject(buttons[0]); touchElements.addObject(buttons[1]); touchElements.addObject(buttons[2]); touchElements.addObject(buttons[3]); // init_Escena(); ofLogNotice("menu - SETUP - fin"); }
Walker::Walker() { mX = ofGetWidth() / 2; mY = ofGetHeight() / 2; mTargetX = mX; mTargetY = mY; }