PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 38ms app.codeStats 0ms

/Rendering/CameraTests/LookAtCameraTests.cs

#
C# | 89 lines | 44 code | 10 blank | 35 comment | 0 complexity | 126bca2571dc84fb409b62712b635b7e MD5 | raw file
 1using Delta.ContentSystem.Rendering;
 2using Delta.Engine;
 3using Delta.Rendering.Basics.Drawing;
 4using Delta.Rendering.Cameras;
 5using Delta.Rendering.Models;
 6using Delta.Utilities;
 7using Delta.Utilities.Datatypes;
 8using NUnit.Framework;
 9
10namespace Delta.Rendering.CameraTests
11{
12	/// <summary>
13	/// All unit tests for look at cameras.
14	/// </summary>
15	[Category("Visual")]
16	public class LookAtCameraTests
17	{
18		#region TestLookAtCamera (Static)
19		/// <summary>
20		/// Test look center camera
21		/// </summary>
22		[Test]
23		public static void TestLookAtCamera()
24		{
25			LookAtCamera testCamera = new LookAtCamera(new Vector(10, 5, 4));
26			Assert.NotNull(testCamera);
27			Assert.Equal(new Vector(10, 5, 4), testCamera.Position);
28		}
29		#endregion
30
31		#region DefaultCameraBehavior (Static)
32		/// <summary>
33		/// Default Camera Behavior
34		/// </summary>
35		[Test]
36		public static void DefaultCameraBehavior()
37		{
38			// At second we need to initialize the camera which we wanna use in the
39			// scene
40			LookAtCamera centerCam = new LookAtCamera(new Vector(0, -5, 5));
41
42			// First create a mesh to see something
43			MaterialData materialData = new MaterialData
44			{
45				ShaderName = "TexturedShader3D",
46				DiffuseMapName = "AngelHighDiffuseAlphaTest",
47			};
48
49			const float planeSize = 2;
50
51			Mesh groundPlane = Mesh.CreatePlane("PlaneXY", planeSize, planeSize,
52				materialData);
53			//Model xPlane = new Model("PlaneXZ", planeSize, planeSize,
54			//  materialData);
55			// xPlane.Rotation = new Vector(0, 90, 0);
56			//Model yPlane = new Model("PlaneYZ", planeSize, planeSize,
57			//  materialData);
58			//yPlane.Rotation = new Vector(0, 0, 90);
59
60			//Label camPositionLabel = new Label
61			//{
62			//  //IsAutoSizing = false,
63			//  LocalArea = new Rectangle(0.05f, 0.13f, 0.35f, 0.05f),
64			//};
65
66			//Label camRotationLabel = new Label
67			//{
68			//  //IsAutoSizing = false,
69			//  LocalArea = new Rectangle(0.05f, 0.18f, 0.35f, 0.05f),
70			//};
71
72			// Draw the created mesh
73			Application.Start(delegate
74			{
75				//centerCam.Update();
76				//camPositionLabel.Text = "Position=" + centerCam.Position;
77				//camRotationLabel.Text = "Rotation=" + centerCam.Rotation;
78
79				//testMesh.Draw(Matrix.Identity);
80				groundPlane.Draw();
81				Grid.Draw();
82
83				//xPlane.Draw();
84				//yPlane.Draw();
85			});
86		}
87		#endregion
88	}
89}