/Rendering/SceneGraphTests/SceneGraphTests.cs
C# | 83 lines | 67 code | 5 blank | 11 comment | 7 complexity | 8770a983d386fde207ae79368ee6e206 MD5 | raw file
Possible License(s): Apache-2.0
- using Delta.ContentSystem.Rendering;
- using Delta.Engine;
- using Delta.InputSystem;
- using Delta.Rendering.Cameras;
- using Delta.Rendering.Models;
- using Delta.Rendering.SceneGraph;
- using Delta.Utilities;
- using Delta.Utilities.Datatypes;
- using NUnit.Framework;
-
- namespace Delta.Rendering.SceneGraphTests
- {
- public static class SceneGraphTests
- {
- #region BasicMeshSceneNode (Static)
- /// <summary>
- /// Usage of SceneGraphNodeMesh attached on root node with movement.
- /// </summary>
- [Test]
- public static void BasicMeshSceneNode()
- {
- SceneGraphNode root = new SceneGraphNode();
- SceneGraphNodeMesh meshNode = new SceneGraphNodeMesh
- {
- Mesh = Mesh.CreateCube("Box_Test", 3.0f, new MaterialData
- {
- DiffuseMapName = "DeltaEngineLogo"
- })
- };
- root.Add(meshNode);
-
- // Create our camera node.
- LookAtCamera cam = new LookAtCamera(new Vector(10, 10, 10));
-
- // Start the application
- Application.Start(delegate
- {
- // Now test if even opening the main scene still works after closing
- // the sub-screen by the keyboard (-> reported issue)
- if (Input.Keyboard.IsReleased(InputButton.W))
- {
- root.OffsetLocalPosition(0, 0, 5);
- }
- if (Input.Keyboard.IsReleased(InputButton.Z))
- {
- root.OffsetLocalPosition(0, 0, -5);
- }
- if (Input.Keyboard.IsReleased(InputButton.A))
- {
- root.OffsetLocalPosition(5, 0, 0);
- }
- if (Input.Keyboard.IsReleased(InputButton.S))
- {
- root.OffsetLocalPosition(-5, 0, 0);
- }
- root.RenderAll();
- });
- }
- #endregion
-
- #region BasicRootNode (LongRunning)
- /// <summary>
- /// Tests basic scene node creation as root node.
- /// </summary>
- [Test, Category("Visual")]
- public static void BasicRootNode()
- {
- // Check the tree integrity
- SceneGraphNode root = new SceneGraphNode();
- SceneGraphNode nodeA = new SceneGraphNode();
- SceneGraphNode nodeB = new SceneGraphNode();
- SceneGraphNode nodeC = new SceneGraphNode();
- root.Add(nodeA);
- root.Add(nodeB);
- root.Add(nodeC);
-
- Assert.True(root.Depth == 1);
- Assert.True(nodeA.Root == root);
- Assert.True(root.ChildrenCount == 3);
- }
- #endregion
- }
- }