Example #1
0
// Handle menu commands
void HandleMenuCommand(int option)
{
	switch(option)
	{
		case 'de':
			mDesign = !mDesign;
			
			if (mDesign)
			{
				mPS.StartConstructingSystem();
			}
			else
			{
				mPS.FinishConstructingSystem();
			}
			break;
		
		case 'cs':
			if (!mDesign)
			{
				mDesign = true;
				mPS.StartConstructingSystem();
			}
			mPS.ClearSystem();
			break;
		
		case 'mp':
			mMode = designMode_Particle;
			break;

		case 'mn':
			mMode = designMode_Nail;
			break;

		case 'ms':
			mMode = designMode_Spring;
			break;
		
		case 'd':
			mSurfaceConditionsName = "Default";
			mSurface.SetAmbientColor( 0.0, 0.0, 1.0, 1.0 );
			mSurface.SetDiffuseColor( 0.0, 0.0, 1.0, 1.0 );
			mSurface.SetSpecularColor( 0.5, 0.5, 0.5, 0.5 );
			mSurface.SetShininess( 10.0 );
			mPS.gravity = 9.8;
			mPS.drag = 0.01;
			mPS.SetSpringConstant(5);
			mPS.SetSpringDampingConstant(1);
			mSurface.SetMassProportion(1); // proportional to numer of particles in x
			break;

		case 't':
			mSurfaceConditionsName = "Trampoline";
			mSurface.SetAmbientColor( 0.1, 0.1, 0.3, 1.0 );
			mSurface.SetDiffuseColor( 0.0, 0.0, 0.6, 1.0 );
			mSurface.SetSpecularColor( 0.5, 1.0, 1.0, 1.0 );
			mSurface.SetShininess( 70.0 );
			mPS.gravity = 9.8;
			mPS.drag = 0.001;
			mPS.SetSpringConstant(10);
			mPS.SetSpringDampingConstant(1);
			mSurface.SetMassProportion(0.5); // proportional to numer of particles in x
			break;

		case 'f':
			mSurfaceConditionsName = "Foam";
			mSurface.SetAmbientColor( 1.0, 1.0, 1.0, 1.0 );
			mSurface.SetDiffuseColor( 0.8, 0.8, 1.0, 1.0 );
			mSurface.SetShininess( 10.0 );
			mPS.gravity = 0.5;
			mPS.drag = 1.0;
			mPS.SetSpringConstant(1);
			mPS.SetSpringDampingConstant(1);
			mSurface.SetMassProportion(1); // proportional to numer of particles in x
			break;

		case 'c':
			mSurfaceConditionsName = "Clay";
			mSurface.SetAmbientColor( 0.6, 0.6, 0.4, 1.0 );
			mSurface.SetDiffuseColor( 0.3, 0.3, 0.2, 1.0 );
			mSurface.SetSpecularColor( 0.2, 0.2, 0.2, 1.0 );
			mSurface.SetShininess( 10.0 );
			mPS.gravity = 1.0;
			mPS.drag = 2.0;
			mPS.SetSpringConstant(0.5);
			mPS.SetSpringDampingConstant(1);
			mSurface.SetMassProportion(1); // proportional to numer of particles in x
			break;

		case 'j':
			mSurfaceConditionsName = "Jello";
			mSurface.SetAmbientColor( 1.0, 0.0, 0.0, 1.0 );
			mSurface.SetDiffuseColor( 1.0, 0.0, 0.0, 1.0 );
			mSurface.SetSpecularColor( 1.0, 1.0, 1.0, 1.0 );
			mSurface.SetShininess( 100.0 );
			mPS.gravity = 0;
			mPS.drag = 0.1;
			mPS.SetSpringConstant(10);
			mPS.SetSpringDampingConstant(2);
			mSurface.SetMassProportion(1); // proportional to numer of particles in x
			break;

		case 'w':
			mSurfaceConditionsName = "Waterbed";
			mSurface.SetAmbientColor( 0.4, 1.0, 0.2, 1.0 );
			mSurface.SetDiffuseColor( 0.1, 0.8, 0.5, 1.0 );
			mSurface.SetSpecularColor( 0.6, 0.6, 1.0, 1.0 );
			mSurface.SetShininess( 200.0 );
			mPS.gravity = 2;
			mPS.drag = 0.001;
			mPS.SetSpringConstant(1);
			mPS.SetSpringDampingConstant(1);
			mSurface.SetMassProportion(1); // proportional to numer of particles in x
			break;

		case '1':
			mSurfaceParticles = 3;
			ConstructSurface(mSurfaceParticles);
			break;

		case '2':
			mSurfaceParticles = 5;
			ConstructSurface(mSurfaceParticles);
			break;

		case '3':
			mSurfaceParticles = 10;
			ConstructSurface(mSurfaceParticles);
			break;

		case '4':
			mSurfaceParticles = 15;
			ConstructSurface(mSurfaceParticles);
			break;
		
		case '5':
			mSurfaceParticles = 20;
			ConstructSurface(mSurfaceParticles);
			break;
		
		case '6':
			mSurfaceParticles = 25;
			ConstructSurface(mSurfaceParticles);
			break;
		
		case '7':
			mSurfaceParticles = 30;
			ConstructSurface(mSurfaceParticles);
			break;
		
		case '8':
			mSurfaceParticles = 35;
			ConstructSurface(mSurfaceParticles);
			break;
		
		case '9':
			mSurfaceParticles = 40;
			ConstructSurface(mSurfaceParticles);
			break;
		
		case '0':
			mSurfaceParticles = 50;
			ConstructSurface(mSurfaceParticles);
			break;
		
		case 'n':
			mDrawNormals = !mDrawNormals;
			break;

		case 'i':
			mDrawInfo = (EDrawInfo)(mDrawInfo + 1);
			if (mDrawInfo >= drawInfo_PastEndOfList)
				mDrawInfo = drawInfo_StartOfList;
			break;

		case 's':
			mDrawSurface = !mDrawSurface;
			mPS.useDepthForMouseZ = mDrawSurface;
			break;

		case 'p':
			mDrawSystem = !mDrawSystem;
			break;

		case 'm':
			if (mPause)
				AdvanceTime(mManualTimeStep);
			break;

		case 'x':
			mUseFixedTimeStep = !mUseFixedTimeStep;
			break;
			
		case ' ':
			mPause = !mPause;
			break;

		case 'q':		// quit
			exit(0);
			break;

		default:
			//printf("Invalid menu choice: %c", option);
			break;
	}
}