CollideBox.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // CollideBox.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13. using Microsoft.Xna.Framework;
  14. using Microsoft.Xna.Framework.Graphics;
  15. #endregion
  16. namespace RobotGameData.Collision
  17. {
  18. /// <summary>
  19. /// It's a collision box.
  20. /// </summary>
  21. public class CollideBox : CollideElement
  22. {
  23. #region Fields
  24. /// <summary>
  25. /// min local position of the bounding box
  26. /// </summary>
  27. protected Vector3 localMin = Vector3.Zero;
  28. /// <summary>
  29. /// max local position of the bounding box
  30. /// </summary>
  31. protected Vector3 localMax = Vector3.Zero;
  32. /// <summary>
  33. /// Bounding box
  34. /// </summary>
  35. protected BoundingBox boundingBox;
  36. #endregion
  37. #region Properties
  38. public BoundingBox BoundingBox
  39. {
  40. get { return boundingBox; }
  41. }
  42. #endregion
  43. /// <summary>
  44. /// Constructor.
  45. /// </summary>
  46. /// <param name="min">min size of the box</param>
  47. /// <param name="max">max size of the box</param>
  48. public CollideBox(Vector3 min, Vector3 max) : base()
  49. {
  50. localMin = min;
  51. localMax = max;
  52. boundingBox = new BoundingBox(localMin, localMax);
  53. }
  54. /// <summary>
  55. /// Transform the bounding box.
  56. /// </summary>
  57. public override void Transform(Matrix matrix)
  58. {
  59. boundingBox.Min = Vector3.Transform(localMin, matrix);
  60. boundingBox.Max = Vector3.Transform(localMax, matrix);
  61. base.Transform(matrix);
  62. }
  63. }
  64. }