PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/Rendering/EffectTests/Program.cs

#
C# | 109 lines | 59 code | 12 blank | 38 comment | 1 complexity | 390d9f828f0256904ccaffb80b6d2244 MD5 | raw file
  1using System.IO;
  2using Delta.ContentSystem.Rendering;
  3using Delta.ContentSystem.Rendering.Helpers;
  4using Delta.Engine;
  5using Delta.InputSystem;
  6using Delta.Rendering.Effects;
  7using Delta.Rendering.Effects.Modifiers;
  8using Delta.Utilities.Datatypes;
  9using NUnit.Framework;
 10
 11namespace Delta.Rendering.EffectTests
 12{
 13	/// <summary>
 14	/// Effect system tests
 15	/// </summary>
 16	public class Program
 17	{
 18		#region Main (Static)
 19		/// <summary>
 20		/// Main
 21		/// </summary>
 22		public static void Main()
 23		{
 24			#region Tests
 25			// 2D Effects
 26			//Effect2DTests.SimpleEffect();
 27			//Effect2DTests.MultiEmitterEffect();
 28			//Effect2DTests.CollisionEffect();
 29
 30			//Effect2DTests.SimpleEffectWithAnimatedMaterial();
 31
 32			//Effect2DTests.OnceEffect();
 33			//Effect2DTests.SimpleElapsingEffect();
 34			//Effect2DTests.AdvancedElapsingEffect();
 35			//Effect2DTests.SimpleEffectPerformance();
 36			//Effect2DTests.TestMultiEffectPerformance();
 37			//Effect2DTests.MassiveEffectPerformance();
 38
 39			// 3D Effects
 40			//Effect3DTests.SimpleEffect3D();
 41			//Effect3DTests.ElapsingEffect3D();
 42			//Effect3DTests.BillboardModeTest();
 43			//Effect3DTests.BillboardModeTestDirect();
 44			//Effect3DTests.SwordClashEffect3D();
 45			//Effect3DTests.BloodSplatterEffect3D();
 46			//Effect3DTests.SmokeEffect3D();
 47			//Effect3DTests.GroundMistEffect3D();
 48			//Effect3DTests.FireEffect3D();
 49
 50			//Effect3DTests.FountainEffect3D();
 51
 52
 53			// Functional
 54			//SaveAndLoadEffect();
 55			#endregion
 56
 57			#region Tutorials
 58			Tutorials.SparksEffect();
 59			//Tutorials.RocketEffect();
 60			//Tutorials.FireEffect();
 61			//Tutorials.SmokeEffect();
 62			//Tutorials.LensFlareEffect();
 63			//Tutorials.BillboardTest();
 64			#endregion
 65		}
 66		#endregion
 67
 68		#region SaveAndLoadEffect (Static)
 69		/// <summary>
 70		/// Test the saving and loading logic of the effects.
 71		/// </summary>
 72		[Test, Category("Visual")]
 73		public static void SaveAndLoadEffect()
 74		{
 75			EffectData saveEffectData = EffectData.Get("<TestSaveLoadEffect>");
 76			EmitterData emitter = new EmitterData();
 77			emitter.Modifiers.Add(new AlwaysSpawnModifier());
 78			emitter.Modifiers.Add(new VelocityModifier
 79			{
 80				Velocity = new Vector(0f, 0.1f, 0f)
 81			});
 82			emitter.Modifiers.Add(Effect2DTests.Default2DMaterialModifier);
 83			saveEffectData.Emitters.Add(emitter);
 84
 85			EffectData loadedEffectData = null;
 86			using (MemoryStream saveStream = new MemoryStream())
 87			{
 88				BinaryWriter writer = new BinaryWriter(saveStream);
 89				saveEffectData.Save(writer);
 90				saveEffectData = null;
 91				emitter = null;
 92
 93				saveStream.Position = 0;
 94				loadedEffectData = EffectData.Get("<>");
 95				BinaryReader reader = new BinaryReader(saveStream);
 96				loadedEffectData.Load(reader);
 97			}
 98
 99			Application.Start(delegate
100			{
101				if (Input.Keyboard.EnterReleased)
102				{
103					Effect.Spawn(loadedEffectData, ScreenSpace.DrawArea.Center);
104				}
105			});
106		}
107		#endregion
108	}
109}