SceneCameraOptions.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /** @addtogroup Scene-Editor
  7. * @{
  8. */
  9. /// <summary>
  10. /// Options used by the scene camera.
  11. /// </summary>
  12. internal class SceneCameraOptions
  13. {
  14. public const float MinScrollSpeed = 0.1f;
  15. public const float MaxScrollSpeed = 3.0f;
  16. public const float MinNearClipPlane = 0.0001f;
  17. public const float MaxNearClipPlane = float.MaxValue;
  18. public const float MinFarClipPlane = 0.01f;
  19. public const float MaxFarClipPlane = float.MaxValue;
  20. public const float StartSpeed = 4.0f;
  21. public const float TopSpeed = 12.0f;
  22. public Degree FieldOfView { get; private set; }
  23. public float OrthographicSize { get; private set; }
  24. public float Acceleration { get; private set; }
  25. public float FastModeMultiplier { get; private set; }
  26. public float PanSpeed { get; private set; }
  27. public float ScrollSpeed { get; private set; }
  28. public float RotationalSpeed { get; private set; }
  29. public float NearClipPlane { get; private set; }
  30. public float FarClipPlane { get; private set; }
  31. public SceneCameraOptions()
  32. {
  33. FieldOfView = (Degree)ProjectSettings.GetFloat("SceneCameraOptions_FieldOfView", 90.0f);
  34. OrthographicSize = ProjectSettings.GetFloat("SceneCameraOptions_OrthographicSize", 10.0f);
  35. Acceleration = ProjectSettings.GetFloat("SceneCameraOptions_Acceleration", 1.0f);
  36. FastModeMultiplier = ProjectSettings.GetFloat("SceneCameraOptions_FastModeMultiplier", 2.0f);
  37. PanSpeed = ProjectSettings.GetFloat("SceneCameraOptions_PanSpeed", 3.0f);
  38. ScrollSpeed = ProjectSettings.GetFloat("SceneCameraOptions_ScrollSpeed", 3.0f);
  39. RotationalSpeed = ProjectSettings.GetFloat("SceneCameraOptions_RotationalSpeed", 3.0f);
  40. NearClipPlane = ProjectSettings.GetFloat("SceneCameraOptions_NearClipPlane", 0.05f);
  41. FarClipPlane = ProjectSettings.GetFloat("SceneCameraOptions_FarClipPlane", 2500f);
  42. }
  43. /// <summary>
  44. /// Sets the orthographic size of the scene camera.
  45. /// </summary>
  46. /// <param name="orthographicSize">The orthographic size value.</param>
  47. public void SetOrthographicSize(float orthographicSize)
  48. {
  49. OrthographicSize = orthographicSize;
  50. ProjectSettings.SetFloat("SceneCameraOptions_OrthographicSize", orthographicSize);
  51. }
  52. /// <summary>
  53. /// Sets the field of view of the scene camera
  54. /// </summary>
  55. /// <param name="fieldOfView">The field of view value.</param>
  56. public void SetFieldOfView(float fieldOfView)
  57. {
  58. FieldOfView = (Degree)fieldOfView;
  59. ProjectSettings.SetFloat("SceneCameraOptions_FieldOfView", fieldOfView);
  60. }
  61. /// <summary>
  62. /// Sets the acceleration of the scene camera
  63. /// </summary>
  64. /// <param name="acceleration">The acceleration value.</param>
  65. public void SetAcceleration(float acceleration)
  66. {
  67. Acceleration = acceleration;
  68. ProjectSettings.SetFloat("SceneCameraOptions_Acceleration", acceleration);
  69. }
  70. /// <summary>
  71. /// Sets the fast mode multiplier of the scene camera
  72. /// </summary>
  73. /// <param name="fastModeMultiplier">The fast mode multiplier value.</param>
  74. public void SetFastModeMultiplier(float fastModeMultiplier)
  75. {
  76. FastModeMultiplier = fastModeMultiplier;
  77. ProjectSettings.SetFloat("SceneCameraOptions_FastModeMultiplier", fastModeMultiplier);
  78. }
  79. /// <summary>
  80. /// Sets the pan speed of the scene camera
  81. /// </summary>
  82. /// <param name="panSpeed">The pan speed value.</param>
  83. public void SetPanSpeed(float panSpeed)
  84. {
  85. PanSpeed = panSpeed;
  86. ProjectSettings.SetFloat("SceneCameraOptions_PanSpeed", panSpeed);
  87. }
  88. /// <summary>
  89. /// Sets the scroll speed of the scene camera
  90. /// </summary>
  91. /// <param name="scrollSpeed">The scroll speed value.</param>
  92. public void SetScrollSpeed(float scrollSpeed)
  93. {
  94. ScrollSpeed = scrollSpeed;
  95. ProjectSettings.SetFloat("SceneCameraOptions_ScrollSpeed", scrollSpeed);
  96. }
  97. /// <summary>
  98. /// Sets the rotation speed of the scene camera
  99. /// </summary>
  100. /// <param name="rotationalSpeed">The rotation speed value.</param>
  101. public void SetRotationalSpeed(float rotationalSpeed)
  102. {
  103. RotationalSpeed = rotationalSpeed;
  104. ProjectSettings.SetFloat("SceneCameraOptions_RotationalSpeed", rotationalSpeed);
  105. }
  106. /// <summary>
  107. /// Sets the near clip plane of the camera
  108. /// </summary>
  109. /// <param name="value">The near clip plane value.</param>
  110. public void SetNearClipPlane(float value)
  111. {
  112. value = MathEx.Clamp(value, MinNearClipPlane, MaxNearClipPlane);
  113. NearClipPlane = value;
  114. ProjectSettings.SetFloat("SceneCameraOptions_NearClipPlane", value);
  115. }
  116. /// <summary>
  117. /// Sets the far clip plane of the camera
  118. /// </summary>
  119. /// <param name="value">The far clip plane value.</param>
  120. public void SetFarClipPlane(float value)
  121. {
  122. value = MathEx.Clamp(value, MinFarClipPlane, MaxFarClipPlane);
  123. FarClipPlane = value;
  124. ProjectSettings.SetFloat("SceneCameraOptions_FarClipPlane", value);
  125. }
  126. }
  127. /** @} */
  128. }