PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/Rendering/CameraTests/LookAtCameraTests.cs

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