BsRect3.cs 2.8 KB

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