//--------------------------------------------------------------
void ofApplication::update(){
    
    float elapsedTime = ofGetElapsedTimef();

    audioLowEnergy = ofMap(audioAnalyzer.getSignalEnergyInRegion(AA_FREQ_REGION_LOW)*audioSensitivity, 0.25f, 3.0f, 0.0f, 1.0f, true);
    audioMidEnergy = audioAnalyzer.getSignalEnergyInRegion(AA_FREQ_REGION_MID)*audioSensitivity;
    audioHiPSF = ofMap(audioAnalyzer.getPSFinRegion(AA_FREQ_REGION_HIGH)*audioSensitivity, 0.3f, 4.0f, 0.0f, 1.0f, true);
    elapsedPhase = 2.0*M_PI*elapsedTime;
    
    processOscMessages();

#ifdef USE_KINECT
    kinectOpenNI.update();
    handPhysics->update();    
    if(bDrawUserOutline) updateUserOutline();
 #endif
    
    // don't draw if frame freeze is turned on
    bool shouldDrawNew = true;
    if (strobeIntervalMs > 1000.0f/60.0f){
        
        shouldDrawNew = (elapsedTime - strobeLastDrawTime >= strobeIntervalMs/1000.0f);
        if (shouldDrawNew){
            strobeLastDrawTime = elapsedTime;
        }
    }
    
    // draw to FBOs
    glDisable(GL_DEPTH_TEST);
    
    beginTrails();
    if (shouldDrawNew){
        if (bDrawUserOutline && bTrailUserOutline) drawUserOutline();
        if (bDrawHands && bTrailHands) drawHandSprites();
        if (bDrawPoi && bTrailPoi) drawPoiSprites();
        drawTouches();
    }
    endTrails();
    
    mainFbo.begin();
    ofClear(0,0,0,0);
    
    if (bDrawUserOutline && !bTrailUserOutline && shouldDrawNew) drawUserOutline();
    
    drawTrails();
    if (shouldDrawNew){
        if (bDrawHands && !bTrailHands) drawHandSprites();
        if (bDrawPoi && !bTrailPoi) drawPoiSprites();
    }

    mainFbo.end();
}
Exemple #2
0
void ofApp::draw() {

    ofBackground(BACKGROUND_COLOR);

    if (appState == SPLASH_SCREEN) {
        imgSplashScreen.draw(0, 0, ofGetWidth(), ofGetHeight());
        if (ofGetElapsedTimeMillis() > 1500) appState = SPLASH_FADE;
        return;
    }

    else if (appState == SPLASH_FADE) {
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, 255);
        if(ofApp::isPhone()){
            imgAbout.drawSubsection(0.0f, 0.0f, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop);
        }
        else {
            imgAbout.draw(0, 0, ofGetWidth(), ofGetHeight());
        }
        splashAlpha -= 2;
        ofSetColor(255, 255, 255, splashAlpha);
        imgSplashScreen.draw(0, 0, ofGetWidth(), ofGetHeight());
        ofDisableAlphaBlending();
        ofPopStyle();
        if (splashAlpha <= 0) appState = ABOUT;
        return;
    }

    else if (appState == ABOUT) {
        if(ofApp::isPhone()){
            imgAbout.drawSubsection(0.0f, 0.0f, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop);
        }
        else {
            imgAbout.draw(0, 0, ofGetWidth(), ofGetHeight());
        }
        setLanguageBBoxes();
        drawBouncingArrow();
        return;
    }

    drawModules();
    drawLines();
    drawParticles();
    drawTouches();

    if (showSwipeInfo)  {
        ofPushStyle();

        if (isTablet()) ofSetColor(47); // NOTE: previous white font color wasn't readable on iPad;
        else ofSetHexColor(CONSOLE_COLOR);

        int swipeSize = 150;
        int padding = 80;

        imgSwipeInfo.draw(ofGetWidth()/2-swipeSize/2, ofGetHeight()/2, swipeSize, swipeSize);

        string s1 = ofApp::translations["SWIPE_INFO_TOP_LINE"];
        int s1w = swipeFont.getStringBoundingBox(s1, 0, 0).width;
        int s1x = (ofGetWidth() - s1w) / 2;
        int s1y = ofGetHeight()/2 - padding;
        swipeFont.drawString(s1, s1x, s1y);

        string s2;
        if (ofApp::isPhone()) s2 = ofApp::translations["SWIPE_INFO_BOTTOM_LINE_PHONE"];
        else s2 = ofApp::translations["SWIPE_INFO_BOTTOM_LINE_TABLET"];

        int s2w = swipeFont.getStringBoundingBox(s2, 0, 0).width;
        int s2x = (ofGetWidth() - s2w)/2;
        int s2y = ofGetHeight()/2 + swipeSize + padding;
        swipeFont.drawString(s2, s2x, s2y);

        ofPopStyle();
    }

    if (appState == BAR) {
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, DEFAULT_ALPHA);
        if(ofApp::isPhone()){
            imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop);
        }
        else {
            imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight());
        }

        ofDisableAlphaBlending();
        drawArrow(false);
        ofPopStyle();
    }

    else if (appState == ABOUT_ASCENDING) {
        if (aboutY < 15) {
            aboutY = 0;
            appState = ABOUT;
        } else {
            aboutY -= 15;
        }
        if (currentAlpha < 255) currentAlpha += 3;
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, currentAlpha);
        if(ofApp::isPhone()){
            imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop);
        }
        else {
            imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight());
        }
        ofDisableAlphaBlending();
        ofPopStyle();
    }

    else if (appState == ABOUT_DESCENDING) {
        aboutY += 20;
        if(ofApp::isPhone()){
            imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop);
        }
        else {
            imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight());
        }
    }

    else if (appState == BAR_ASCENDING) {
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, DEFAULT_ALPHA);
        aboutY -= 5;
        if(ofApp::isPhone()){
            imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop);
        }
        else {
            imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight());
        }
        drawArrow(false);
        ofDisableAlphaBlending();
        ofPopStyle();
    }

    else if (appState == BAR_DESCENDING) {
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, DEFAULT_ALPHA);
        aboutY += 5;
        if(ofApp::isPhone()){
            imgAbout.drawSubsection(0.0f, aboutY, (float)ofGetWidth(), (float)ofGetHeight(), 0.0f, (float)crop);
        }
        else {
            imgAbout.draw(0, aboutY, ofGetWidth(), ofGetHeight());
        }
        drawArrow(true);

        ofDisableAlphaBlending();
        ofPopStyle();
    }

    else if (appState == APP) {

        if (isOsx()) {
            currentAlpha = DEFAULT_ALPHA;
            drawArrow(true);
            ofPushStyle();
            ofSetColor(IMAGE_COLOR, DEFAULT_ALPHA);
            ofEnableAlphaBlending();
            ofDrawRectangle(barRect);
            ofDisableAlphaBlending();
            ofPopStyle();
        }
    }

}