BsRect3.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Math
  7. * @{
  8. */
  9. /// <summary>
  10. /// Represents a rectangle in three dimensional space. It is represented by two axes that extend from the specified
  11. /// origin. Axes should be perpendicular to each other and they extend in both positive and negative directions from
  12. /// the origin by the amount specified by extents.
  13. /// </summary>
  14. [StructLayout(LayoutKind.Sequential), SerializeObject]
  15. public struct Rect3 // Note: Must match C++ class Rect3
  16. {
  17. /// <summary>
  18. /// Creates a new rectangle.
  19. /// </summary>
  20. /// <param name="center">Origin of the rectangle. </param>
  21. /// <param name="axes">Two axes that define orientation of the rectangle. Axes extend from the origin. Axes should
  22. /// be normalized.</param>
  23. /// <param name="extents">Two extents that define the size of the rectangle. Extends should be half the width/height
  24. /// as they are applied in both directions.</param>
  25. public Rect3(Vector3 center, Vector3[] axes, float[] extents)
  26. {
  27. this._center = center;
  28. _axisHorz = axes[0];
  29. _axisVert = axes[1];
  30. _extentHorz = extents[0];
  31. _extentVert = extents[1];
  32. }
  33. /// <summary>
  34. /// Origin of the rectangle.
  35. /// </summary>
  36. public Vector3 Center
  37. {
  38. get { return _center; }
  39. set { _center = value; }
  40. }
  41. /// <summary>
  42. /// Returns the horizontal axis. Together with the vertical axis this defines rectangle orientation.
  43. /// </summary>
  44. public Vector3 AxisHorz
  45. {
  46. get { return _axisHorz; }
  47. set { _axisHorz = value; }
  48. }
  49. /// <summary>
  50. /// Returns the vertical axis. Together with the horizontal axis this defines rectangle orientation.
  51. /// </summary>
  52. public Vector3 AxisVert
  53. {
  54. get { return _axisVert; }
  55. set { _axisVert = value; }
  56. }
  57. /// <summary>
  58. /// Returns the extents in the direction of the horizontal axis. This represents half the total
  59. /// width of the rectangle.
  60. /// </summary>
  61. public float ExtentHorz
  62. {
  63. get { return _extentHorz; }
  64. set { _extentHorz = value; }
  65. }
  66. /// <summary>
  67. /// Returns the extents in the direction of the vertical axis. This represents half the total
  68. /// height of the rectangle.
  69. /// </summary>
  70. public float ExtentVert
  71. {
  72. get { return _extentVert; }
  73. set { _extentVert = value; }
  74. }
  75. [SerializeField]
  76. private Vector3 _center;
  77. [SerializeField]
  78. private Vector3 _axisHorz;
  79. [SerializeField]
  80. private Vector3 _axisVert;
  81. [SerializeField]
  82. private float _extentHorz;
  83. [SerializeField]
  84. private float _extentVert;
  85. };
  86. /** @} */
  87. }