agate-svn-commit Mailing List for AgateLib (Page 22)
Status: Alpha
Brought to you by:
kanato
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
(86) |
May
(77) |
Jun
|
Jul
(1) |
Aug
(31) |
Sep
(12) |
Oct
(31) |
Nov
(53) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(53) |
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
(7) |
Dec
(13) |
2011 |
Jan
(17) |
Feb
(5) |
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
(21) |
Dec
|
2012 |
Jan
(6) |
Feb
(14) |
Mar
(5) |
Apr
(4) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(8) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
(5) |
Nov
(9) |
Dec
(5) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
|
Jun
(5) |
Jul
(33) |
Aug
(69) |
Sep
(35) |
Oct
(4) |
Nov
(1) |
Dec
|
From: <ac...@us...> - 2009-08-18 16:24:52
|
Revision: 1012 http://agate.svn.sourceforge.net/agate/?rev=1012&view=rev Author: accagon Date: 2009-08-18 16:24:45 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Added triggering of events in emitters. Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs branches/particles/AgateLib/Particles/ParticleEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-08-18 16:17:29 UTC (rev 1011) +++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-08-18 16:24:45 UTC (rev 1012) @@ -165,6 +165,7 @@ Particles[index].Life = EmitLife; Particles[index].Position = Position; Particles[index].Velocity = EmitVelocity; + NewRecyledParticle(Particles[index]); } else if(Particles.Count < Particles.Capacity) { @@ -176,6 +177,7 @@ pp.Life = EmitLife; pp.Position = Position; pp.Velocity = EmitVelocity; + NewParticle(pp); Particles.Add(pp); } else Modified: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-08-18 16:17:29 UTC (rev 1011) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-08-18 16:24:45 UTC (rev 1012) @@ -183,6 +183,7 @@ Particles[index].Life = EmitLife; Particles[index].Position = Position; Particles[index].Velocity = EmitVelocity; + NewRecyledParticle(Particles[index]); } else if(Particles.Count < Particles.Capacity) { @@ -196,6 +197,7 @@ sp.Life = EmitLife; sp.Position = Position; sp.Velocity = EmitVelocity; + NewRecyledParticle(sp); Particles.Add(sp); } else Modified: branches/particles/AgateLib/Particles/ParticleEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-08-18 16:17:29 UTC (rev 1011) +++ branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-08-18 16:24:45 UTC (rev 1012) @@ -148,7 +148,7 @@ /// <param name="particle"> /// Dead particle. /// </param> - protected void DeadParticle(Particle particle) + protected void NewDeadParticle(Particle particle) { if(OnDeadParticle != null) OnDeadParticle(this, new ParticleArgs(particle)); @@ -160,7 +160,7 @@ /// <param name="particle"> /// Recyled particle. /// </param> - protected void RecyledParticle(Particle particle) + protected void NewRecyledParticle(Particle particle) { if(OnRecyledParticle != null) OnRecyledParticle(this, new ParticleArgs(particle)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-08-18 16:17:38
|
Revision: 1011 http://agate.svn.sourceforge.net/agate/?rev=1011&view=rev Author: accagon Date: 2009-08-18 16:17:29 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Merged ScaleWidth and ScaleHeight to Scale. Old ScaleWidth/Height properties are still available. Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs branches/particles/AgateLib/Particles/ParticleEmitter.cs branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs Modified: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-08-10 21:57:50 UTC (rev 1010) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-08-18 16:17:29 UTC (rev 1011) @@ -39,16 +39,15 @@ private double mEmitAlpha = 1d; - private float mEmitScaleWidth = 1f; - private float mEmitScaleHeight = 1f; + private SizeF mEmitScale = new SizeF(1f, 1f); /// <value> /// Gets or sets the scale width of emitting particles. /// </value> public float EmitScaleWidth { - get { return mEmitScaleWidth; } - set { mEmitScaleWidth = value; } + get { return mEmitScale.Width; } + set { mEmitScale.Width = value; } } /// <value> @@ -56,9 +55,18 @@ /// </value> public float EmitScaleHeight { - get { return mEmitScaleHeight; } - set { mEmitScaleHeight = value; } + get { return mEmitScale.Height; } + set { mEmitScale.Height = value; } } + + /// <value> + /// Gets or sets the scale of emitting particles. + /// </value> + public SizeF EmitScale + { + get { return mEmitScale; } + set { mEmitScale = value; } + } /// <value> /// Gets or sets the alpha channel of emitting particles. @@ -170,8 +178,7 @@ Particles[index].Acceleration = EmitAcceleration; (Particles[index] as SurfaceParticle).SurfaceKey = mEmitSurfaceKey; (Particles[index] as SurfaceParticle).Alpha = mEmitAlpha; - (Particles[index] as SurfaceParticle).ScaleHeight = mEmitScaleHeight; - (Particles[index] as SurfaceParticle).ScaleWidth = mEmitScaleWidth; + (Particles[index] as SurfaceParticle).Scale = mEmitScale; Particles[index].Condition = Condition.Alive; Particles[index].Life = EmitLife; Particles[index].Position = Position; @@ -184,8 +191,7 @@ sp.Acceleration = EmitAcceleration; sp.SurfaceKey = mEmitSurfaceKey; sp.Alpha = mEmitAlpha; - sp.ScaleHeight = mEmitScaleHeight; - sp.ScaleWidth = EmitScaleWidth; + sp.Scale = mEmitScale; sp.Condition = Condition.Alive; sp.Life = EmitLife; sp.Position = Position; Modified: branches/particles/AgateLib/Particles/ParticleEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-08-10 21:57:50 UTC (rev 1010) +++ branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-08-18 16:17:29 UTC (rev 1011) @@ -125,13 +125,48 @@ base.Update (time_ms); } - // TODO: Find a way how to trigger the events below public delegate void ParticleEventHandler(object sender, ParticleArgs args); public event ParticleEventHandler OnNewParticle; public event ParticleEventHandler OnDeadParticle; public event ParticleEventHandler OnRecyledParticle; /// <summary> + /// Triggers a new <see cref="OnNewParticle"/> event. + /// </summary> + /// <param name="particle"> + /// A newly created particle. + /// </param> + protected void NewParticle(Particle particle) + { + if(OnNewParticle != null) + OnNewParticle(this, new ParticleArgs(particle)); + } + + /// <summary> + /// Triggers a new <see cref="OnDeadParticle"/> event. + /// </summary> + /// <param name="particle"> + /// Dead particle. + /// </param> + protected void DeadParticle(Particle particle) + { + if(OnDeadParticle != null) + OnDeadParticle(this, new ParticleArgs(particle)); + } + + /// <summary> + /// Triggers a new <see cref="OnRecyledParticle"/> event. + /// </summary> + /// <param name="particle"> + /// Recyled particle. + /// </param> + protected void RecyledParticle(Particle particle) + { + if(OnRecyledParticle != null) + OnRecyledParticle(this, new ParticleArgs(particle)); + } + + /// <summary> /// Update event handler. /// </summary> public delegate void UpdateEventHandler(UpdateArgs args); @@ -140,6 +175,18 @@ /// The event is called in <see cref="ParticleEmitter.Update"/>. /// </summary> public event UpdateEventHandler OnUpdate; + + /// <summary> + /// Triggers a new <see cref="OnUpdate"/> event + /// </summary> + /// <param name="time_ms"> + /// Time in milliseconds. + /// </param> + protected void NewUpdate(double time_ms) + { + if(OnUpdate != null) + OnUpdate(new UpdateArgs(this, time_ms)); + } } /// <summary> Modified: branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs =================================================================== --- branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs 2009-08-10 21:57:50 UTC (rev 1010) +++ branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs 2009-08-18 16:17:29 UTC (rev 1011) @@ -17,7 +17,7 @@ // Contributor(s): Marcel Hauf. // using System; - +using AgateLib.Geometry; using AgateLib.DisplayLib; namespace AgateLib.Particles @@ -31,8 +31,7 @@ private double mAlpha = 1d; - private float mScaleWidth = 1f; - private float mScaleHeight = 1f; + private SizeF mScale = new SizeF(1f, 1f); /// <value> /// Gets or sets the surface key. @@ -57,8 +56,8 @@ /// </value> public float ScaleWidth { - get { return mScaleWidth; } - set { mScaleWidth = value; } + get { return mScale.Width; } + set { mScale.Width = value; } } /// <value> @@ -66,10 +65,19 @@ /// </value> public float ScaleHeight { - get { return mScaleHeight; } - set { mScaleHeight = value; } + get { return mScale.Height; } + set { mScale.Height = value; } } + /// <value> + /// Gets or sets the scale. + /// </value> + public SizeF Scale + { + get { return mScale; } + set { mScale = value; } + } + /// <summary> /// Constructs a SurfaceParticle with a default SurfaceKey=0. /// </summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-10 21:57:58
|
Revision: 1010 http://agate.svn.sourceforge.net/agate/?rev=1010&view=rev Author: kanato Date: 2009-08-10 21:57:50 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Add ToBitmap converter for surfaces. Modified Paths: -------------- trunk/Drivers/AgateLib.WinForms/FormsInterop.cs Modified: trunk/Drivers/AgateLib.WinForms/FormsInterop.cs =================================================================== --- trunk/Drivers/AgateLib.WinForms/FormsInterop.cs 2009-08-10 21:57:14 UTC (rev 1009) +++ trunk/Drivers/AgateLib.WinForms/FormsInterop.cs 2009-08-10 21:57:50 UTC (rev 1010) @@ -21,6 +21,7 @@ using System.Text; using Draw = System.Drawing; using AgateLib.Geometry; +using AgateLib.DisplayLib; namespace AgateLib.WinForms { @@ -30,6 +31,23 @@ /// </summary> public static class Interop { + public static System.Drawing.Bitmap ToBitmap(this Surface surf) + { + string filename = System.IO.Path.GetTempFileName(); + + surf.SaveTo(filename); + + System.Drawing.Bitmap retval; + + using (var stream = System.IO.File.OpenRead(filename)) + { + retval = new System.Drawing.Bitmap(stream); + } + + System.IO.File.Delete(filename); + + return retval; + } /// <summary> /// Converts color structures. /// </summary> @@ -105,7 +123,7 @@ /// </summary> /// <param name="pt"></param> /// <returns></returns> - public static Draw.Point Convert(Point pt) + public static Draw.Point Convert(this Point pt) { return new Draw.Point(pt.X, pt.Y); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-10 21:57:21
|
Revision: 1009 http://agate.svn.sourceforge.net/agate/?rev=1009&view=rev Author: kanato Date: 2009-08-10 21:57:14 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Fixed XleSerializer.cs when int array has zero size. Modified Paths: -------------- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs trunk/AgateLib/Serialization/Xle/XleSerializer.cs Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2009-08-01 21:59:29 UTC (rev 1008) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2009-08-10 21:57:14 UTC (rev 1009) @@ -292,11 +292,14 @@ { byte[] array = new byte[value.Length * 4]; - unsafe + if (array.Length > 0) { - fixed (int* val = value) + unsafe { - Marshal.Copy((IntPtr)val, array, 0, array.Length); + fixed (int* val = value) + { + Marshal.Copy((IntPtr)val, array, 0, array.Length); + } } } Write(name, array); @@ -411,6 +414,27 @@ nodes.Pop(); } /// <summary> + /// Writes a List<T> of strings to the XML data as an element. + /// </summary> + /// <param name="name">The name of the XML element used.</param> + /// <param name="value">The list data to write.</param> + public void Write(string name, List<string> value) + { + XmlElement element = CreateElement(name); + AddAttribute(element, "array", "true"); + + nodes.Push(element); + + for (int i = 0; i < value.Count; i++) + { + XmlElement item = doc.CreateElement("Item"); + CurrentNode.AppendChild(item); + item.InnerText = value[i]; + } + + nodes.Pop(); + } + /// <summary> /// Writes a Dictionary of objects implementing IXleSerializable to the XML data as an element. /// The key type must implement IConvertible and the value type must implment IXleSerializable. /// </summary> @@ -425,7 +449,7 @@ Type valueType = typeof(Tvalue); XmlElement element = CreateElement(name); - //AddAttribute(element, "dictionary", "true"); + AddAttribute(element, "dictionary", "true"); //AddAttribute(element, "keytype", keyType.ToString()); //AddAttribute(element, "valuetype", valueType.ToString()); @@ -606,7 +630,22 @@ /// <param name="name">The name of the element in the XML stream to decode.</param> /// <returns></returns> [CLSCompliant(false)] + [Obsolete("Use ReadDictionaryString instead.")] public Dictionary<Tkey, string> ReadDictionary<Tkey>(string name) + where Tkey : IConvertible + { + return ReadDictionaryString<Tkey>(name); + } + /// <summary> + /// Reads a dictionary type of strings from the XML data. + /// The key type must implement IConvertible and the value type must implement + /// IXleSerializable. + /// </summary> + /// <typeparam name="Tkey">The key type of the dictionary.</typeparam> + /// <param name="name">The name of the element in the XML stream to decode.</param> + /// <returns></returns> + [CLSCompliant(false)] + public Dictionary<Tkey, string> ReadDictionaryString<Tkey>(string name) where Tkey : IConvertible { XmlElement element = (XmlElement)CurrentNode[name]; @@ -631,6 +670,29 @@ return retval; } + public Dictionary<Tkey, int> ReadDictionaryInt32<Tkey>(string name) + { + XmlElement element = (XmlElement)CurrentNode[name]; + + nodes.Push(element); + + Dictionary<Tkey, int> retval = new Dictionary<Tkey, int>(); + + for (int i = 0; i < element.ChildNodes.Count; i++) + { + XmlElement current = (XmlElement)CurrentNode.ChildNodes[i]; + string keyString = current.GetAttribute("key"); + Tkey key = (Tkey)Convert.ChangeType(keyString, typeof(Tkey)); + + string valueString = current.GetAttribute("value"); + + retval.Add(key, int.Parse(valueString)); + } + + nodes.Pop(); + + return retval; + } /// <summary> /// Reads an object from the XML data. /// </summary> @@ -823,11 +885,14 @@ if (array.Length % 4 != 0) throw new XleSerializationException("Encoded array is wrong size!"); - unsafe + if (array.Length > 0) { - fixed (byte* ar = array) + unsafe { - Marshal.Copy((IntPtr)ar, result, 0, result.Length); + fixed (byte* ar = array) + { + Marshal.Copy((IntPtr)ar, result, 0, result.Length); + } } } @@ -937,12 +1002,19 @@ if (item.Name != "Item") throw new XleSerializationException("Could not understand data. Expected Item, found " + item.Name + "."); - nodes.Push(item); + if (type == typeof(string)) + { + list.Add(item.InnerText); + } + else + { + nodes.Push(item); - object o = DeserializeObject(type); - list.Add(o); + object o = DeserializeObject(type); + list.Add(o); - nodes.Pop(); + nodes.Pop(); + } } Array retval = (Array)Activator.CreateInstance(arrayType, list.Count); @@ -1065,5 +1137,6 @@ return obj; } + } } Modified: trunk/AgateLib/Serialization/Xle/XleSerializer.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2009-08-01 21:59:29 UTC (rev 1008) +++ trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2009-08-10 21:57:14 UTC (rev 1009) @@ -66,7 +66,7 @@ public void Serialize(Stream outStream, IXleSerializable objectGraph) { if (objectType.IsAssignableFrom(objectGraph.GetType()) == false) - throw new ArgumentException("Object is not of type " + objectType.GetType()); + throw new ArgumentException("Object is not of type " + objectType.Name); XleSerializationInfo info = new XleSerializationInfo(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-01 21:59:36
|
Revision: 1008 http://agate.svn.sourceforge.net/agate/?rev=1008&view=rev Author: kanato Date: 2009-08-01 21:59:29 +0000 (Sat, 01 Aug 2009) Log Message: ----------- Add IXleSerializable to floating point geometry structures. Add some more read/write methods to XleSerializationInfo. Modified Paths: -------------- trunk/AgateLib/Geometry/PointF.cs trunk/AgateLib/Geometry/RectangleF.cs trunk/AgateLib/Geometry/SizeF.cs trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs Modified: trunk/AgateLib/Geometry/PointF.cs =================================================================== --- trunk/AgateLib/Geometry/PointF.cs 2009-08-01 21:03:22 UTC (rev 1007) +++ trunk/AgateLib/Geometry/PointF.cs 2009-08-01 21:59:29 UTC (rev 1008) @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Text; +using AgateLib.Serialization.Xle; namespace AgateLib.Geometry { @@ -26,7 +27,7 @@ /// Replacement for System.Drawing.PointF structure. /// </summary> [Serializable] - public struct PointF + public struct PointF : IXleSerializable { float x, y; @@ -61,6 +62,18 @@ this.y = size.Height; } + + void IXleSerializable.WriteData(XleSerializationInfo info) + { + info.Write("X", X, true); + info.Write("Y", Y, true); + } + void IXleSerializable.ReadData(XleSerializationInfo info) + { + X = info.ReadFloat("X"); + Y = info.ReadFloat("Y"); + } + #endregion #region --- Public Properties --- Modified: trunk/AgateLib/Geometry/RectangleF.cs =================================================================== --- trunk/AgateLib/Geometry/RectangleF.cs 2009-08-01 21:03:22 UTC (rev 1007) +++ trunk/AgateLib/Geometry/RectangleF.cs 2009-08-01 21:59:29 UTC (rev 1008) @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; +using AgateLib.Serialization.Xle; namespace AgateLib.Geometry { @@ -28,7 +29,7 @@ /// </summary> [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] - public struct RectangleF + public struct RectangleF : IXleSerializable { PointF pt; SizeF sz; @@ -56,6 +57,24 @@ this.sz = sz; } + #region IXleSerializable Members + + void IXleSerializable.WriteData(XleSerializationInfo info) + { + info.Write("X", X, true); + info.Write("Y", Y, true); + info.Write("Width", Width, true); + info.Write("Height", Height, true); + } + void IXleSerializable.ReadData(XleSerializationInfo info) + { + X = info.ReadFloat("X"); + Y = info.ReadFloat("Y"); + Width = info.ReadFloat("Width"); + Height = info.ReadFloat("Height"); + } + + #endregion /// <summary> /// Static method which returns a RectangleF with specified left, top, right and bottom. /// </summary> Modified: trunk/AgateLib/Geometry/SizeF.cs =================================================================== --- trunk/AgateLib/Geometry/SizeF.cs 2009-08-01 21:03:22 UTC (rev 1007) +++ trunk/AgateLib/Geometry/SizeF.cs 2009-08-01 21:59:29 UTC (rev 1008) @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; +using AgateLib.Serialization.Xle; namespace AgateLib.Geometry { @@ -28,7 +29,7 @@ /// </summary> [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] - public struct SizeF + public struct SizeF : IXleSerializable { float width, height; @@ -53,6 +54,20 @@ this.height = height; } + #region IXleSerializable Members + + void IXleSerializable.WriteData(XleSerializationInfo info) + { + info.Write("Width", Width, true); + info.Write("Height", Height, true); + } + void IXleSerializable.ReadData(XleSerializationInfo info) + { + Width = info.ReadFloat("Width"); + Height = info.ReadFloat("Height"); + } + + #endregion /// <summary> /// Gets or sets the width. /// </summary> Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2009-08-01 21:03:22 UTC (rev 1007) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2009-08-01 21:59:29 UTC (rev 1008) @@ -303,7 +303,23 @@ } + /// <summary> + /// Writes a bool[] array to the XML data as an element. + /// </summary> + /// <param name="name">The name of the XML element used.</param> + /// <param name="value">The array data to write.</param> + public void Write(string name, bool[] value) + { + byte[] array = new byte[value.Length]; + + for (int i = 0; i < value.Length; i++) + array[i] = (byte)(value[i] ? 1 : 0); + + Write(name, array); + } + + /// <summary> /// Writes an double[] array to the XML data as an element. /// </summary> /// <param name="name">The name of the XML element used.</param> @@ -436,6 +452,36 @@ nodes.Pop(); } /// <summary> + /// Writes a Dictionary of integers to the XML data as an element. + /// The key type must implement IConvertible and the value type must implment IXleSerializable. + /// </summary> + /// <param name="name">The name of the XML element used.</param> + /// <param name="value">The dictionary to write.</param> + [CLSCompliant(false)] + public void Write<Tkey>(string name, Dictionary<Tkey, int> value) + where Tkey : IConvertible + { + Type keyType = typeof(Tkey); + + XmlElement element = CreateElement(name); + //AddAttribute(element, "dictionary", "true"); + //AddAttribute(element, "keytype", keyType.ToString()); + //AddAttribute(element, "valuetype", valueType.ToString()); + + nodes.Push(element); + + foreach (KeyValuePair<Tkey, int> kvp in value) + { + XmlElement item = doc.CreateElement("Item"); + CurrentNode.AppendChild(item); + + AddAttribute(item, "key", kvp.Key.ToString()); + AddAttribute(item, "value", kvp.Value.ToString()); + } + + nodes.Pop(); + } + /// <summary> /// Writes a Dictionary of strings implementing IXleSerializable to the XML data as an element. /// The key type must implement IConvertible. /// </summary> @@ -743,7 +789,26 @@ return double.Parse(element.InnerText); } + /// <summary> + /// Reads a float value from the XML data. If the name is not present + /// an XleSerializationException is thrown. + /// </summary> + /// <param name="name">Name of the field.</param> + /// <returns></returns> + public float ReadFloat(string name) + { + string attribute = CurrentNode.GetAttribute(name); + if (string.IsNullOrEmpty(attribute) == false) + return float.Parse(attribute); + + XmlElement element = (XmlElement)CurrentNode[name]; + + if (element == null) + throw new XleSerializationException("Node " + name + " not found."); + + return float.Parse(element.InnerText); + } /// <summary> /// Reads a integer array from the XML data. If the name is not present /// an XleSerializationException is thrown. @@ -768,7 +833,23 @@ return result; } + /// <summary> + /// Reads a boolean array from the XML data. If the name is not present + /// an XleSerializationException is thrown. + /// </summary> + /// <param name="name">Name of the field.</param> + /// <returns></returns> + public bool[] ReadBooleanArray(string name) + { + byte[] array = ReadByteArray(name); + bool[] result = new bool[array.Length]; + for (int i = 0; i < array.Length; i++) + result[i] = array[i] != 0; + + return result; + } + /// <summary> /// Reads a double array from the XML data. If the name is not present /// an XleSerializationException is thrown. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-08-01 21:03:37
|
Revision: 1007 http://agate.svn.sourceforge.net/agate/?rev=1007&view=rev Author: kanato Date: 2009-08-01 21:03:22 +0000 (Sat, 01 Aug 2009) Log Message: ----------- Add ReadObject<T> overload to XleSerializationInfo. Add IXleSerializable interface to Point, Rect and Size. Modified Paths: -------------- trunk/AgateLib/Geometry/Point.cs trunk/AgateLib/Geometry/Rectangle.cs trunk/AgateLib/Geometry/Size.cs trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs Modified: trunk/AgateLib/Geometry/Point.cs =================================================================== --- trunk/AgateLib/Geometry/Point.cs 2009-07-30 18:14:31 UTC (rev 1006) +++ trunk/AgateLib/Geometry/Point.cs 2009-08-01 21:03:22 UTC (rev 1007) @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using AgateLib.Serialization.Xle; namespace AgateLib.Geometry { @@ -27,7 +28,7 @@ /// </summary> [Serializable] [TypeConverter(typeof(PointConverter))] - public struct Point + public struct Point : IXleSerializable { int x, y; @@ -62,6 +63,18 @@ this.y = size.Height; } + + void IXleSerializable.WriteData(XleSerializationInfo info) + { + info.Write("X", X, true); + info.Write("Y", Y, true); + } + void IXleSerializable.ReadData(XleSerializationInfo info) + { + X = info.ReadInt32("X"); + Y = info.ReadInt32("Y"); + } + #endregion #region --- Public Properties --- @@ -212,5 +225,7 @@ } #endregion + + } } Modified: trunk/AgateLib/Geometry/Rectangle.cs =================================================================== --- trunk/AgateLib/Geometry/Rectangle.cs 2009-07-30 18:14:31 UTC (rev 1006) +++ trunk/AgateLib/Geometry/Rectangle.cs 2009-08-01 21:03:22 UTC (rev 1007) @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; +using AgateLib.Serialization.Xle; namespace AgateLib.Geometry { @@ -28,7 +29,7 @@ /// </summary> [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] - public struct Rectangle + public struct Rectangle : IXleSerializable { Point pt; Size sz; @@ -56,6 +57,25 @@ this.sz = sz; } + #region IXleSerializable Members + + void IXleSerializable.WriteData(XleSerializationInfo info) + { + info.Write("X", X, true); + info.Write("Y", Y, true); + info.Write("Width", Width, true); + info.Write("Height", Height, true); + } + void IXleSerializable.ReadData(XleSerializationInfo info) + { + X = info.ReadInt32("X"); + Y = info.ReadInt32("Y"); + Width = info.ReadInt32("Width"); + Height = info.ReadInt32("Height"); + } + + #endregion + /// <summary> /// Static method which returns a rectangle with specified left, top, right and bottom. /// </summary> @@ -412,5 +432,7 @@ (int)Math.Round(rect.Width), (int)Math.Round(rect.Height)); } + + } } \ No newline at end of file Modified: trunk/AgateLib/Geometry/Size.cs =================================================================== --- trunk/AgateLib/Geometry/Size.cs 2009-07-30 18:14:31 UTC (rev 1006) +++ trunk/AgateLib/Geometry/Size.cs 2009-08-01 21:03:22 UTC (rev 1007) @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; +using AgateLib.Serialization.Xle; namespace AgateLib.Geometry { @@ -28,7 +29,7 @@ /// </summary> [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] - public partial struct Size + public partial struct Size : IXleSerializable { int width, height; @@ -52,6 +53,21 @@ this.height = height; } + #region IXleSerializable Members + + void IXleSerializable.WriteData(XleSerializationInfo info) + { + info.Write("Width", Width, true); + info.Write("Height", Height, true); + } + void IXleSerializable.ReadData(XleSerializationInfo info) + { + Width = info.ReadInt32("Width"); + Height = info.ReadInt32("Height"); + } + + #endregion + /// <summary> /// Gets or sets the width. /// </summary> @@ -183,5 +199,6 @@ { return SizeConverter.ConvertFromString(null, System.Globalization.CultureInfo.CurrentCulture, text); } + } } \ No newline at end of file Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2009-07-30 18:14:31 UTC (rev 1006) +++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2009-08-01 21:03:22 UTC (rev 1007) @@ -607,6 +607,12 @@ nodes.Pop(); } } + + public T ReadObject<T>(string name) + { + return (T)ReadObject(name); + } + /// <summary> /// Reads a string from the XML data, with an optional default value substituted /// if the name is not present. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-07-30 18:14:41
|
Revision: 1006 http://agate.svn.sourceforge.net/agate/?rev=1006&view=rev Author: kanato Date: 2009-07-30 18:14:31 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Fix text display when a string transformer is used. Modified Paths: -------------- trunk/AgateLib/BitmapFont/BitmapFontImpl.cs trunk/AgateLib/DisplayLib/FontState.cs trunk/AgateLib/DisplayLib/FontSurface.cs Modified: trunk/AgateLib/BitmapFont/BitmapFontImpl.cs =================================================================== --- trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2009-05-27 12:21:28 UTC (rev 1005) +++ trunk/AgateLib/BitmapFont/BitmapFontImpl.cs 2009-07-30 18:14:31 UTC (rev 1006) @@ -325,7 +325,7 @@ // It may be less then text.Length because carriage return characters // don't need any rects. GetRects(cache.SrcRects, cache.DestRects, out cache.DisplayTextLength, - state.Text, state.ScaleHeight, state.ScaleWidth); + state.TransformedText, state.ScaleHeight, state.ScaleWidth); PointF dest = state.Location; Modified: trunk/AgateLib/DisplayLib/FontState.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontState.cs 2009-05-27 12:21:28 UTC (rev 1005) +++ trunk/AgateLib/DisplayLib/FontState.cs 2009-07-30 18:14:31 UTC (rev 1006) @@ -34,6 +34,7 @@ private PointF mLocation; private string mText; private FontStateCache mCache; + private string mTransformedText; /// <summary> /// Gets or sets the text that is displayed when drawn. @@ -44,11 +45,17 @@ set { mText = value; + mTransformedText = string.Empty; if (Cache != null) Cache.OnTextChanged(this); } } + public string TransformedText + { + get { return mTransformedText; } + internal set { mTransformedText = value; } + } /// <summary> /// Gets or sets the location where text is drawn. /// </summary> Modified: trunk/AgateLib/DisplayLib/FontSurface.cs =================================================================== --- trunk/AgateLib/DisplayLib/FontSurface.cs 2009-05-27 12:21:28 UTC (rev 1005) +++ trunk/AgateLib/DisplayLib/FontSurface.cs 2009-07-30 18:14:31 UTC (rev 1006) @@ -366,6 +366,9 @@ public void DrawText(FontState state) { + if (string.IsNullOrEmpty(state.TransformedText)) + state.TransformedText = StringTransformer.Transform(state.Text); + impl.DrawText(state); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-27 13:22:30
|
Revision: 1005 http://agate.svn.sourceforge.net/agate/?rev=1005&view=rev Author: accagon Date: 2009-05-27 12:21:28 +0000 (Wed, 27 May 2009) Log Message: ----------- * Particles/*: Correct spelling of words alive and frequency. Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs branches/particles/AgateLib/Particles/Particle.cs branches/particles/AgateLib/Particles/ParticleEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-27 12:10:09 UTC (rev 1004) +++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-27 12:21:28 UTC (rev 1005) @@ -123,7 +123,7 @@ { foreach(PixelParticle ptl in Particles) { - if(ptl.Condition == Condition.ALive || ptl.Condition == Condition.Frozen) + if(ptl.Condition == Condition.Alive || ptl.Condition == Condition.Frozen) { mSurface.Color = ptl.Color; mSurface.Draw(ptl.Position); @@ -133,7 +133,7 @@ /// <summary> /// Overridden Update mehtod. - /// Emits particles based on the frequenzy property. + /// Emits particles based on the frequency property. /// Updates the emitter position. /// Calls particle manipulators to manipulate particles. /// </summary> @@ -141,15 +141,15 @@ public override void Update (double time_ms) { time += (float)time_ms; - float frequenzy = EmitFrequenzy*1000; + float frequency = EmitFrequency*1000; - while(time >= frequenzy) + while(time >= frequency) { - //int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false)); + //int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsAlive == false)); int index = -1; for (int i = 0; i < Particles.Count; i++) { - if (Particles[i].IsALive == false) + if (Particles[i].IsAlive == false) { index = i; break; @@ -161,7 +161,7 @@ // Recycle a dead particle Particles[index].Acceleration = EmitAcceleration; (Particles[index] as PixelParticle).Color = EmitColor; - Particles[index].Condition = Condition.ALive; + Particles[index].Condition = Condition.Alive; Particles[index].Life = EmitLife; Particles[index].Position = Position; Particles[index].Velocity = EmitVelocity; @@ -172,7 +172,7 @@ PixelParticle pp = new PixelParticle(EmitColor); pp.Acceleration = EmitVelocity; pp.Color = EmitColor; - pp.Condition = Condition.ALive; + pp.Condition = Condition.Alive; pp.Life = EmitLife; pp.Position = Position; pp.Velocity = EmitVelocity; @@ -185,7 +185,7 @@ break; } - time -= frequenzy; + time -= frequency; } // updates own position, particle positions and calls manipulators Modified: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-27 12:10:09 UTC (rev 1004) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-27 12:21:28 UTC (rev 1005) @@ -141,7 +141,7 @@ /// <summary> /// Overridden Update mehtod. - /// Emits particles based on the frequenzy property. + /// Emits particles based on the frequency property. /// Updates the emitter position. /// Calls particle manipulators to manipulate particles. /// </summary> @@ -149,15 +149,15 @@ public override void Update (double time_ms) { time += (float)time_ms; - float frequenzy = EmitFrequenzy*1000; + float frequency = EmitFrequency*1000; - while(time >= frequenzy) + while(time >= frequency) { - //int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false)); + //int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsAlive == false)); int index = -1; for (int i = 0; i < Particles.Count; i++) { - if (Particles[i].IsALive == false) + if (Particles[i].IsAlive == false) { index = i; break; @@ -172,7 +172,7 @@ (Particles[index] as SurfaceParticle).Alpha = mEmitAlpha; (Particles[index] as SurfaceParticle).ScaleHeight = mEmitScaleHeight; (Particles[index] as SurfaceParticle).ScaleWidth = mEmitScaleWidth; - Particles[index].Condition = Condition.ALive; + Particles[index].Condition = Condition.Alive; Particles[index].Life = EmitLife; Particles[index].Position = Position; Particles[index].Velocity = EmitVelocity; @@ -186,7 +186,7 @@ sp.Alpha = mEmitAlpha; sp.ScaleHeight = mEmitScaleHeight; sp.ScaleWidth = EmitScaleWidth; - sp.Condition = Condition.ALive; + sp.Condition = Condition.Alive; sp.Life = EmitLife; sp.Position = Position; sp.Velocity = EmitVelocity; @@ -199,7 +199,7 @@ break; } - time -= frequenzy; + time -= frequency; } // updates own position, particle positions and calls manipulators @@ -214,7 +214,7 @@ { foreach(SurfaceParticle sp in Particles) { - if(sp.Condition == Condition.ALive || sp.Condition == Condition.Frozen) + if(sp.Condition == Condition.Alive || sp.Condition == Condition.Frozen) { mSurfaces[sp.SurfaceKey].ScaleHeight = sp.ScaleHeight; mSurfaces[sp.SurfaceKey].ScaleWidth = sp.ScaleWidth; Modified: branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs =================================================================== --- branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs 2009-05-27 12:10:09 UTC (rev 1004) +++ branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs 2009-05-27 12:21:28 UTC (rev 1005) @@ -78,7 +78,7 @@ { foreach(PixelParticle pt in args.Emitter.Particles) { - if(pt.Condition == Condition.ALive && pt.Life <= LifeBarrier) + if(pt.Condition == Condition.Alive && pt.Life <= LifeBarrier) { fadeout = pt.Color.A - (int)(255 * mAlphaAmount * args.Time_ms/1000); pt.Color = Color.FromArgb(fadeout, pt.Color); @@ -91,7 +91,7 @@ { foreach(SurfaceParticle sp in args.Emitter.Particles) { - if(sp.Condition == Condition.ALive && sp.Life <= LifeBarrier) + if(sp.Condition == Condition.Alive && sp.Life <= LifeBarrier) { sp.Alpha -= mAlphaAmount * args.Time_ms/1000; if(mRecyleInvisible == true && sp.Alpha == 0) Modified: branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs =================================================================== --- branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs 2009-05-27 12:10:09 UTC (rev 1004) +++ branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs 2009-05-27 12:21:28 UTC (rev 1005) @@ -52,7 +52,7 @@ { foreach(Particle pt in args.Emitter.Particles) { - if(pt.IsALive == true) + if(pt.IsAlive == true) { pt.Acceleration = pt.Acceleration + Gravity * (float)args.Time_ms/1000; // pt.Acceleration = pt.Acceleration + Position * Strength * args.Time_ms; Modified: branches/particles/AgateLib/Particles/Particle.cs =================================================================== --- branches/particles/AgateLib/Particles/Particle.cs 2009-05-27 12:10:09 UTC (rev 1004) +++ branches/particles/AgateLib/Particles/Particle.cs 2009-05-27 12:21:28 UTC (rev 1005) @@ -48,7 +48,7 @@ /// <value> /// Is particle alive. /// </value> - public bool IsALive + public bool IsAlive { get { if(mCondition == Condition.Dead) @@ -103,7 +103,7 @@ public virtual void Update(double time_ms) { // If the particle is not alive don't simulate - if(mCondition != Condition.ALive) + if(mCondition != Condition.Alive) return; // passed time in seconds @@ -139,7 +139,7 @@ /// <summary> /// Particle is alive and will be simulated. /// </summary> - ALive, + Alive, /// <summary> /// Particle is dead and is ready to get recycled. /// </summary> Modified: branches/particles/AgateLib/Particles/ParticleEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-27 12:10:09 UTC (rev 1004) +++ branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-27 12:21:28 UTC (rev 1005) @@ -50,7 +50,7 @@ // 1 = emit each second a particle // 2 = emit every two seconds - private float mEmitFrequenzy = 1f; + private float mEmitFrequency = 1f; private Vector2 mEmitAcceleration = Vector2.Empty; private Vector2 mEmitVelocity = Vector2.Empty; @@ -74,12 +74,12 @@ } /// <value> - /// Gets or sets the emit frequenzy in seconds. + /// Gets or sets the emit frequency in seconds. /// </value> - public float EmitFrequenzy + public float EmitFrequency { - get { return mEmitFrequenzy; } - set { mEmitFrequenzy = value; } + get { return mEmitFrequency; } + set { mEmitFrequency = value; } } /// <value> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-27 12:10:15
|
Revision: 1004 http://agate.svn.sourceforge.net/agate/?rev=1004&view=rev Author: accagon Date: 2009-05-27 12:10:09 +0000 (Wed, 27 May 2009) Log Message: ----------- * SurfaceEmitter.cs: Remove use of FirstOrDefault method. Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-27 03:48:29 UTC (rev 1003) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-27 12:10:09 UTC (rev 1004) @@ -153,7 +153,17 @@ while(time >= frequenzy) { - int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false)); + //int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false)); + int index = -1; + for (int i = 0; i < Particles.Count; i++) + { + if (Particles[i].IsALive == false) + { + index = i; + break; + } + } + if(index > -1) { // Recycle a dead particle This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-27 03:48:44
|
Revision: 1003 http://agate.svn.sourceforge.net/agate/?rev=1003&view=rev Author: kanato Date: 2009-05-27 03:48:29 +0000 (Wed, 27 May 2009) Log Message: ----------- Remove use of FirstOrDefault extension method. Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-25 18:48:48 UTC (rev 1002) +++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-27 03:48:29 UTC (rev 1003) @@ -145,7 +145,17 @@ while(time >= frequenzy) { - int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false)); + //int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false)); + int index = -1; + for (int i = 0; i < Particles.Count; i++) + { + if (Particles[i].IsALive == false) + { + index = i; + break; + } + } + if(index > -1) { // Recycle a dead particle This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-25 18:48:50
|
Revision: 1002 http://agate.svn.sourceforge.net/agate/?rev=1002&view=rev Author: accagon Date: 2009-05-25 18:48:48 +0000 (Mon, 25 May 2009) Log Message: ----------- * Add test files for particles: - Data/smoke2.png: - DisplayTests/ParticleTests: - DisplayTests/ParticleTests/ParticleTests.cs: Added Paths: ----------- branches/particles/Tests/Data/smoke2.png branches/particles/Tests/DisplayTests/ParticleTests/ branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs Added: branches/particles/Tests/Data/smoke2.png =================================================================== (Binary files differ) Property changes on: branches/particles/Tests/Data/smoke2.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs =================================================================== --- branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs (rev 0) +++ branches/particles/Tests/DisplayTests/ParticleTests/ParticleTests.cs 2009-05-25 18:48:48 UTC (rev 1002) @@ -0,0 +1,105 @@ + +using System; + +using Tests; + +using AgateLib; +using AgateLib.DisplayLib; +using AgateLib.Geometry; +using AgateLib.Particles; + +namespace Tests.ParticleTest +{ + public class PixelParticleTest : AgateApplication, IAgateTest + { + #region IAgateTest Members + + public string Name { get { return "Particles"; } } + + public string Category { get { return "Display"; } } + + public void Main(string[] args) + { + Run(args); + } + + #endregion + + protected override AppInitParameters GetAppInitParameters () + { + AppInitParameters para = new AppInitParameters(); + para.InitializeAudio = false; + para.InitializeJoysticks = false; + para.ShowSplashScreen = false; + + return para; + } + + Random ran = new Random(); + + // PixelParticle + PixelEmitter pe; + GravityManipulator gm; + GravityManipulator gm2; + + //SurfaceParticle + SurfaceEmitter sm; + + FontSurface fontSurface; + + protected override void Initialize() + { + //PixelParticle + pe = new PixelEmitter(new Vector2(400f, 550f) ,Color.Blue, 5000); + pe.EmitLife = 4f; + pe.EmitFrequenzy = 0.002f; + pe.PixelSize = new Size(3, 3); + + //SurfaceParticle + sm = new SurfaceEmitter(new Vector2(150f, 550f), 4.2f, 50, 0); + Surface surf = new Surface(@"smoke2.png"); + sm.AddSurface(surf); + sm.EmitFrequenzy = 0.1f; + sm.EmitAlpha = 1d; + sm.EmitAcceleration = new Vector2(0, -20); + sm.EmitVelocity = new Vector2(0, -10); + + //Manipulators + gm = new GravityManipulator(new Vector2(0f, -50f)); + gm.SubscribeToEmitter(pe); + gm.SubscribeToEmitter(sm); + + gm2 = new GravityManipulator(Vector2.Empty); + gm2.SubscribeToEmitter(pe); + gm2.SubscribeToEmitter(sm); + + FadeOutManipulator fom = new FadeOutManipulator(3f, 0.8f); + fom.SubscribeToEmitter(pe); + + FadeOutManipulator fom2 = new FadeOutManipulator(4f, 0.4f); + fom2.SubscribeToEmitter(sm); + + fontSurface = new FontSurface("Arial", 10f, FontStyle.Bold); + } + + protected override void Update(double time_ms) + { + gm2.Gravity = new Vector2((float)ran.Next(-300, 300), 0f); + pe.Update(time_ms); + sm.Update(time_ms); + } + + protected override void Render() + { + Display.Clear(Color.Black); + + fontSurface.DrawText("FPS: " + Display.FramesPerSecond); + + pe.Draw(); + fontSurface.DrawText(pe.Position.X, pe.Position.Y, "Particles: " + pe.Particles.Count + "/" + pe.Particles.Capacity); + + sm.Draw(); + fontSurface.DrawText(sm.Position.X, sm.Position.Y, "Particles: " + sm.Particles.Count + "/" + sm.Particles.Capacity); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-25 18:43:04
|
Revision: 1001 http://agate.svn.sourceforge.net/agate/?rev=1001&view=rev Author: accagon Date: 2009-05-25 18:42:58 +0000 (Mon, 25 May 2009) Log Message: ----------- * SurfaceParticle.cs: Add scale Modified Paths: -------------- branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs Modified: branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs =================================================================== --- branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs 2009-05-25 18:41:24 UTC (rev 1000) +++ branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs 2009-05-25 18:42:58 UTC (rev 1001) @@ -31,6 +31,9 @@ private double mAlpha = 1d; + private float mScaleWidth = 1f; + private float mScaleHeight = 1f; + /// <value> /// Gets or sets the surface key. /// </value> @@ -49,6 +52,24 @@ set { mAlpha = value; } } + /// <value> + /// Gets or sets the scale width of the surface. + /// </value> + public float ScaleWidth + { + get { return mScaleWidth; } + set { mScaleWidth = value; } + } + + /// <value> + /// Gets or sets the scale height of the surface. + /// </value> + public float ScaleHeight + { + get { return mScaleHeight; } + set { mScaleHeight = value; } + } + /// <summary> /// Constructs a SurfaceParticle with a default SurfaceKey=0. /// </summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-25 18:41:32
|
Revision: 1000 http://agate.svn.sourceforge.net/agate/?rev=1000&view=rev Author: accagon Date: 2009-05-25 18:41:24 +0000 (Mon, 25 May 2009) Log Message: ----------- * FadeOutManipulator.cs: - Remove unnecessary draw code from Update method - Add RecyleInvisible property --> Changes condition of invisible particles to dead->will be recyled Modified Paths: -------------- branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs Modified: branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs =================================================================== --- branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs 2009-05-25 18:11:18 UTC (rev 999) +++ branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs 2009-05-25 18:41:24 UTC (rev 1000) @@ -32,7 +32,18 @@ private int fadeout = 0; + private bool mRecyleInvisible = true; + /// <value> + /// Gets or sets if invisible particles should be recyled. + /// </value> + public bool RecyleInvisible + { + get { return mRecyleInvisible; } + set { mRecyleInvisible = value; } + } + + /// <value> /// Gets or sets the life barrier at which the particle should fade out. /// </value> public float LifeBarrier @@ -71,6 +82,8 @@ { fadeout = pt.Color.A - (int)(255 * mAlphaAmount * args.Time_ms/1000); pt.Color = Color.FromArgb(fadeout, pt.Color); + if(mRecyleInvisible == true && pt.Color.A == 0) + pt.Condition = Condition.Dead; } } } @@ -81,7 +94,8 @@ if(sp.Condition == Condition.ALive && sp.Life <= LifeBarrier) { sp.Alpha -= mAlphaAmount * args.Time_ms/1000; - (args.Emitter as SurfaceEmitter).GetSurfaceByKey(sp.SurfaceKey).Draw(sp.Position); + if(mRecyleInvisible == true && sp.Alpha == 0) + sp.Condition = Condition.Dead; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-25 18:11:32
|
Revision: 999 http://agate.svn.sourceforge.net/agate/?rev=999&view=rev Author: accagon Date: 2009-05-25 18:11:18 +0000 (Mon, 25 May 2009) Log Message: ----------- * PixelEmitter.cs: Optimize rendering by using a surface instead of drawing each particle to display using DrawEllipse * SurfaceEmitter.cs: - Add emit scale - Change velocity and acceleration on emit to emit values Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-20 04:10:44 UTC (rev 998) +++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-25 18:11:18 UTC (rev 999) @@ -35,7 +35,7 @@ private float time = 0f; - private Rectangle mRectangle = new Rectangle(0, 0, 2, 2); + private Surface mSurface; /// <value> /// Gets or sets the emit color. @@ -51,8 +51,8 @@ /// </value> public Size PixelSize { - get { return mRectangle.Size; } - set { mRectangle.Size = value; } + get { return mSurface.DisplaySize; } + set { mSurface = new Surface(FillSurface(value, Color.White)); } } /// <summary> @@ -63,9 +63,24 @@ public PixelEmitter(Vector2 position, Color color) { Position = position; - mEmitColor = color; + mEmitColor = color; + mSurface = new Surface(FillSurface(new Size(1,1), Color.White)); } + private static PixelBuffer FillSurface(Size size, Color color) + { + PixelBuffer pb = new PixelBuffer(PixelFormat.ARGB8888, size); + int ii = 0; + for(int i = 0; i < pb.Width; i++) + { + for(ii = 0;ii <pb.Height; ii++) + { + pb.SetPixel(i, ii, color); + } + } + return pb; + } + /// <summary> /// Constructs a pixel particle emitter. /// </summary> @@ -110,10 +125,8 @@ { if(ptl.Condition == Condition.ALive || ptl.Condition == Condition.Frozen) { - mRectangle.X = (int)ptl.Position.X; - mRectangle.Y = (int)ptl.Position.Y; - - Display.DrawEllipse(mRectangle, ptl.Color); + mSurface.Color = ptl.Color; + mSurface.Draw(ptl.Position); } } } @@ -136,23 +149,23 @@ if(index > -1) { // Recycle a dead particle - Particles[index].Acceleration = Vector2.Empty; + Particles[index].Acceleration = EmitAcceleration; (Particles[index] as PixelParticle).Color = EmitColor; Particles[index].Condition = Condition.ALive; Particles[index].Life = EmitLife; Particles[index].Position = Position; - Particles[index].Velocity = Vector2.Empty; + Particles[index].Velocity = EmitVelocity; } else if(Particles.Count < Particles.Capacity) { // Add a new particle PixelParticle pp = new PixelParticle(EmitColor); - pp.Acceleration = Vector2.Empty; + pp.Acceleration = EmitVelocity; pp.Color = EmitColor; pp.Condition = Condition.ALive; pp.Life = EmitLife; pp.Position = Position; - pp.Velocity = Vector2.Empty; + pp.Velocity = EmitVelocity; Particles.Add(pp); } else Modified: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-20 04:10:44 UTC (rev 998) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-25 18:11:18 UTC (rev 999) @@ -38,6 +38,27 @@ private float time; private double mEmitAlpha = 1d; + + private float mEmitScaleWidth = 1f; + private float mEmitScaleHeight = 1f; + + /// <value> + /// Gets or sets the scale width of emitting particles. + /// </value> + public float EmitScaleWidth + { + get { return mEmitScaleWidth; } + set { mEmitScaleWidth = value; } + } + + /// <value> + /// Gets or sets the scale height of emitting particles. + /// </value> + public float EmitScaleHeight + { + get { return mEmitScaleHeight; } + set { mEmitScaleHeight = value; } + } /// <value> /// Gets or sets the alpha channel of emitting particles. @@ -136,25 +157,29 @@ if(index > -1) { // Recycle a dead particle - Particles[index].Acceleration = Vector2.Empty; + Particles[index].Acceleration = EmitAcceleration; (Particles[index] as SurfaceParticle).SurfaceKey = mEmitSurfaceKey; (Particles[index] as SurfaceParticle).Alpha = mEmitAlpha; + (Particles[index] as SurfaceParticle).ScaleHeight = mEmitScaleHeight; + (Particles[index] as SurfaceParticle).ScaleWidth = mEmitScaleWidth; Particles[index].Condition = Condition.ALive; Particles[index].Life = EmitLife; Particles[index].Position = Position; - Particles[index].Velocity = Vector2.Empty; + Particles[index].Velocity = EmitVelocity; } else if(Particles.Count < Particles.Capacity) { // Add a new particle SurfaceParticle sp = new SurfaceParticle(); - sp.Acceleration = Vector2.Empty; + sp.Acceleration = EmitAcceleration; sp.SurfaceKey = mEmitSurfaceKey; sp.Alpha = mEmitAlpha; + sp.ScaleHeight = mEmitScaleHeight; + sp.ScaleWidth = EmitScaleWidth; sp.Condition = Condition.ALive; sp.Life = EmitLife; sp.Position = Position; - sp.Velocity = Vector2.Empty; + sp.Velocity = EmitVelocity; Particles.Add(sp); } else @@ -181,6 +206,8 @@ { if(sp.Condition == Condition.ALive || sp.Condition == Condition.Frozen) { + mSurfaces[sp.SurfaceKey].ScaleHeight = sp.ScaleHeight; + mSurfaces[sp.SurfaceKey].ScaleWidth = sp.ScaleWidth; mSurfaces[sp.SurfaceKey].Alpha = sp.Alpha; mSurfaces[sp.SurfaceKey].Draw(sp.Position); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-20 04:10:50
|
Revision: 998 http://agate.svn.sourceforge.net/agate/?rev=998&view=rev Author: kanato Date: 2009-05-20 04:10:44 +0000 (Wed, 20 May 2009) Log Message: ----------- Remove StencilBufferWrite. Modified Paths: -------------- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs Modified: branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 04:04:18 UTC (rev 997) +++ branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 04:10:44 UTC (rev 998) @@ -80,19 +80,6 @@ Display.Impl.SetRenderState(RenderStateBool.StencilBufferTest, value); } } - public bool StencilBufferWrite - { - get - { - CheckDisplayInitialized(); - return Display.Impl.GetRenderState(RenderStateBool.StencilBufferWrite); - } - set - { - CheckDisplayInitialized(); - Display.Impl.SetRenderState(RenderStateBool.StencilBufferWrite, value); - } - } } public enum RenderStateBool @@ -105,6 +92,5 @@ ZBufferWrite, StencilBufferTest, - StencilBufferWrite, } } Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 04:04:18 UTC (rev 997) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 04:10:44 UTC (rev 998) @@ -1079,6 +1079,8 @@ { case RenderStateBool.WaitForVerticalBlank: return mVSync; case RenderStateBool.ZBufferTest: return mDevice.Device.GetRenderState<bool>(RenderState.ZEnable); + case RenderStateBool.StencilBufferTest: return mDevice.Device.GetRenderState<bool>(RenderState.StencilEnable); + default: throw new NotSupportedException(string.Format( "The specified render state, {0}, is not supported by this driver.")); @@ -1098,6 +1100,10 @@ mDevice.Device.SetRenderState(RenderState.ZEnable, value); return; + case RenderStateBool.StencilBufferTest: + mDevice.Device.SetRenderState(RenderState.StencilEnable, value); + return; + default: throw new NotSupportedException(string.Format( "The specified render state, {0}, is not supported by this driver.")); Modified: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs 2009-05-20 04:04:18 UTC (rev 997) +++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs 2009-05-20 04:10:44 UTC (rev 998) @@ -77,7 +77,7 @@ this.ClientSize = new System.Drawing.Size(604, 374); this.Controls.Add(this.splitContainer1); this.Name = "frmRenderStateTest"; - this.Text = "frmRenderStateTest"; + this.Text = "Render States"; this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.ResumeLayout(false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-20 04:04:28
|
Revision: 997 http://agate.svn.sourceforge.net/agate/?rev=997&view=rev Author: kanato Date: 2009-05-20 04:04:18 +0000 (Wed, 20 May 2009) Log Message: ----------- Add RenderStates test. Add support for ZBufferTest in SDX. Modified Paths: -------------- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs Added Paths: ----------- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx Modified: branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 03:43:15 UTC (rev 996) +++ branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 04:04:18 UTC (rev 997) @@ -41,7 +41,6 @@ } } - public bool ZBufferTest { get Modified: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-20 03:43:15 UTC (rev 996) +++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-20 04:04:18 UTC (rev 997) @@ -102,19 +102,8 @@ mDevice.Dispose(); mDevice = null; } - //if (mSurfaceVB != null) - //{ - // mSurfaceVB.Dispose(); - // mSurfaceVB = null; - //} } - //private void CreateSurfaceVB() - //{ - // //mSurfaceVB = new VertexBuffer(mDevice, SurfaceVBSize, - // // Usage.WriteOnly | Usage.Dynamic, CustomVertex.TransformedColoredTextured.Format, - // // Pool.Default); - //} public Device Device { get { return mDevice; } Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 03:43:15 UTC (rev 996) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 04:04:18 UTC (rev 997) @@ -1078,6 +1078,7 @@ switch (renderStateBool) { case RenderStateBool.WaitForVerticalBlank: return mVSync; + case RenderStateBool.ZBufferTest: return mDevice.Device.GetRenderState<bool>(RenderState.ZEnable); default: throw new NotSupportedException(string.Format( "The specified render state, {0}, is not supported by this driver.")); @@ -1093,6 +1094,10 @@ OnVSyncChanged(); break; + case RenderStateBool.ZBufferTest: + mDevice.Device.SetRenderState(RenderState.ZEnable, value); + return; + default: throw new NotSupportedException(string.Format( "The specified render state, {0}, is not supported by this driver.")); Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs (rev 0) +++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/RenderStates.cs 2009-05-20 04:04:18 UTC (rev 997) @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using AgateLib; + +namespace Tests.DisplayTests.RenderStates +{ + class RenderStates : IAgateTest + { + + #region IAgateTest Members + + public string Name + { + get { return "Render States"; } + } + + public string Category + { + get { return "Display"; } + } + + public void Main(string[] args) + { + using (AgateSetup setup = new AgateSetup(args)) + { + setup.Initialize(true, false, false); + if (setup.WasCanceled) + return; + + frmRenderStateTest frm = new frmRenderStateTest(); + frm.Show(); + + int count = 0; + + while (frm.Visible) + { + frm.UpdateFrame(); + + count++; + if (count > 60) + frm.Text = string.Format("Render States - {0:0.00} FPS", AgateLib.DisplayLib.Display.FramesPerSecond); + + Core.KeepAlive(); + + + } + } + } + + #endregion + } +} Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs (rev 0) +++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.Designer.cs 2009-05-20 04:04:18 UTC (rev 997) @@ -0,0 +1,94 @@ +namespace Tests.DisplayTests.RenderStates +{ + partial class frmRenderStateTest + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.agateRenderTarget1 = new AgateLib.WinForms.AgateRenderTarget(); + this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // agateRenderTarget1 + // + this.agateRenderTarget1.Dock = System.Windows.Forms.DockStyle.Fill; + this.agateRenderTarget1.Location = new System.Drawing.Point(0, 0); + this.agateRenderTarget1.Name = "agateRenderTarget1"; + this.agateRenderTarget1.Size = new System.Drawing.Size(238, 374); + this.agateRenderTarget1.TabIndex = 0; + // + // propertyGrid1 + // + this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill; + this.propertyGrid1.Location = new System.Drawing.Point(0, 0); + this.propertyGrid1.Name = "propertyGrid1"; + this.propertyGrid1.Size = new System.Drawing.Size(362, 374); + this.propertyGrid1.TabIndex = 1; + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.agateRenderTarget1); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.propertyGrid1); + this.splitContainer1.Size = new System.Drawing.Size(604, 374); + this.splitContainer1.SplitterDistance = 238; + this.splitContainer1.TabIndex = 2; + // + // frmRenderStateTest + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(604, 374); + this.Controls.Add(this.splitContainer1); + this.Name = "frmRenderStateTest"; + this.Text = "frmRenderStateTest"; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private AgateLib.WinForms.AgateRenderTarget agateRenderTarget1; + private System.Windows.Forms.PropertyGrid propertyGrid1; + private System.Windows.Forms.SplitContainer splitContainer1; + } +} \ No newline at end of file Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs (rev 0) +++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.cs 2009-05-20 04:04:18 UTC (rev 997) @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using AgateLib.DisplayLib; + +namespace Tests.DisplayTests.RenderStates +{ + public partial class frmRenderStateTest : Form + { + DisplayWindow wind; + + public frmRenderStateTest() + { + InitializeComponent(); + + wind = DisplayWindow.CreateFromControl(agateRenderTarget1); + + propertyGrid1.SelectedObject = Display.RenderState; + } + + internal void UpdateFrame() + { + Display.BeginFrame(); + Display.Clear(AgateLib.Geometry.Color.Green); + Display.EndFrame(); + } + } +} Added: branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx (rev 0) +++ branches/agate3d-3.2/Tests/DisplayTests/RenderStates/frmRenderStateTest.resx 2009-05-20 04:04:18 UTC (rev 997) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-20 03:43:23
|
Revision: 996 http://agate.svn.sourceforge.net/agate/?rev=996&view=rev Author: kanato Date: 2009-05-20 03:43:15 +0000 (Wed, 20 May 2009) Log Message: ----------- SDX_Display: mark vsync as obsolete. Remove references to VertexFormat. Modified Paths: -------------- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs Modified: branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-20 03:37:24 UTC (rev 995) +++ branches/agate3d-3.2/Drivers/AgateSDX/D3DDevice.cs 2009-05-20 03:43:15 UTC (rev 996) @@ -159,18 +159,6 @@ { get { return mDrawBuffer; } } - public VertexFormat VertexFormat - { - get { return mVertexFormat; } - set - { - if (mVertexFormat != value) - { - mVertexFormat = value; - mDevice.VertexFormat = value; - } - } - } public bool AlphaBlend { get { return mAlphaBlend; } Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 03:37:24 UTC (rev 995) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 03:43:15 UTC (rev 996) @@ -831,6 +831,7 @@ { mDevice.SetOrthoProjection(region); } + [Obsolete] public override void DoLighting(LightManager lights) { FlushDrawBuffer(); Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-20 03:37:24 UTC (rev 995) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_VertexBuffer.cs 2009-05-20 03:43:15 UTC (rev 996) @@ -201,7 +201,6 @@ mDisplay.D3D_Device.AlphaArgument1 = Direct3D.TextureArgument.Texture; - mDisplay.D3D_Device.VertexFormat = SlimDX.Direct3D9.VertexFormat.None; mDisplay.D3D_Device.Device.VertexDeclaration = mDeclaration; mDisplay.D3D_Device.Device.Indices = indexbuffer.DeviceIndexBuffer; mDisplay.D3D_Device.Device.SetStreamSource(0, mBuffer, 0, mLayout.VertexSize); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-20 03:37:29
|
Revision: 995 http://agate.svn.sourceforge.net/agate/?rev=995&view=rev Author: kanato Date: 2009-05-20 03:37:24 +0000 (Wed, 20 May 2009) Log Message: ----------- Deprecate the DoLighting in DisplayImpl. Modified Paths: -------------- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs =================================================================== --- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-20 03:33:19 UTC (rev 994) +++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-20 03:37:24 UTC (rev 995) @@ -553,7 +553,11 @@ /// Gets all the light settings from the LightManager. /// </summary> /// <param name="lights"></param> - public abstract void DoLighting(LightManager lights); + [Obsolete()] + public virtual void DoLighting(LightManager lights) + { + throw new NotImplementedException("DoLighting is not implemented, and also deprecated."); + } /// <summary> /// Processes pending events. Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-20 03:33:19 UTC (rev 994) +++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-20 03:37:24 UTC (rev 995) @@ -250,10 +250,6 @@ { throw new AgateException("SetOrthoProjection is not implemented in AgateDrawing.dll."); } - public override void DoLighting(LightManager lights) - { - throw new AgateException("Lighting is not supported by AgateDrawing. Use a 3D accelerated driver such as AgateOTK or AgateMDX for lighting support."); - } protected override void SavePixelBuffer(PixelBuffer pixelBuffer, string filename, ImageFileFormat format) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-20 03:33:35
|
Revision: 994 http://agate.svn.sourceforge.net/agate/?rev=994&view=rev Author: kanato Date: 2009-05-20 03:33:19 +0000 (Wed, 20 May 2009) Log Message: ----------- Add in RenderStateAdapter and refactor VSync to go through the render states. Modified Paths: -------------- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs branches/agate3d-3.2/Tests/Fonts/Fonts.cs Added Paths: ----------- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs Modified: branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/AgateLib/DisplayLib/Display.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -63,7 +63,8 @@ private static SurfacePacker mSurfacePacker; private static Rectangle mCurrentClipRect; private static Stack<Rectangle> mClipRects = new Stack<Rectangle>(); - + private static RenderStateAdapter mRenderState = new RenderStateAdapter(); + /// <summary> /// Gets the object which handles all of the actual calls to Display functions. /// This may be cast to a surface object in whatever rendering library @@ -95,6 +96,11 @@ mSurfacePacker = new SurfacePacker(); } + public static RenderStateAdapter RenderState + { + get { return mRenderState; } + } + private static ShaderCompilerImpl CreateShaderCompiler() { return impl.CreateShaderCompiler(); @@ -406,22 +412,11 @@ /// Gets or sets the VSync flag. If VSync is off, tearing might occur. /// If VSync is on, the framerate will be capped at the monitor's refresh rate. /// </summary> + [Obsolete("Use Display.RenderState.WaitForVerticalBlank instead.", true)] public static bool VSync { - get - { - if (impl == null) - throw new AgateException("Display has not been initialized."); - - return impl.VSync; - } - set - { - if (impl == null) - throw new AgateException("Display has not been initialized."); - - impl.VSync = value; - } + get { return RenderState.WaitForVerticalBlank; } + set { RenderState.WaitForVerticalBlank = value; } } /// <summary> @@ -686,11 +681,13 @@ /// <summary> /// Turns lighting functions off. /// </summary> + [Obsolete("Use shaders instead.")] public static void DisableLighting() { DoLighting(LightManager.Empty); } + internal static void DoLighting(LightManager lights) { impl.DoLighting(lights); Added: branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs =================================================================== --- branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs (rev 0) +++ branches/agate3d-3.2/AgateLib/DisplayLib/RenderStateAdapter.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.DisplayLib +{ + public sealed class RenderStateAdapter + { + void CheckDisplayInitialized() + { + if (Display.Impl == null) + throw new AgateException("Display has not been initialized."); + } + + public bool WaitForVerticalBlank + { + get + { + CheckDisplayInitialized(); + return Display.Impl.GetRenderState(RenderStateBool.WaitForVerticalBlank); + } + set + { + CheckDisplayInitialized(); + Display.Impl.SetRenderState(RenderStateBool.WaitForVerticalBlank, value); + } + } + + public bool AlphaBlend + { + get + { + CheckDisplayInitialized(); + return Display.Impl.GetRenderState(RenderStateBool.AlphaBlend); + } + set + { + CheckDisplayInitialized(); + Display.Impl.SetRenderState(RenderStateBool.AlphaBlend, value); + } + } + + + public bool ZBufferTest + { + get + { + CheckDisplayInitialized(); + return Display.Impl.GetRenderState(RenderStateBool.ZBufferTest); + } + set + { + CheckDisplayInitialized(); + Display.Impl.SetRenderState(RenderStateBool.ZBufferTest, value); + } + } + public bool ZBufferWrite + { + get + { + CheckDisplayInitialized(); + return Display.Impl.GetRenderState(RenderStateBool.ZBufferWrite); + } + set + { + CheckDisplayInitialized(); + Display.Impl.SetRenderState(RenderStateBool.ZBufferWrite, value); + } + } + public bool StencilBufferTest + { + get + { + CheckDisplayInitialized(); + return Display.Impl.GetRenderState(RenderStateBool.StencilBufferTest); + } + set + { + CheckDisplayInitialized(); + Display.Impl.SetRenderState(RenderStateBool.StencilBufferTest, value); + } + } + public bool StencilBufferWrite + { + get + { + CheckDisplayInitialized(); + return Display.Impl.GetRenderState(RenderStateBool.StencilBufferWrite); + } + set + { + CheckDisplayInitialized(); + Display.Impl.SetRenderState(RenderStateBool.StencilBufferWrite, value); + } + } + } + + public enum RenderStateBool + { + WaitForVerticalBlank, + + AlphaBlend, + + ZBufferTest, + ZBufferWrite, + + StencilBufferTest, + StencilBufferWrite, + } +} Modified: branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs =================================================================== --- branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/AgateLib/ImplementationBase/DisplayImpl.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -409,7 +409,7 @@ for (int i = 0; i < pts.Length; i++) { pts[i] = new PointF((float)(center.X + radiusX * Math.Cos(step * i) + 0.5), - (float)(center.Y + radiusY * Math.Sin(step * i) + 0.5)); + (float)(center.Y + radiusY * Math.Sin(step * i) + 0.5)); } FillPolygon(pts, color); @@ -525,17 +525,6 @@ } /// <summary> - /// Gets or sets VSync flag. - /// There is no need to call base.VSync if overriding this member. - /// </summary> - public virtual bool VSync - { - get { return true; } - set { } - } - - - /// <summary> /// Enumerates a list of screen modes. /// </summary> /// <returns></returns> @@ -663,5 +652,8 @@ } + + protected internal abstract bool GetRenderState(RenderStateBool renderStateBool); + protected internal abstract void SetRenderState(RenderStateBool renderStateBool, bool value); } } Modified: branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Drivers/AgateDrawing/Drawing_Display.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -375,6 +375,33 @@ } #endregion + + + protected override bool GetRenderState(RenderStateBool renderStateBool) + { + switch (renderStateBool) + { + // vsync is not supported, but shouldn't throw an error. + case RenderStateBool.WaitForVerticalBlank: return false; + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } + + protected override void SetRenderState(RenderStateBool renderStateBool, bool value) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: + // vsync is not supported, but shouldn't throw an error. + break; + + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } } Modified: branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Drivers/AgateMDX/MDX1_Display.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -540,7 +540,7 @@ if (present.AutoDepthStencilFormat == DepthFormat.Unknown) present.EnableAutoDepthStencil = false; - if (VSync) + if (GetRenderState(RenderStateBool.WaitForVerticalBlank)) present.PresentationInterval = PresentInterval.Default; else present.PresentationInterval = PresentInterval.Immediate; @@ -711,19 +711,7 @@ if (VSyncChanged != null) VSyncChanged(this, EventArgs.Empty); } - public override bool VSync - { - get - { - return mVSync; - } - set - { - mVSync = value; - OnVSyncChanged(); - } - } public override Size MaxSurfaceSize { get { return mDevice.MaxSurfaceSize; } @@ -1004,5 +992,32 @@ } #endregion + + + protected override bool GetRenderState(RenderStateBool renderStateBool) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: return mVSync; + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } + + protected override void SetRenderState(RenderStateBool renderStateBool, bool value) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: + mVSync = value; + OnVSyncChanged(); + break; + + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } } } \ No newline at end of file Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Drivers/AgateOTK/GL_Display.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -368,12 +368,6 @@ GL.Enable(EnableCap.Texture2D); } - public override bool VSync - { - get { return mVSync; } - set { mVSync = value; } - } - public override void Initialize() { mState = new GLState(); @@ -752,5 +746,30 @@ #endregion #endregion + + protected override bool GetRenderState(RenderStateBool renderStateBool) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: return mVSync; + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } + + protected override void SetRenderState(RenderStateBool renderStateBool, bool value) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: + mVSync = value; + break; + + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } } } \ No newline at end of file Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Drivers/AgateOTK/GL_DisplayControl.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -425,8 +425,8 @@ public override void EndRender() { - if (mContext.VSync != mDisplay.VSync) - mContext.VSync = mDisplay.VSync; + if (mContext.VSync != Display.RenderState.WaitForVerticalBlank) + mContext.VSync = Display.RenderState.WaitForVerticalBlank; mContext.SwapBuffers(); } Modified: branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Drivers/AgateOTK/GL_GameWindow.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -431,8 +431,8 @@ public override void BeginRender() { - if (mWindow.Context.VSync != mDisplay.VSync) - mWindow.Context.VSync = mDisplay.VSync; + if (mWindow.Context.VSync != Display.RenderState.WaitForVerticalBlank) + mWindow.Context.VSync = Display.RenderState.WaitForVerticalBlank; MakeCurrent(); Modified: branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs =================================================================== --- branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Drivers/AgateSDX/SDX_Display.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -588,7 +588,7 @@ if (present.AutoDepthStencilFormat == Format.Unknown) present.EnableAutoDepthStencil = false; - if (VSync) + if (GetRenderState(RenderStateBool.WaitForVerticalBlank)) present.PresentationInterval = PresentInterval.Default; else present.PresentationInterval = PresentInterval.Immediate; @@ -779,25 +779,6 @@ System.Windows.Forms.Application.DoEvents(); } - internal event EventHandler VSyncChanged; - private void OnVSyncChanged() - { - if (VSyncChanged != null) - VSyncChanged(this, EventArgs.Empty); - } - public override bool VSync - { - get - { - return mVSync; - } - set - { - mVSync = value; - - OnVSyncChanged(); - } - } public override Size MaxSurfaceSize { get { return mDevice.MaxSurfaceSize; } @@ -1082,5 +1063,39 @@ } #endregion + + [Obsolete("The necessity of this needs to be verified.")] + internal event EventHandler VSyncChanged; + private void OnVSyncChanged() + { + if (VSyncChanged != null) + VSyncChanged(this, EventArgs.Empty); + } + + protected override bool GetRenderState(RenderStateBool renderStateBool) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: return mVSync; + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } + + protected override void SetRenderState(RenderStateBool renderStateBool, bool value) + { + switch (renderStateBool) + { + case RenderStateBool.WaitForVerticalBlank: + mVSync = value; + OnVSyncChanged(); + break; + + default: + throw new NotSupportedException(string.Format( + "The specified render state, {0}, is not supported by this driver.")); + } + } } } \ No newline at end of file Modified: branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs =================================================================== --- branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Tests/CoreTests/Performance/Performance.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -65,7 +65,7 @@ double fps; Display.Initialize((DisplayTypeID)info.DriverTypeID); - Display.VSync = false; + Display.RenderState.WaitForVerticalBlank = false; DisplayWindow wind = DisplayWindow.CreateWindowed("Performance Test", 300, 300); font = new FontSurface("Arial", 11); Modified: branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Tests/DisplayTests/LightingTest/LightingTest.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -45,7 +45,7 @@ lights.AddPointLight(new Vector3(0, 0, -1), Color.White); lights.AddPointLight(new Vector3(0, 0, -1), Color.Yellow); - Display.VSync = false; + Display.RenderState.WaitForVerticalBlank = false; //lights[0].Ambient = Color.White; lights[1].AttenuationConstant = 0.01f; Modified: branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Tests/DisplayTests/SpriteTester/frmSpriteTester.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -338,7 +338,7 @@ private void chkVSync_CheckedChanged(object sender, EventArgs e) { - Display.VSync = chkVSync.Checked; + Display.RenderState.WaitForVerticalBlank = chkVSync.Checked; } } Modified: branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Tests/DisplayTests/TileTester/TileTester.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -34,7 +34,7 @@ tile = new Surface("bg-bricks.png"); - Display.VSync = true; + Display.RenderState.WaitForVerticalBlank = true; while (frm.IsDisposed == false) { Display.BeginFrame(); Modified: branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs =================================================================== --- branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Tests/DisplayTests/TileTester/frmTileTester.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -18,7 +18,7 @@ CreateControl(); DisplayWindow wind = DisplayWindow.CreateFromControl(agateRenderTarget1); - chkVSync.Checked = Display.VSync; + chkVSync.Checked = Display.RenderState.WaitForVerticalBlank; } public bool ScrollX @@ -40,7 +40,7 @@ } private void chkVSync_CheckedChanged(object sender, EventArgs e) { - Display.VSync = chkVSync.Checked; + Display.RenderState.WaitForVerticalBlank = chkVSync.Checked; } } } \ No newline at end of file Modified: branches/agate3d-3.2/Tests/Fonts/Fonts.cs =================================================================== --- branches/agate3d-3.2/Tests/Fonts/Fonts.cs 2009-05-19 16:13:29 UTC (rev 993) +++ branches/agate3d-3.2/Tests/Fonts/Fonts.cs 2009-05-20 03:33:19 UTC (rev 994) @@ -135,7 +135,7 @@ } else if (Keyboard.Keys[KeyCode.F2]) { - Display.VSync = !Display.VSync; + Display.RenderState.WaitForVerticalBlank = !Display.RenderState.WaitForVerticalBlank; Keyboard.ReleaseKey(KeyCode.F2); } else if (Keyboard.Keys[KeyCode.Escape]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-19 16:13:41
|
Revision: 993 http://agate.svn.sourceforge.net/agate/?rev=993&view=rev Author: accagon Date: 2009-05-19 16:13:29 +0000 (Tue, 19 May 2009) Log Message: ----------- * Particles/*: Change float to double for time_ms Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs branches/particles/AgateLib/Particles/Particle.cs branches/particles/AgateLib/Particles/ParticleEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-19 15:18:00 UTC (rev 992) +++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-19 16:13:29 UTC (rev 993) @@ -124,12 +124,10 @@ /// Updates the emitter position. /// Calls particle manipulators to manipulate particles. /// </summary> - /// <param name="time_ms"> - /// A <see cref="System.Single"/> - /// </param> - public override void Update (float time_ms) + /// <param name="time_ms">Time in milliseconds.</param> + public override void Update (double time_ms) { - time += time_ms; + time += (float)time_ms; float frequenzy = EmitFrequenzy*1000; while(time >= frequenzy) Modified: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-19 15:18:00 UTC (rev 992) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-19 16:13:29 UTC (rev 993) @@ -44,7 +44,7 @@ /// </value> public double EmitAlpha { - get { return mEmitAlpha; } + get { return EmitAlpha; } set { mEmitAlpha = value; } } @@ -124,12 +124,10 @@ /// Updates the emitter position. /// Calls particle manipulators to manipulate particles. /// </summary> - /// <param name="time_ms"> - /// A <see cref="System.Single"/> - /// </param> - public override void Update (float time_ms) + /// <param name="time_ms">Time in milliseconds.</param> + public override void Update (double time_ms) { - time += time_ms; + time += (float)time_ms; float frequenzy = EmitFrequenzy*1000; while(time >= frequenzy) Modified: branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs =================================================================== --- branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs 2009-05-19 15:18:00 UTC (rev 992) +++ branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs 2009-05-19 16:13:29 UTC (rev 993) @@ -54,7 +54,7 @@ { if(pt.IsALive == true) { - pt.Acceleration = pt.Acceleration + Gravity * args.Time_ms/1000; + pt.Acceleration = pt.Acceleration + Gravity * (float)args.Time_ms/1000; // pt.Acceleration = pt.Acceleration + Position * Strength * args.Time_ms; // pt.Velocity = pt.Velocity + Position * Strength * args.Time_ms; } Modified: branches/particles/AgateLib/Particles/Particle.cs =================================================================== --- branches/particles/AgateLib/Particles/Particle.cs 2009-05-19 15:18:00 UTC (rev 992) +++ branches/particles/AgateLib/Particles/Particle.cs 2009-05-19 16:13:29 UTC (rev 993) @@ -100,14 +100,14 @@ /// <param name="time_ms"> /// Passed time in milliseconds since last update. /// </param> - public virtual void Update(float time_ms) + public virtual void Update(double time_ms) { // If the particle is not alive don't simulate if(mCondition != Condition.ALive) return; // passed time in seconds - float time = time_ms/1000; + float time = (float)time_ms/1000; mLife -= time; if(mLife <= 0) Modified: branches/particles/AgateLib/Particles/ParticleEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-19 15:18:00 UTC (rev 992) +++ branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-19 16:13:29 UTC (rev 993) @@ -112,7 +112,7 @@ /// <param name="time_ms"> /// Passed time in milliseconds since last update. /// </param> - public override void Update (float time_ms) + public override void Update (double time_ms) { if ( OnUpdate != null) OnUpdate(new UpdateArgs(this, time_ms)); @@ -176,7 +176,7 @@ /// </summary> /// <param name="emitter">Emitter that triggered the update event.</param> /// <param name="time_ms">Passed time in milliseconds since last update.</param> - public UpdateArgs(ParticleEmitter emitter, float time_ms) + public UpdateArgs(ParticleEmitter emitter, double time_ms) { mEmitter = emitter; mTime_ms = time_ms; @@ -191,11 +191,11 @@ get { return mEmitter; } } - private float mTime_ms; + private double mTime_ms; /// <value> /// Passed time in milliseconds since last update. /// </value> - public float Time_ms + public double Time_ms { get { return mTime_ms; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-19 15:18:05
|
Revision: 992 http://agate.svn.sourceforge.net/agate/?rev=992&view=rev Author: accagon Date: 2009-05-19 15:18:00 +0000 (Tue, 19 May 2009) Log Message: ----------- * ParticleEmitter.cs: Add sample code and more documentation * Particles/PixelParticle.cs: Add more documentation Modified Paths: -------------- branches/particles/AgateLib/Particles/ParticleEmitter.cs branches/particles/AgateLib/Particles/Particles/PixelParticle.cs Modified: branches/particles/AgateLib/Particles/ParticleEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-19 12:13:38 UTC (rev 991) +++ branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-19 15:18:00 UTC (rev 992) @@ -27,6 +27,21 @@ /// <summary> /// Base class for particle emitters. /// </summary> + /// <example>This sample shows how to extend the <see cref="ParticleEmitter"/> class. + /// <code> + /// class TestClass : ParticleEmitter + /// { + /// public override void Draw () + /// { + /// foreach(PixelParticle ptl in Particles) + /// { + /// Display.DrawEllipse(new Rectangle(0, 0, 2, 2), Color.White); + /// } + /// } + /// } + /// </code> + /// </example> + /// </summary> public abstract class ParticleEmitter : Particle { private List<Particle> mParticles = new List<Particle>(); @@ -50,7 +65,7 @@ } /// <value> - /// Gets or sets the life of particles which will be emitted in future. + /// Gets or sets the life of particles which will be emitted in future in seconds. /// </value> public float EmitLife { @@ -106,16 +121,24 @@ { pt.Update(time_ms); } - + //Updates itself base.Update (time_ms); } + // TODO: Find a way how to trigger the events below public delegate void ParticleEventHandler(object sender, ParticleArgs args); public event ParticleEventHandler OnNewParticle; public event ParticleEventHandler OnDeadParticle; public event ParticleEventHandler OnRecyledParticle; + /// <summary> + /// Update event handler. + /// </summary> public delegate void UpdateEventHandler(UpdateArgs args); + /// <summary> + /// The UpdateEvent is called then the ParticleEmitter begins to update. + /// The event is called in <see cref="ParticleEmitter.Update"/>. + /// </summary> public event UpdateEventHandler OnUpdate; } Modified: branches/particles/AgateLib/Particles/Particles/PixelParticle.cs =================================================================== --- branches/particles/AgateLib/Particles/Particles/PixelParticle.cs 2009-05-19 12:13:38 UTC (rev 991) +++ branches/particles/AgateLib/Particles/Particles/PixelParticle.cs 2009-05-19 15:18:00 UTC (rev 992) @@ -24,7 +24,7 @@ namespace AgateLib.Particles { /// <summary> - /// A particle which draws one pixel. + /// A particle class which represents a particle with one colored pixels. /// </summary> public class PixelParticle : Particle { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-19 13:22:17
|
Revision: 991 http://agate.svn.sourceforge.net/agate/?rev=991&view=rev Author: accagon Date: 2009-05-19 12:13:38 +0000 (Tue, 19 May 2009) Log Message: ----------- * SurfaceEmitter.cs: Add EmitAlpha property Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-19 11:19:04 UTC (rev 990) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-19 12:13:38 UTC (rev 991) @@ -37,6 +37,26 @@ private float time; + private double mEmitAlpha = 1d; + + /// <value> + /// Gets or sets the alpha channel of emitting particles. + /// </value> + public double EmitAlpha + { + get { return mEmitAlpha; } + set { mEmitAlpha = value; } + } + + /// <value> + /// Gets or sets the SurfaceKey of the emitting particles. + /// </value> + public int EmitSurfaceKey + { + get { return mEmitSurfaceKey; } + set { mEmitSurfaceKey = value; } + } + /// <summary> /// Constructs a SurfaceEmitter with default values: /// EmitLife = 1f, maxParticle = 1000, emitSurfaceKey = 0 @@ -120,7 +140,7 @@ // Recycle a dead particle Particles[index].Acceleration = Vector2.Empty; (Particles[index] as SurfaceParticle).SurfaceKey = mEmitSurfaceKey; - (Particles[index] as SurfaceParticle).Alpha = 1d; + (Particles[index] as SurfaceParticle).Alpha = mEmitAlpha; Particles[index].Condition = Condition.ALive; Particles[index].Life = EmitLife; Particles[index].Position = Position; @@ -132,7 +152,7 @@ SurfaceParticle sp = new SurfaceParticle(); sp.Acceleration = Vector2.Empty; sp.SurfaceKey = mEmitSurfaceKey; - sp.Alpha = 1d; + sp.Alpha = mEmitAlpha; sp.Condition = Condition.ALive; sp.Life = EmitLife; sp.Position = Position; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-19 11:19:09
|
Revision: 990 http://agate.svn.sourceforge.net/agate/?rev=990&view=rev Author: accagon Date: 2009-05-19 11:19:04 +0000 (Tue, 19 May 2009) Log Message: ----------- * Particles/SurfaceParticle.cs: Implement SurfaceParticle * Emitters/PixelEmitter.cs: Remove unused code * Emitters/SurfaceEmitter.cs: Add SurfaceEmitter * Manipulators/FadeOutManipulator.cs: Add fade out for SurfaceParticles Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs Added Paths: ----------- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-18 16:12:54 UTC (rev 989) +++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-19 11:19:04 UTC (rev 990) @@ -33,7 +33,6 @@ { private Color mEmitColor = Color.White; - private Surface drawSurf = new Surface(1, 1); private float time = 0f; private Rectangle mRectangle = new Rectangle(0, 0, 2, 2); @@ -115,8 +114,6 @@ mRectangle.Y = (int)ptl.Position.Y; Display.DrawEllipse(mRectangle, ptl.Color); - //drawSurf.Color = ptl.Color; - //drawSurf.Draw(ptl.Position.X, ptl.Position.Y); } } } Added: branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs (rev 0) +++ branches/particles/AgateLib/Particles/Emitters/SurfaceEmitter.cs 2009-05-19 11:19:04 UTC (rev 990) @@ -0,0 +1,172 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib.Particles. +// +// The Initial Developer of the Original Code is Marcel Hauf +// Portions created by Marcel Hauf are Copyright (C) 2009. +// All Rights Reserved. +// +// Contributor(s): Marcel Hauf. +// +using System; +using System.Linq; +using System.Collections.Generic; + +using AgateLib.Geometry; +using AgateLib.DisplayLib; + +namespace AgateLib.Particles +{ + /// <summary> + /// A surface emitter. + /// Optimized for emitting and rendering surface based particles. + /// </summary> + public class SurfaceEmitter : ParticleEmitter + { + private List<Surface> mSurfaces = new List<Surface>(); + + private int mEmitSurfaceKey; + + private float time; + + /// <summary> + /// Constructs a SurfaceEmitter with default values: + /// EmitLife = 1f, maxParticle = 1000, emitSurfaceKey = 0 + /// </summary> + /// <param name="position"></param> + public SurfaceEmitter(Vector2 position) : this(position, 1f, 1000, 0) {} + + /// <summary> + /// Constructs a SurfaceEmitter with default values: + /// maxParticle = 1000, emitSurfaceKey = 0 + /// </summary> + /// <param name="position"></param> + /// <param name="emitLife"></param> + public SurfaceEmitter(Vector2 position, float emitLife) : this(position, emitLife, 1000, 0) {} + + /// <summary> + /// Constructs a SurfaceEmitter with default values: + /// emitSurfaceKey = 0 + /// </summary> + /// <param name="position"></param> + /// <param name="emitLife"></param> + /// <param name="maxParticle"></param> + public SurfaceEmitter(Vector2 position, float emitLife, int maxParticle) : this(position, emitLife, maxParticle, 0) {} + + /// <summary> + /// Constructs a SurfaceEmitter. + /// </summary> + /// <param name="position"></param> + /// <param name="emitLife"></param> + /// <param name="maxParticle"></param> + /// <param name="emitSurfaceKey"></param> + public SurfaceEmitter(Vector2 position, float emitLife, int maxParticle, int emitSurfaceKey) + { + base.Position = position; + base.EmitLife = emitLife; + base.Particles = new List<Particle>(maxParticle); + mEmitSurfaceKey = emitSurfaceKey; + } + + /// <summary> + /// Gets surface by key from storage. + /// </summary> + /// <param name="key">Surface key</param> + /// <returns></returns> + public Surface GetSurfaceByKey(int key) + { + return mSurfaces[key]; + } + + /// <summary> + /// Adds a surface to the storage. + /// </summary> + /// <param name="image"></param> + /// <returns>Returns the key where the surface is stored.</returns> + public int AddSurface(Surface image) + { + int index = mSurfaces.Count; + mSurfaces.Insert(index, image); + return index; + } + + /// <summary> + /// Overridden Update mehtod. + /// Emits particles based on the frequenzy property. + /// Updates the emitter position. + /// Calls particle manipulators to manipulate particles. + /// </summary> + /// <param name="time_ms"> + /// A <see cref="System.Single"/> + /// </param> + public override void Update (float time_ms) + { + time += time_ms; + float frequenzy = EmitFrequenzy*1000; + + while(time >= frequenzy) + { + int index = Particles.IndexOf(Particles.FirstOrDefault(pt => pt.IsALive == false)); + if(index > -1) + { + // Recycle a dead particle + Particles[index].Acceleration = Vector2.Empty; + (Particles[index] as SurfaceParticle).SurfaceKey = mEmitSurfaceKey; + (Particles[index] as SurfaceParticle).Alpha = 1d; + Particles[index].Condition = Condition.ALive; + Particles[index].Life = EmitLife; + Particles[index].Position = Position; + Particles[index].Velocity = Vector2.Empty; + } + else if(Particles.Count < Particles.Capacity) + { + // Add a new particle + SurfaceParticle sp = new SurfaceParticle(); + sp.Acceleration = Vector2.Empty; + sp.SurfaceKey = mEmitSurfaceKey; + sp.Alpha = 1d; + sp.Condition = Condition.ALive; + sp.Life = EmitLife; + sp.Position = Position; + sp.Velocity = Vector2.Empty; + Particles.Add(sp); + } + else + { + // No capacity left and no dead particles to recycle + time = 0; + break; + } + + time -= frequenzy; + } + + // updates own position, particle positions and calls manipulators + base.Update (time_ms); + } + + /// <summary>s + /// Overridden Draw method. + /// Draws each living particle. + /// </summary> + public override void Draw () + { + foreach(SurfaceParticle sp in Particles) + { + if(sp.Condition == Condition.ALive || sp.Condition == Condition.Frozen) + { + mSurfaces[sp.SurfaceKey].Alpha = sp.Alpha; + mSurfaces[sp.SurfaceKey].Draw(sp.Position); + } + } + } + } +} Modified: branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs =================================================================== --- branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs 2009-05-18 16:12:54 UTC (rev 989) +++ branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs 2009-05-19 11:19:04 UTC (rev 990) @@ -63,16 +63,28 @@ void HandleOnUpdate(UpdateArgs args) { - foreach(PixelParticle pt in args.Emitter.Particles) + if(args.Emitter.GetType() == typeof(PixelEmitter)) { - if(pt.Condition == Condition.ALive && pt.Life <= LifeBarrier) + foreach(PixelParticle pt in args.Emitter.Particles) { - fadeout = pt.Color.A - (int)(255 * mAlphaAmount * args.Time_ms/1000); - pt.Color = Color.FromArgb(fadeout, pt.Color); - + if(pt.Condition == Condition.ALive && pt.Life <= LifeBarrier) + { + fadeout = pt.Color.A - (int)(255 * mAlphaAmount * args.Time_ms/1000); + pt.Color = Color.FromArgb(fadeout, pt.Color); + } } } - // TODO: fade out for SurfaceParticle + else if(args.Emitter.GetType() == typeof(SurfaceEmitter)) + { + foreach(SurfaceParticle sp in args.Emitter.Particles) + { + if(sp.Condition == Condition.ALive && sp.Life <= LifeBarrier) + { + sp.Alpha -= mAlphaAmount * args.Time_ms/1000; + (args.Emitter as SurfaceEmitter).GetSurfaceByKey(sp.SurfaceKey).Draw(sp.Position); + } + } + } } /// <summary> Modified: branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs =================================================================== --- branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs 2009-05-18 16:12:54 UTC (rev 989) +++ branches/particles/AgateLib/Particles/Particles/SurfaceParticle.cs 2009-05-19 11:19:04 UTC (rev 990) @@ -1,16 +1,66 @@ - +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib.Particles. +// +// The Initial Developer of the Original Code is Marcel Hauf +// Portions created by Marcel Hauf are Copyright (C) 2009. +// All Rights Reserved. +// +// Contributor(s): Marcel Hauf. +// using System; using AgateLib.DisplayLib; -using AgateLib.Particles; namespace AgateLib.Particles { + /// <summary> + /// A surface particle class. + /// </summary> public class SurfaceParticle : Particle - { - public SurfaceParticle(Surface image) + { + private int mSurfaceKey; + + private double mAlpha = 1d; + + /// <value> + /// Gets or sets the surface key. + /// </value> + public int SurfaceKey { - + get { return mSurfaceKey; } + set { mSurfaceKey = value; } } + + /// <value> + /// Gets or sets the alpha of the surface. + /// </value> + public double Alpha + { + get { return mAlpha; } + set { mAlpha = value; } + } + + /// <summary> + /// Constructs a SurfaceParticle with a default SurfaceKey=0. + /// </summary> + public SurfaceParticle() : this(0) {} + + /// <summary> + /// Constructs a SurfaceParticle. + /// </summary> + /// <param name="surfaceKey"></param> + public SurfaceParticle(int surfaceKey) + { + SurfaceKey = surfaceKey; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-18 16:13:05
|
Revision: 989 http://agate.svn.sourceforge.net/agate/?rev=989&view=rev Author: accagon Date: 2009-05-18 16:12:54 +0000 (Mon, 18 May 2009) Log Message: ----------- Move EmitLife property from Emitters/PixelEmitter.cs to ParticleEmitter.cs Modified Paths: -------------- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs branches/particles/AgateLib/Particles/ParticleEmitter.cs Modified: branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-18 13:25:53 UTC (rev 988) +++ branches/particles/AgateLib/Particles/Emitters/PixelEmitter.cs 2009-05-18 16:12:54 UTC (rev 989) @@ -31,8 +31,7 @@ /// </summary> public class PixelEmitter : ParticleEmitter { - private Color mEmitColor = Color.White; - private float mEmitLife = 1f; + private Color mEmitColor = Color.White; private Surface drawSurf = new Surface(1, 1); private float time = 0f; @@ -46,18 +45,9 @@ { get { return mEmitColor; } set { mEmitColor = value; } - } + } /// <value> - /// Gets or sets the life of particles which will be emitted in future. - /// </value> - public float EmitLife - { - get { return mEmitLife; } - set { mEmitLife = value; } - } - - /// <value> /// Gets or sets the pixel size. /// </value> public Size PixelSize @@ -85,7 +75,7 @@ /// <param name="emitLife"></param> public PixelEmitter(Vector2 position, Color color, float emitLife) : this(position, color) { - mEmitLife = emitLife; + base.EmitLife = emitLife; } /// <summary> @@ -108,7 +98,7 @@ /// <param name="emitLife"></param> public PixelEmitter(Vector2 position, Color color, int maxParticles, float emitLife) : this(position, color, maxParticles) { - mEmitLife = emitLife; + base.EmitLife = emitLife; } /// <summary>s Modified: branches/particles/AgateLib/Particles/ParticleEmitter.cs =================================================================== --- branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-18 13:25:53 UTC (rev 988) +++ branches/particles/AgateLib/Particles/ParticleEmitter.cs 2009-05-18 16:12:54 UTC (rev 989) @@ -31,6 +31,8 @@ { private List<Particle> mParticles = new List<Particle>(); + private float mEmitLife = 1f; + // 1 = emit each second a particle // 2 = emit every two seconds private float mEmitFrequenzy = 1f; @@ -48,6 +50,15 @@ } /// <value> + /// Gets or sets the life of particles which will be emitted in future. + /// </value> + public float EmitLife + { + get { return mEmitLife; } + set { mEmitLife = value; } + } + + /// <value> /// Gets or sets the emit frequenzy in seconds. /// </value> public float EmitFrequenzy This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ac...@us...> - 2009-05-18 13:26:03
|
Revision: 988 http://agate.svn.sourceforge.net/agate/?rev=988&view=rev Author: accagon Date: 2009-05-18 13:25:53 +0000 (Mon, 18 May 2009) Log Message: ----------- * FadeOutManipulator.cs: Add new FadeOutManipulator * GravityManipulator.cs: - Add UnSubscribeToEmitter method - Add pseudo gravity manipulation code Modified Paths: -------------- branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs Added Paths: ----------- branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs Added: branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs =================================================================== --- branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs (rev 0) +++ branches/particles/AgateLib/Particles/Manipulators/FadeOutManipulator.cs 2009-05-18 13:25:53 UTC (rev 988) @@ -0,0 +1,96 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib.Particles. +// +// The Initial Developer of the Original Code is Marcel Hauf +// Portions created by Marcel Hauf are Copyright (C) 2009. +// All Rights Reserved. +// +// Contributor(s): Marcel Hauf. +// +using System; + +using AgateLib.Geometry; + +namespace AgateLib.Particles +{ + /// <summary> + /// Fades out particles by changing the alpha channel. + /// </summary> + public class FadeOutManipulator + { + private float mLifeBarrier = 1f; + private float mAlphaAmount = 0.5f; + + private int fadeout = 0; + + /// <value> + /// Gets or sets the life barrier at which the particle should fade out. + /// </value> + public float LifeBarrier + { + get { return mLifeBarrier; } + set { mLifeBarrier = value; } + } + + /// <value> + /// Gets or sets the amount of alpha which will be reduced. + /// </value> + public float AlphaAmount + { + get { return mAlphaAmount; } + set { mAlphaAmount = value; } + } + + /// <summary> + /// Constructs a FadeOutManipulator. + /// </summary> + /// <param name="lifeBarrier">The barrier at which the particles will be faded out</param> + /// <param name="alphaAmount">The amount of alpha wich will be reduced.</param> + public FadeOutManipulator(float lifeBarrier, float alphaAmount) + { + mLifeBarrier = lifeBarrier; + mAlphaAmount = alphaAmount; + } + + void HandleOnUpdate(UpdateArgs args) + { + foreach(PixelParticle pt in args.Emitter.Particles) + { + if(pt.Condition == Condition.ALive && pt.Life <= LifeBarrier) + { + fadeout = pt.Color.A - (int)(255 * mAlphaAmount * args.Time_ms/1000); + pt.Color = Color.FromArgb(fadeout, pt.Color); + + } + } + // TODO: fade out for SurfaceParticle + } + + /// <summary> + /// Subscribe to a particle emitter. + /// </summary> + /// <param name="emitter"></param> + public void SubscribeToEmitter (ParticleEmitter emitter) + { + emitter.OnUpdate += HandleOnUpdate; + } + + /// <summary> + /// Unsubscribe to a particle emitter. + /// </summary> + /// <param name="emitter"></param> + public void UnSubscribeToEmitter (ParticleEmitter emitter) + { + emitter.OnUpdate -= HandleOnUpdate; + } + } +} Modified: branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs =================================================================== --- branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs 2009-05-18 10:59:32 UTC (rev 987) +++ branches/particles/AgateLib/Particles/Manipulators/GravityManipulator.cs 2009-05-18 13:25:53 UTC (rev 988) @@ -47,27 +47,36 @@ { mGravity = gravity; } - - /// <summary> - /// Subscribe to a particle emitter. - /// </summary> - /// <param name="emitter"></param> - public void SubscribeToEmitter(ParticleEmitter emitter) - { - emitter.OnUpdate +=HandleOnUpdate; - } void HandleOnUpdate(UpdateArgs args) { - // TODO: Adjust pseudo math to new gravity property foreach(Particle pt in args.Emitter.Particles) { if(pt.IsALive == true) { + pt.Acceleration = pt.Acceleration + Gravity * args.Time_ms/1000; // pt.Acceleration = pt.Acceleration + Position * Strength * args.Time_ms; // pt.Velocity = pt.Velocity + Position * Strength * args.Time_ms; } } } + + /// <summary> + /// Subscribe to a particle emitter. + /// </summary> + /// <param name="emitter"></param> + public void SubscribeToEmitter (ParticleEmitter emitter) + { + emitter.OnUpdate += HandleOnUpdate; + } + + /// <summary> + /// Unsubscribe to a particle emitter. + /// </summary> + /// <param name="emitter"></param> + public void UnSubscribeToEmitter (ParticleEmitter emitter) + { + emitter.OnUpdate -= HandleOnUpdate; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |