void WaterSimulationApp::keyDown( KeyEvent event ){
	switch(event.getChar()){
	case 'r':fluidsys->reset(boxDimension);break;
	case 'f':setFullScreen( ! isFullScreen() ); break;
	case 'a':mAddNewForce=true;break;
	}

	switch(event.getCode()){
	case KeyEvent::KEY_SPACE:mAnimate=!mAnimate;break;
	case KeyEvent::KEY_ESCAPE:this->quit();break;
	}

}
void WaterSimulationApp::setup(){

	boxDimension=Vec3f(30.0f,30.0f,30.0f);
	boxCenter=Vec3f(boxDimension)/2.0f;

	//Fluid System setup
	fluidsys=&stamfluid;
	fluidsys->reset(boxDimension);

	randomForce=Vec3f(2,3,-1);
	randomForceX=boxCenter;

	//// setup our default camera, looking down the z-axis
	CameraPersp	cam;
	cam.setEyePoint(Vec3f(200, 50, 50));
	cam.setCenterOfInterestPoint(boxCenter);
	cam.setPerspective(60.0, getWindowAspectRatio(), 1.0, 1000.0);
	mMayaCam.setCurrentCam(cam);

	Matrix44f mvM=mMayaCam.getCamera().getModelViewMatrix();
	gravity = Vec3f(mvM.m10,mvM.m11,mvM.m12);//col4:camera center, row: right,up,back
	gravity*= 9.8f;
	// Setup the parameters
	mDrawGravity=false;
	mAddNewForce=false;
	mAnimate	=false;
	mDrawBox	=true;


	mParams = params::InterfaceGl::create( getWindow(), "Water Simulation Parameters", toPixels( Vec2i( 250,300  ) ) );
	mParams->addParam("Draw Box", &mDrawBox);
	mParams->addParam("Draw Grid",&mDrawGrid);
	mParams->addParam("Draw Random Force",&mDrawForce);
	mParams->addSeparator();
	mParams->addParam("External Force Position",&randomForceX);
	mParams->addParam("External Force Dir",&randomForce);
	mParams->addParam("Draw Gravity",&mDrawGravity);
	mParams->addParam("Draw Velocity", &(fluidsys->mDrawVelocity));
	mParams->addSeparator();
	mParams->addParam("Animate",&mAnimate);
	mParams->addText("status","label=` `");
	mParams->addParam("Time Elapsed",&(fluidsys->elapsed),"",true);
	mParams->addSeparator();
	mParams->addParam("Viscosity", &fluidsys->viscosity);
	mParams->addParam("Diffusion Rate", &fluidsys->diffusion);
	mParams->addParam("Buoyancy Rate",&fluidsys->buoyancy);
}