void HiKinectApp::update()
{
	if( mKinect.checkNewDepthFrame() ) {
		mDepthTexture = mKinect.getDepthImage();
		mDepthSurface = Surface32f( mKinect.getDepthImage() );
		mKinectReady = true;
		if ( !mKinectIR ) {
			mKinectIR = true;
			mKinect.setVideoInfrared( true );
		}
		
		ci::Surface captureSurface = Surface8u( mKinect.getDepthImage() );
		ci::Surface outputSurface = captureSurface;
		mContours->clear();
		mSilhouetteDetector->processSurface(&captureSurface, mContours, &outputSurface);
	}
	
	if( mKinect.checkNewColorFrame() )
		mColorTexture = mKinect.getVideoImage();
	
	if( mIsMouseDown ) // using small number instead of 0.0 because lights go black after a few seconds when going to 0.0f
		mDirectional -= ( mDirectional - 0.00001f ) * 0.1f;  
	else 
		mDirectional -= ( mDirectional - 1.0f ) * 0.1f;
	
	if (mKinectReady)
		mGridMesh.updateKinect(mKinect);
	else
		mGridMesh.update();
}