/* 
 * @Description: Listen for key presses
 * @param: KeyEvent
 * @return: none
 */
void Base_ThreeD_ProjectApp::keyDown( KeyEvent event ) 
{
	//printf("%i \n", event.getCode());
	
	switch ( event.getCode() ) 
	{
		case KeyEvent::KEY_1:
		{
			RENDER_MODE = 0;
		}
			break;
		case KeyEvent::KEY_2:
		{
			RENDER_MODE = 1;
		}
			break;
		case KeyEvent::KEY_3:
		{
			RENDER_MODE = 2;
		}
			break;
		case KeyEvent::KEY_4:
		{
			RENDER_MODE = 3;
		}
			break;		
			
		case KeyEvent::KEY_UP:
		{
			Vec3f lightPos = mLight->getPosition();
			if ( lightPos.y > 0 )
				lightPos.y *= -1;
			lightPos = lightPos + Vec3f(0, 0.0, 0.1);		
			mLight->lookAt( lightPos, Vec3f::zero() );
			//mLight->update( *mCam );
			
			lightPos = mLightRef->getPosition() + Vec3f(0, 0.0, 0.1);
			mLightRef->lookAt( lightPos, Vec3f::zero() );
			mLightRef->update( *mCam );
		}
			break;
		case KeyEvent::KEY_DOWN:
		{
			Vec3f lightPos = mLight->getPosition();
			if ( lightPos.y > 0 )
				lightPos.y *= -1;
			lightPos = lightPos + Vec3f(0, 0.0, -0.1);		
			mLight->lookAt( lightPos, Vec3f::zero() );
			//mLight->update( *mCam );
			
			lightPos = mLightRef->getPosition() + Vec3f(0, 0.0, -0.1);	
			mLightRef->lookAt( lightPos, Vec3f::zero() );
			mLightRef->update( *mCam );
		}
			break;
		case KeyEvent::KEY_LEFT:
		{
			Vec3f lightPos = mLight->getPosition();
			if ( lightPos.y > 0 )
				lightPos.y *= -1;
			lightPos = lightPos + Vec3f(0.1, 0, 0);		
			mLight->lookAt( lightPos, Vec3f::zero() );
			//mLight->update( *mCam );
			
			lightPos = mLightRef->getPosition() + Vec3f(0.1, 0, 0);
			mLightRef->lookAt( lightPos, Vec3f::zero() );
			mLightRef->update( *mCam );
		}
			break;
		case KeyEvent::KEY_RIGHT:
		{
			Vec3f lightPos = mLight->getPosition();
			if ( lightPos.y > 0 )
				lightPos.y *= -1;
			lightPos = lightPos + Vec3f(-0.1, 0, 0);		
			mLight->lookAt( lightPos, Vec3f::zero() );
			//mLight->update( *mCam );
			
			lightPos = mLightRef->getPosition() + Vec3f(-0.1, 0, 0);	
			mLightRef->lookAt( lightPos, Vec3f::zero() );
			mLightRef->update( *mCam );
		}
			break;
		case KeyEvent::KEY_w:
		{
			mEye = mCam->getEyePoint();
			mEye = Quatf( Vec3f(1, 0, 0), -0.03f ) * mEye;
			mCam->lookAt( mEye, Vec3f::zero() );
			//mLight->update( *mCam );
			mLightRef->update( *mCam );
		}
			break;
		case KeyEvent::KEY_a:
		{
			mEye = mCam->getEyePoint();
			mEye = Quatf( Vec3f(0, 1, 0), 0.03f ) * mEye;
			mCam->lookAt( mEye, Vec3f::zero() );
			//mLight->update( *mCam );
			mLightRef->update( *mCam );
		}
			break;	
		case KeyEvent::KEY_s:
		{
			mEye = mCam->getEyePoint();
			mEye = Quatf( Vec3f(1, 0, 0), 0.03f ) * mEye;
			mCam->lookAt( mEye, Vec3f::zero() );
			//mLight->update( *mCam );
			mLightRef->update( *mCam );
		}
			break;
		case KeyEvent::KEY_d:
		{
			mEye = mCam->getEyePoint();
			mEye = Quatf( Vec3f(0, 1, 0), -0.03f ) * mEye;
			mCam->lookAt( mEye, Vec3f::zero() );
			//mLight->update( *mCam );
			mLightRef->update( *mCam );
		}
			break;
		default:
			break;
	}
}