BoundedPlane.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using UnityEngine;
  2. namespace UnityARInterface
  3. {
  4. public struct BoundedPlane
  5. {
  6. public string id;
  7. public Vector3 center;
  8. public Vector2 extents;
  9. public Quaternion rotation;
  10. public Vector3 normal { get { return rotation * Vector3.up; } }
  11. public Plane plane { get { return new Plane(normal, center); } }
  12. public float width
  13. {
  14. get { return extents.x; }
  15. set { extents.x = value; }
  16. }
  17. public float height
  18. {
  19. get { return extents.y; }
  20. set { extents.y = value; }
  21. }
  22. public Vector3[] quad
  23. {
  24. get
  25. {
  26. Vector3[] points = new Vector3[4];
  27. var right = rotation * Vector3.right * extents.x / 2;
  28. var forward = rotation * Vector3.forward * extents.y / 2;
  29. points[0] = center + right - forward;
  30. points[1] = center + right + forward;
  31. points[2] = center + -right + forward;
  32. points[3] = center + -right - forward;
  33. return points;
  34. }
  35. }
  36. }
  37. }