Beispiel #1
0
void BrainbowApp::scene1(){
    
    if (!musicOn && getElapsedSeconds() > 1){
        mAudio.playTraz("drone");
    }
    
    //    //addspheres
    if (lightFade >= 0.45f && ballTimer.getSeconds() > 0.5f && mCloud.getNumber() < 20){
        mCloud.addSphere();
        mAudio.playTraz("bubble");
        ballTimer = 0;
        ballTimer.start();
    }
    
        //into diamond
    if (gongTimer.getSeconds()>1 && scaledZ < 290 && scaledZ > 100 && !gong && getElapsedSeconds() > 30){
        mAudio.playTraz("activate");
        gong = true;
        gongTimer.stop();
        gongTimer.start();
    }
    
    if (gong && zshift < 500 ){
        //        zshift = 1;
        zshift++;
        scaledZ += zshift;
    }
    if (mCloud.getNumber() < 300 && ballTimer.getSeconds() > 0.1f && gong && zshift > 0){
        mCloud.addSphere();
        //        mAudio.playTraz("bubble");
        ballTimer = 0;
        ballTimer.start();
    }
    
    //    cout << "x: " << scaledX << endl;
    //    cout << "y: " << scaledY << endl;
    //    cout << "z: " << scaledZ << endl;
    
    if ((mCloud.getHexClear() || shift2) && getElapsedSeconds() > 10 && zshift < 750 && gong){
        //        if (getElapsedSeconds() > 10 && zshift < 720){
        shift2 = true;
        zshift++;
        scaledZ += zshift;
        discMaterial.setSpecular( ColorA(colorSat, colorSat, colorSat, .4f + discOp ) );
        discMaterial.setDiffuse( ColorA(colorSat, colorSat, colorSat, .4f + discOp) );
        discMaterial.setAmbient( ColorA(colorSat, colorSat, colorSat, .05f ) );
        discMaterial.setShininess( 600.0f );
        discMaterial.setEmission(ColorA(1, 1, 1, 1 ));
        mDisc.setMaterial( discMaterial );
        
        discOp += .01;
        if (zshift > 680){
            
            diamondFade += .005;
            sphereMaterial.setSpecular( ColorA(colorSat-0.3f, colorSat, colorSat, .4f-diamondFade ) );
            sphereMaterial.setDiffuse( ColorA(colorSat-0.3f, colorSat, colorSat, .4f-diamondFade ) );
            sphereMaterial.setAmbient( ColorA(colorSat-0.3f, colorSat, colorSat, .05f-diamondFade ) );
            mDiamond.setMaterial( sphereMaterial );
            //                drawDiamond = false;
        }
        if (!musicOn){
            mAudio.playTraz("activate2");
            musicOn = true;
        }
    }
    if (zshift >= 750 && scaledZ > 700 && scaledY < 450 && scaledY > 320 && scaledX <685 && scaledX > 590){
        sceneOne = false;
        sceneTwo = true;
        zshift = 0;
    }
}
// Render
void UiApp::draw()
{
	// Clear window
	gl::setViewport( getWindowBounds() );
	gl::clear( Colorf::white() );
	gl::setMatricesWindow( getWindowSize() );
	gl::color( ColorAf::white() );

	// Make PNG backgrounds transparent
	gl::enableAlphaBlending();
	gl::disableDepthRead();
	gl::disableDepthWrite();

	// Master offset
	gl::pushMatrices();

   int num_buttons = 3;

	// Draw buttons
	for ( size_t i = 0; i < num_buttons; ++i ) {
		bool pressed = mButtonState[ i ];
		if (pressed && !anyPressed)
		{
			anyPressed = true;
			timer.start();
		}
		gl::pushMatrices();
		gl::translate( mButtonPosition[ i ] );
		gl::draw( mButton[i][ pressed ? 1 : 0 ] );
		gl::popMatrices();
	}

	if (!mButtonState[0] && !mButtonState[1] && !mButtonState[2])
	{
		anyPressed = false;
		timer.stop();
	}

	gl::popMatrices();

	// Draw finger position for pressing buttons
	if ( mCursorType == CursorType::TOUCH )
	{
		gl::color( ColorAf( 0.0f, 0.0f, 0.0f ) );
		gl::drawSolidCircle( mFingerTipPosition, 26.0f );


      // If an option is being hovered on and has been for at least 3 seconds, color the cursor green
		if (timer.getSeconds() >= 3.0f && anyPressed == true)
		{
			gl::color( ColorAf( 0.0f, 0.8f, 0.0f ) );

         SHELLEXECUTEINFO ShExecInfo = {0};
         ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
         ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
         ShExecInfo.hwnd = NULL;
         ShExecInfo.lpVerb = NULL;              
         ShExecInfo.lpParameters = L"";   
         ShExecInfo.lpDirectory = NULL;
         ShExecInfo.nShow = SW_SHOW;
         ShExecInfo.hInstApp = NULL; 

         // Launch note visualization program
         if (mButtonState[0])
         {
            timer.stop();
            mButtonState[0] = false;
            anyPressed = false;

            ShExecInfo.lpFile = L"C:\\LeapMusic\\NoteVisualization.exe";
            ShellExecuteEx(&ShExecInfo);
            WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
         }

         // Launch ribbon visualization program
         if (mButtonState[1])
         {
            timer.stop();
            mButtonState[1] = false;
            anyPressed = false;

            ShExecInfo.lpFile = L"C:\\LeapMusic\\RibbonVisualization.exe";
            ShellExecuteEx(&ShExecInfo);
            WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
         }

         // Quit
         if (mButtonState[2])
         {
            quit();
         }
		}
		else
		{
			gl::color( ColorAf( 1.0f, 0.7f, 0.0f ) );
		}

		gl::drawSolidCircle( mFingerTipPosition, 20.0f );


      // Draw the timer if it has been less than 3 seconds since hovering began
		if (anyPressed && timer.getSeconds() < 3.0f)
		{
			gl::drawStringCentered(std::to_string(3-(int)timer.getSeconds()), Vec2f(mFingerTipPosition.x, mFingerTipPosition.y - 10.0f),cinder::ColorA(0,0,0,1),cinder::Font("Arial", 30.0f));
		}
	}

	// Draw the interface
	//mParams.draw();
}