public ParticleSystemInstance(ParticleSystem system)
        {
            if (system == null)
            {
                throw new ArgumentNullException("system");
            }

            System = system;
            RefreshEffectInstances();
        }
Example #2
0
		public void Open()
		{
			if (!CloseDocument() || openFileDialog.ShowDialog() != DialogResult.OK)
			{
				return;
			}

			var fileName = openFileDialog.FileName;
			using (XmlReader xr = XmlReader.Create(fileName))
			{
				m_fileName = fileName;
				m_particleSystem = IntermediateSerializer.Deserialize<ParticleSystem>(xr, Path.GetDirectoryName(fileName));
			}

			OnDocumentOpen();
			SetModified(false);
		}
        public XnaRect ResolveUVBounds(string uvBoundsName, ParticleSystem system)
        {
            uvBoundsName = uvBoundsName ?? "{Whole}";
            if (uvBoundsName == "{Whole}")
            {
                return system != null && system.TextureObject != null
                       ? new XnaRect(0, 0, system.TextureObject.Width, system.TextureObject.Height)
                       : XnaRect.Empty;
            }
            else if (uvBoundsName.StartsWith("{") && uvBoundsName.EndsWith("}"))
            {
                string[][] tokens = uvBoundsName.Substring(1, uvBoundsName.Length - 2)
                                    .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                    .Select(t => t.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)).ToArray();
                int x, y, w, h;
                if (tokens.Length != 4 || tokens.Any(t => t.Length != 2)
                    || tokens[0][0] != "x" || !int.TryParse(tokens[0][1], out x)
                    || tokens[1][0] != "y" || !int.TryParse(tokens[1][1], out y)
                    || (tokens[2][0] != "width" && tokens[2][0] != "w") || !int.TryParse(tokens[2][1], out w)
                    || (tokens[3][0] != "height" && tokens[3][0] != "h") || !int.TryParse(tokens[3][1], out h))
                {
                    throw new FormatException(String.Format("Cannot convert '{0}' to a rectangle.", uvBoundsName));
                }
                return new XnaRect(x, y, w, h);
            }
            else if (system == null)
            {
                return XnaRect.Empty;
            }
            else
            {
                var atlas = ResolveAtlas(system.TextureName);
                if (atlas == null || !atlas.SubTextures.ContainsKey(uvBoundsName))
                {
                    return XnaRect.Empty;
                }

                return atlas.SubTextures[uvBoundsName].Bounds;
            }
        }
Example #4
0
		public void New()
		{
			if (!CloseDocument())
			{
				return;
			}

			m_fileName = null;
			m_particleSystem = new ParticleSystem();

			var effect = new Effect { Capacity = 1000 };
			effect.Name = "New Effect";
			effect.EmissionRate = 50.0f;
			effect.DefaultParticleLifetime = 3.0f;
			effect.DefaultParticleSize = new Microsoft.Xna.Framework.Vector2(1, 1);
			effect.DefaultParticleColor = new Microsoft.Xna.Framework.Color(255, 255, 255, 128);
			effect.ModifiersOnEmit.Add(new Modifiers.RandomPositionInSphere { Radius = 5 });
			effect.ModifiersOnUpdate.Add(new Modifiers.Accelerate { Acceleration = Microsoft.Xna.Framework.Vector3.UnitZ * 10 });

			m_particleSystem.Effects.Add(effect);

			OnDocumentOpen();
			SetModified(true);
		}
Example #5
0
 public XnaRect ResolveUVBounds(string uvBoundsName, ParticleSystem system) { return XnaRect.Empty; }