PageRenderTime 159ms CodeModel.GetById 90ms app.highlight 4ms RepoModel.GetById 63ms app.codeStats 0ms

/Rendering/SceneGraphTests/SceneGraphTests.cs

#
C# | 83 lines | 67 code | 5 blank | 11 comment | 7 complexity | 8770a983d386fde207ae79368ee6e206 MD5 | raw file
 1using Delta.ContentSystem.Rendering;
 2using Delta.Engine;
 3using Delta.InputSystem;
 4using Delta.Rendering.Cameras;
 5using Delta.Rendering.Models;
 6using Delta.Rendering.SceneGraph;
 7using Delta.Utilities;
 8using Delta.Utilities.Datatypes;
 9using NUnit.Framework;
10
11namespace Delta.Rendering.SceneGraphTests
12{
13	public static class SceneGraphTests
14	{
15		#region BasicMeshSceneNode (Static)
16		/// <summary>
17		/// Usage of SceneGraphNodeMesh attached on root node with movement.
18		/// </summary>
19		[Test]
20		public static void BasicMeshSceneNode()
21		{
22			SceneGraphNode root = new SceneGraphNode();
23			SceneGraphNodeMesh meshNode = new SceneGraphNodeMesh
24			{
25				Mesh = Mesh.CreateCube("Box_Test", 3.0f, new MaterialData
26				{
27					DiffuseMapName = "DeltaEngineLogo"
28				})
29			};
30			root.Add(meshNode);
31
32			// Create our camera node.
33			LookAtCamera cam = new LookAtCamera(new Vector(10, 10, 10));
34
35			// Start the application  
36			Application.Start(delegate
37			{
38				// Now test if even opening the main scene still works after closing
39				// the sub-screen by the keyboard (-> reported issue)
40				if (Input.Keyboard.IsReleased(InputButton.W))
41				{
42					root.OffsetLocalPosition(0, 0, 5);
43				}
44				if (Input.Keyboard.IsReleased(InputButton.Z))
45				{
46					root.OffsetLocalPosition(0, 0, -5);
47				}
48				if (Input.Keyboard.IsReleased(InputButton.A))
49				{
50					root.OffsetLocalPosition(5, 0, 0);
51				}
52				if (Input.Keyboard.IsReleased(InputButton.S))
53				{
54					root.OffsetLocalPosition(-5, 0, 0);
55				}
56				root.RenderAll();
57			});
58		}
59		#endregion
60
61		#region BasicRootNode (LongRunning)
62		/// <summary>
63		/// Tests basic scene node creation as root node.
64		/// </summary>
65		[Test, Category("Visual")]
66		public static void BasicRootNode()
67		{
68			// Check the tree integrity
69			SceneGraphNode root = new SceneGraphNode();
70			SceneGraphNode nodeA = new SceneGraphNode();
71			SceneGraphNode nodeB = new SceneGraphNode();
72			SceneGraphNode nodeC = new SceneGraphNode();
73			root.Add(nodeA);
74			root.Add(nodeB);
75			root.Add(nodeC);
76
77			Assert.True(root.Depth == 1);
78			Assert.True(nodeA.Root == root);
79			Assert.True(root.ChildrenCount == 3);
80		}
81		#endregion
82	}
83}