BsRect3.cs 3.3 KB

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