PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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