public Campfire(Game game)
        {
            parentGame = game;
            // TODO: use this.Content to load your game content here
            logs = parentGame.Content.Load<Texture2D>("logs");

            // Declare a new Particle System instance and Initialize it
            mcParticleSystem = new FireParticleSystem(parentGame);
            mcParticleSystem.AutoInitialize(parentGame.GraphicsDevice, parentGame.Content, null);
        }
		/// <summary>
		/// Load your graphics content
		/// </summary>
		protected override void LoadContent()
		{
			mcSpriteBatch = new SpriteBatch(GraphicsDevice);

			// Load fonts and models for test application
			mcFont = Content.Load<SpriteFont>("Fonts/font");
			mcFloorModel = Content.Load<Model>("grid");
			mcSphereModel = Content.Load<Model>("SphereHighPoly");

			// Setup our render target to draw to when we want draws to persist across multiple frames
			_renderTarget = new RenderTarget2D(mcGraphics.GraphicsDevice, mcGraphics.PreferredBackBufferWidth, mcGraphics.PreferredBackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);

			// Specify vertices indicating positive axis directions
			int iLineLength = 50;
			msaAxisDirectionVertices = new VertexPositionColor[6];
			msaAxisDirectionVertices[0] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Red);
			msaAxisDirectionVertices[1] = new VertexPositionColor(new Vector3(iLineLength, 1, 0), Color.Red);
			msaAxisDirectionVertices[2] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Green);
			msaAxisDirectionVertices[3] = new VertexPositionColor(new Vector3(0, iLineLength, 0), Color.Green);
			msaAxisDirectionVertices[4] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Blue);
			msaAxisDirectionVertices[5] = new VertexPositionColor(new Vector3(0, 1, iLineLength), Color.Blue);
			
			mcAxisEffect = new BasicEffect(GraphicsDevice);
			mcAxisEffect.VertexColorEnabled = true;
			mcAxisEffect.LightingEnabled = false;
			mcAxisEffect.TextureEnabled = false;
			mcAxisEffect.FogEnabled = false;
			mcAxisVertexDeclaration = VertexPositionColor.VertexDeclaration;

			// Instantiate all of the Particle Systems
			mcDPSFSplashScreenParticleSystem = new DPSFSplashScreenParticleSystem(this);
			mcRandomParticleSystem = new RandomParticleSystem(this);
			mcFireParticleSystem = new FireParticleSystem(this);
			mcFireSpriteParticleSystem = new FireSpriteParticleSystem(this);
			mcSmokeParticleSystem = new SmokeParticleSystem(this);
			mcSnowParticleSystem = new SnowParticleSystem(this);
			mcSquarePatternParticleSystem = new SquarePatternParticleSystem(this);
			mcFountainParticleSystem = new FountainParticleSystem(this);
			mcRandom2DParticleSystem = new Random2DParticleSystem(this);
			mcGasFallParticleSystem = new GasFallParticleSystem(this);
			mcDotParticleSystem = new DotParticleSystem(this);
			mcFireworksParticleSystem = new FireworksParticleSystem(this);
			mcFigure8ParticleSystem = new Figure8ParticleSystem(this);
			mcStarParticleSystem = new StarParticleSystem(this);
			mcBallParticleSystem = new BallParticleSystem(this);
			mcRotatingQuadParticleSystem = new RotatingQuadsParticleSystem(this);
			mcBoxParticleSystem = new BoxParticleSystem(this);
			mcImageParticleSystem = new ImageParticleSystem(this);
			mcAnimatedQuadParticleSystem = new AnimatedQuadParticleSystem(this);
			mcSpriteParticleSystem = new SpriteParticleSystem(this);
			mcAnimatedSpriteParticleSystem = new AnimatedSpriteParticleSystem(this);
			mcQuadSprayParticleSystem = new QuadSprayParticleSystem(this);
			mcMagnetParticleSystem = new MagnetsParticleSystem(this);
			mcSparklerParticleSystem = new SparklerParticleSystem(this);
			mcGridQuadParticleSystem = new GridQuadParticleSystem(this);
			mcSphereParticleSystem = new SphereParticleSystem(this);
			mcMultipleImagesParticleSystem = new MultipleParticleImagesParticleSystem(this);
			mcMultipleImagesSpriteParticleSystem = new MultipleParticleImagesSpriteParticleSystem(this);
			mcExplosionFireSmokeParticleSystem = new ExplosionFireSmokeParticleSystem(this);
			mcExplosionFlashParticleSystem = new ExplosionFlashParticleSystem(this);
			mcExplosionFlyingSparksParticleSystem = new ExplosionFlyingSparksParticleSystem(this);
			mcExplosionSmokeTrailsParticleSystem = new ExplosionSmokeTrailsParticleSystem(this);
			mcExplosionRoundSparksParticleSystem = new ExplosionRoundSparksParticleSystem(this);
			mcExplosionDebrisParticleSystem = new ExplosionDebrisParticleSystem(this);
			mcExplosionShockwaveParticleSystem = new ExplosionShockwaveParticleSystem(this);
			mcExplosionParticleSystem = new ExplosionParticleSystem(this);
			mcTrailParticleSystem = new TrailParticleSystem(this);
			mcSpriteParticleSystemTemplate = new SpriteParticleSystemTemplate(this);
			mcSprite3DBillboardParticleSystemTemplate = new Sprite3DBillboardParticleSystemTemplate(this);
			mcQuadParticleSystemTemplate = new QuadParticleSystemTemplate(this);
			mcTexturedQuadParticleSystemTemplate = new TexturedQuadParticleSystemTemplate(this);
			mcDefaultSpriteParticleSystemTemplate = new DefaultSpriteParticleSystemTemplate(this);
			mcDefaultSprite3DBillboardParticleSystemTemplate = new DefaultSprite3DBillboardParticleSystemTemplate(this);
			mcDefaultQuadParticleSystemTemplate = new DefaultQuadParticleSystemTemplate(this);
			mcDefaultTexturedQuadParticleSystemTemplate = new DefaultTexturedQuadParticleSystemTemplate(this);

			mcDPSFSplashScreenParticleSystem.DrawOrder = 10;
			mcRandomParticleSystem.DrawOrder = 100;
			mcFireParticleSystem.DrawOrder = 200;
			mcFireSpriteParticleSystem.DrawOrder = 250;
			mcSmokeParticleSystem.DrawOrder = 300;
			mcSnowParticleSystem.DrawOrder = 400;
			mcSquarePatternParticleSystem.DrawOrder = 500;
			mcFountainParticleSystem.DrawOrder = 600;
			mcRandom2DParticleSystem.DrawOrder = 700;
			mcGasFallParticleSystem.DrawOrder = 800;
			mcDotParticleSystem.DrawOrder = 900;
			mcFireworksParticleSystem.DrawOrder = 1000;
			mcFigure8ParticleSystem.DrawOrder = 1100;
			mcStarParticleSystem.DrawOrder = 1200;
			mcBallParticleSystem.DrawOrder = 1300;
			mcRotatingQuadParticleSystem.DrawOrder = 1400;
			mcBoxParticleSystem.DrawOrder = 1500;
			mcImageParticleSystem.DrawOrder = 1600;
			mcAnimatedQuadParticleSystem.DrawOrder = 1700;
			mcSpriteParticleSystem.DrawOrder = 1800;
			mcAnimatedSpriteParticleSystem.DrawOrder = 1900;
			mcQuadSprayParticleSystem.DrawOrder = 1925;
			mcMagnetParticleSystem.DrawOrder = 1950;
			mcSparklerParticleSystem.DrawOrder = 1960;
			mcGridQuadParticleSystem.DrawOrder = 1980;
			mcSphereParticleSystem.DrawOrder = 1990;
			mcMultipleImagesParticleSystem.DrawOrder = 2000;
			mcMultipleImagesSpriteParticleSystem.DrawOrder = 2005;
			mcExplosionFireSmokeParticleSystem.DrawOrder = 2010;
			mcExplosionFlashParticleSystem.DrawOrder = 2020;
			mcExplosionFlyingSparksParticleSystem.DrawOrder = 2030;
			mcExplosionSmokeTrailsParticleSystem.DrawOrder = 2040;
			mcExplosionRoundSparksParticleSystem.DrawOrder = 2050;
			mcExplosionDebrisParticleSystem.DrawOrder = 2060;
			mcExplosionShockwaveParticleSystem.DrawOrder = 2070;
			mcExplosionParticleSystem.DrawOrder = 2080;
			mcTrailParticleSystem.DrawOrder = 2090;
			mcSpriteParticleSystemTemplate.DrawOrder = 2200;
			mcSprite3DBillboardParticleSystemTemplate.DrawOrder = 2300;
			mcQuadParticleSystemTemplate.DrawOrder = 2350;
			mcTexturedQuadParticleSystemTemplate.DrawOrder = 2400;
			mcDefaultSpriteParticleSystemTemplate.DrawOrder = 2600;
			mcDefaultSprite3DBillboardParticleSystemTemplate.DrawOrder = 2700;
			mcDefaultQuadParticleSystemTemplate.DrawOrder = 2750;
			mcDefaultTexturedQuadParticleSystemTemplate.DrawOrder = 2800;

			// Add all Particle Systems to the Particle System Manager
			mcParticleSystemManager.AddParticleSystem(mcDPSFSplashScreenParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcRandomParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcFireParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcFireSpriteParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcSmokeParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcSnowParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcSquarePatternParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcFountainParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcRandom2DParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcGasFallParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcDotParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcFireworksParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcFigure8ParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcStarParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcBallParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcRotatingQuadParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcBoxParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcImageParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcAnimatedQuadParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcSpriteParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcAnimatedSpriteParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcQuadSprayParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcMagnetParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcSparklerParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcGridQuadParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcSphereParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcMultipleImagesParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcMultipleImagesSpriteParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionFireSmokeParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionFlashParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionFlyingSparksParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionSmokeTrailsParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionRoundSparksParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionDebrisParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionShockwaveParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcExplosionParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcTrailParticleSystem);
			mcParticleSystemManager.AddParticleSystem(mcSpriteParticleSystemTemplate);
			mcParticleSystemManager.AddParticleSystem(mcSprite3DBillboardParticleSystemTemplate);
			mcParticleSystemManager.AddParticleSystem(mcQuadParticleSystemTemplate);
			mcParticleSystemManager.AddParticleSystem(mcTexturedQuadParticleSystemTemplate);
			mcParticleSystemManager.AddParticleSystem(mcDefaultSpriteParticleSystemTemplate);
			mcParticleSystemManager.AddParticleSystem(mcDefaultSprite3DBillboardParticleSystemTemplate);
			mcParticleSystemManager.AddParticleSystem(mcDefaultQuadParticleSystemTemplate);
			mcParticleSystemManager.AddParticleSystem(mcDefaultTexturedQuadParticleSystemTemplate);

			// Set how often the Particle Systems should be Updated
			mcParticleSystemManager.UpdatesPerSecond = miPARTICLE_SYSTEM_UPDATES_PER_SECOND;

			// Hide text and other things while displaying the Splash Screen
			mbShowText = false; mbShowFloor = false;

			// Setup the Splash Screen to display before anything else
			mcDPSFSplashScreenParticleSystem.AutoInitialize(this.GraphicsDevice, this.Content, null);
			mcDPSFSplashScreenParticleSystem.SplashScreenComplete += new EventHandler(mcDPSFSplashScreenParticleSystem_SplashScreenComplete);
			mcCurrentParticleSystem = mcDPSFSplashScreenParticleSystem;
		}
        public Campfire(Game game, World world, SpriteBatch batch, Vector2 position)
        {
            //Set the parent game
            _parentGame = game;

            //Initialize the logs
            _logs = _parentGame.Content.Load<Texture2D>("EnvironmentObjects/logs");
            //Initialize the scale (we're scaling down the logs when we draw instead of in the original image to show off that capability)
            _scale = new Vector2(0.5f, 0.45f);
            //No rotation
            _rotation = 0f;
            //No sprite effects
            _spriteEffects = SpriteEffects.None;
            //Layer depth to front layer
            _layerDepth = 0f;

            //Create an array to hold the data from the texture
            uint[] data = new uint[_logs.Width * _logs.Height];

            //Transfer the texture data to the array
            _logs.GetData(data);

            //Find the vertices that makes up the outline of the shape in the texture
            Vertices textureVertices = PolygonTools.CreatePolygon(data, _logs.Width, false);

            //The tool return vertices as they were found in the texture.
            //We need to find the real center (centroid) of the vertices for 2 reasons:

            //1. To translate the vertices so the polygon is centered around the centroid.
            Vector2 centroid = -textureVertices.GetCentroid();
            textureVertices.Translate(ref centroid);

            //2. To draw the texture the correct place.
            _origin = -centroid;

            //We simplify the vertices found in the texture.
            textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f);

            //Since it is a concave polygon, we need to partition it into several smaller convex polygons
            List<Vertices> list = BayazitDecomposer.ConvexPartition(textureVertices);

            //scale the vertices from graphics space to sim space
            Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * _scale;
            foreach (Vertices vertices in list)
            {
                vertices.Scale(ref vertScale);
            }

            //Create a single body with multiple fixtures
            _body = BodyFactory.CreateCompoundPolygon(world, list, 1f, BodyType.Dynamic);
            _body.BodyType = BodyType.Static;
            _body.CollidesWith = Category.All;
            _body.Position = position;

            // Declare a new Particle System instance and Initialize it
            _particleSystem = new FireParticleSystem(_parentGame);
            _particleSystem.AutoInitialize(_parentGame.GraphicsDevice, _parentGame.Content, batch);
        }