Exemple #1
0
void BrainbowApp::scene2(){
    //    cout << "x: " << scaledX << endl;
    //    cout << "y: " << scaledY << endl;
    //    cout << "z: " << scaledZ << endl;
    
    if (!newLight){
        mCloud.clear();
        mLight->setAmbient( Color( 0.0f, 0.0f, 0.0f ) );
        mLight->setDiffuse( Color( 1.0f, 1.0f, 1.0f ) );
        mLight->setSpecular( Color( 1.0f, 1.0f, 1.0f ) );
        mLight->setShadowParams( 60.0f, 0.5f, 8.0f );
        newLight = true;
        cubeTimer.start();
    }
    
    if (scaledZ < 350 && targets.size() < 5 && cubeTimer.getSeconds() > 2){
        addTarget(Vec3f (scaledX, scaledY, scaledZ));
        cubeTimer = 0;
        cubeTimer.start();
    }
    
    if (cubes.size() >= 45){
        if ( !newCloud){
            mCloud = SphereCloud(0, 500);
            newCloud = true;
        }
        if (newCloud && mCloud.getNumber() < 300 && gongTimer.getSeconds() > .5){
            gongTimer = 0;
            gongTimer.start();
            mCloud.addSphere();
            mAudio.playTraz("bubble");
        }
    }
}
Exemple #2
0
void BrainbowApp::setup()
{
    // LOAD AUDIO
    mAudio = AudioCont();
    mAudio.setUp();
    
    // START SCENE 1
    sceneOne = true;
    sceneTwo = false;
    
    // Set up OpenGL
    
	gl::enableAlphaBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();
    
    gongTimer.start();
    ballTimer.start();
    
    // LIGHTING
    //here
    glPolygonOffset( 1.0f, 1.0f );
	glEnable( GL_LIGHTING );
	glEnable( GL_DEPTH_TEST );
    
    
    mLight = new gl::Light( gl::Light::POINT, 0 );
	mLight->lookAt( Vec3f( 1, 5, 1 ), Vec3f (getWindowWidth(), getWindowHeight() * 0.5f, 0.0f ));
    mLight->setAmbient( Color( 0.3f, 0.3f, 0.3f ) );
	mLight->setDiffuse( Color( 1.0f, 1.0f, 1.0f ) );
	mLight->setSpecular( Color( 1.0f, 1.0f, 1.0f ) );
	mLight->setShadowParams( 60.0f, 0.5f, 8.0f );
    //	mLight->update( *mCamera );
	mLight->enable();
    
    
    //LOAD SHAPES
    colorSat = 1.0f;
    
	sphereMaterial.setSpecular( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	sphereMaterial.setDiffuse( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	sphereMaterial.setAmbient( ColorA(colorSat-0.3f, colorSat, colorSat, .05f ) );
	sphereMaterial.setShininess( 1.0f );
    
    sphereMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    gl::Material cylMaterial;
    cylMaterial.setSpecular( ColorA(0, 1.0f, 1.0f, .2f ));
	cylMaterial.setDiffuse( ColorA(0, 1.0f, 1.0f, .2f ) );
	cylMaterial.setAmbient( ColorA(0, 1.0f, 1.0f, .2f ) );
	cylMaterial.setShininess( 600.0f );
    cylMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    
    gl::Material curMaterial;
    curMaterial.setSpecular( ColorA(1, .5, 0, .5f ));
	curMaterial.setDiffuse( ColorA(1, .5, 0, .5f ) );
	curMaterial.setAmbient( ColorA(1, 1.0f, 1.0f, .05f ) );
	curMaterial.setShininess( 600.0f );
    curMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    
    
	discMaterial.setSpecular( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	discMaterial.setDiffuse( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	discMaterial.setAmbient( ColorA(colorSat-0.3f, colorSat, colorSat, .05f ) );
	discMaterial.setShininess( 600.0f );
    discMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    
    initShadowMap();
    
    mCloud = SphereCloud(0, 70);
    
    mDiamond = gl::DisplayList( GL_COMPILE );
    mDiamond.newList();
    gl::drawSphere(Vec3f(0, 0, 0), 300, 4);
    mDiamond.endList();
    mDiamond.setMaterial( sphereMaterial );
    
    mCyl = gl::DisplayList( GL_COMPILE );
    mCyl.newList();
    //    gl::drawCylinder(200, 200, 200);
    gl::drawColorCube(Vec3f(0, 0, 0), Vec3f(300, 300, 300));
    mCyl.endList();
    mCyl.setMaterial(cylMaterial);
    
    mCur = gl::DisplayList( GL_COMPILE );
    mCur.newList();
    gl::drawSphere(Vec3f(0, 0, 0), 5);
    mCur.endList();
    mCur.setMaterial(curMaterial);
    
    mDisc = gl::DisplayList( GL_COMPILE );
    mDisc.newList();
    gl::drawSolidCircle(Vec2f(0, 0), 60, 6);
    mDisc.endList();
    mDisc.setMaterial( discMaterial );
	
	// START LEAP
	mLeap 		= LeapSdk::Device::create();
	mCallbackId = mLeap->addCallback( &BrainbowApp::onFrame, this );
    
    
    mShader = gl::GlslProg( loadResource( RES_SHADOWMAP_VERT ), loadResource( RES_SHADOWMAP_FRAG ) );
	mShader.bind();
	mShader.uniform( "depthTexture", 0 );
}
Exemple #3
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();
}