BsRect3.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.
  16. /// </param>
  17. /// <param name="axes">Two axes that define orientation of the rectangle. Axes extend from the origin.
  18. /// Axes should be normalized.
  19. /// </param>
  20. /// <param name="extents">Two extents that define the size of the rectangle. Extends should be
  21. /// half the width/height as they are applied in both directions.
  22. /// </param>
  23. public Rect3(Vector3 center, Vector3[] axes, float[] extents)
  24. {
  25. this._center = center;
  26. _axisHorz = axes[0];
  27. _axisVert = axes[1];
  28. _extentHorz = extents[0];
  29. _extentVert = extents[1];
  30. }
  31. /// <summary>
  32. /// Origin of the rectangle.
  33. /// </summary>
  34. public Vector3 Center
  35. {
  36. get { return _center; }
  37. set { _center = value; }
  38. }
  39. /// <summary>
  40. /// Returns the horizontal axis. Together with the vertical axis this defines rectangle orientation.
  41. /// </summary>
  42. public Vector3 AxisHorz
  43. {
  44. get { return _axisHorz; }
  45. set { _axisHorz = value; }
  46. }
  47. /// <summary>
  48. /// Returns the vertical axis. Together with the horizontal axis this defines rectangle orientation.
  49. /// </summary>
  50. public Vector3 AxisVert
  51. {
  52. get { return _axisVert; }
  53. set { _axisVert = value; }
  54. }
  55. /// <summary>
  56. /// Returns the extents in the direction of the horizontal axis. This represents half the total
  57. /// width of the rectangle.
  58. /// </summary>
  59. public float ExtentHorz
  60. {
  61. get { return _extentHorz; }
  62. set { _extentHorz = value; }
  63. }
  64. /// <summary>
  65. /// Returns the extents in the direction of the vertical axis. This represents half the total
  66. /// height of the rectangle.
  67. /// </summary>
  68. public float ExtentVert
  69. {
  70. get { return _extentVert; }
  71. set { _extentVert = value; }
  72. }
  73. private Vector3 _center;
  74. private Vector3 _axisHorz;
  75. private Vector3 _axisVert;
  76. private float _extentHorz;
  77. private float _extentVert;
  78. };
  79. }