2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "../design/BoundingBoxConverter.h"
\r
27 #include "Vector3.h"
\r
29 using System::Runtime::InteropServices::OutAttribute;
\r
33 value class BoundingSphere;
\r
37 ref class DataStream;
\r
40 /// An axis aligned bounding box, specified by minimum and maximum vectors.
\r
42 /// <unmanaged>None</unmanaged>
\r
43 [System::Serializable]
\r
44 [System::Runtime::InteropServices::StructLayout( System::Runtime::InteropServices::LayoutKind::Sequential )]
\r
45 [System::ComponentModel::TypeConverter( SlimDX::Design::BoundingBoxConverter::typeid )]
\r
46 public value class BoundingBox : System::IEquatable<BoundingBox>
\r
50 /// The highest corner of the box.
\r
55 /// The lowest corner of the box.
\r
60 /// Initializes a new instance of the <see cref="BoundingBox"/> structure.
\r
62 /// <param name="minimum">The lowest corner of the box.</param>
\r
63 /// <param name="maximum">The highest corner of the box.</param>
\r
64 BoundingBox( Vector3 minimum, Vector3 maximum );
\r
67 /// Retrieves the eight corners of the bounding box.
\r
69 /// <returns>An array of points representing the eight corners of the bounding box.</returns>
\r
70 array<Vector3>^ GetCorners();
\r
73 /// Determines whether the box contains the specified box.
\r
75 /// <param name="box1">The first box that will be checked for containment.</param>
\r
76 /// <param name="box2">The second box that will be checked for containment.</param>
\r
77 /// <returns>A member of the <see cref="ContainmentType"/> enumeration indicating whether the two objects intersect, are contained, or don't meet at all.</returns>
\r
78 static ContainmentType Contains( BoundingBox box1, BoundingBox box2 );
\r
81 /// Determines whether the box contains the specified sphere.
\r
83 /// <param name="box">The box that will be checked for containment.</param>
\r
84 /// <param name="sphere">The sphere that will be checked for containment.</param>
\r
85 /// <returns>A member of the <see cref="ContainmentType"/> enumeration indicating whether the two objects intersect, are contained, or don't meet at all.</returns>
\r
86 static ContainmentType Contains( BoundingBox box, BoundingSphere sphere );
\r
89 /// Determines whether the box contains the specified point.
\r
91 /// <param name="box">The box that will be checked for containment.</param>
\r
92 /// <param name="vector">The point that will be checked for containment.</param>
\r
93 /// <returns>A member of the <see cref="ContainmentType"/> enumeration indicating whether the two objects intersect, are contained, or don't meet at all.</returns>
\r
94 static ContainmentType Contains( BoundingBox box, Vector3 vector );
\r
97 /// Constructs a <see cref="BoundingBox"/> that fully contains the given points.
\r
99 /// <param name="points">The points that will be contained by the box.</param>
\r
100 /// <returns>The newly constructed bounding box.</returns>
\r
101 static BoundingBox FromPoints( array<Vector3>^ points );
\r
104 /// Constructs a <see cref="BoundingBox"/> that fully contains the given points.
\r
106 /// <param name="points">The points that will be contained by the box.</param>
\r
107 /// <param name="count">The number of vertices in the stream.</param>
\r
108 /// <param name="stride">The number of bytes between vertices.</param>
\r
109 /// <returns>The newly constructed bounding box.</returns>
\r
110 static BoundingBox FromPoints( DataStream^ points, int count, int stride );
\r
113 /// Constructs a <see cref="BoundingBox"/> from a given sphere.
\r
115 /// <param name="sphere">The sphere that will designate the extents of the box.</param>
\r
116 /// <returns>The newly constructed bounding box.</returns>
\r
117 static BoundingBox FromSphere( BoundingSphere sphere );
\r
120 /// Constructs a <see cref="BoundingBox"/> that is the as large as the total combined area of the two specified boxes.
\r
122 /// <param name="box1">The first box to merge.</param>
\r
123 /// <param name="box2">The second box to merge.</param>
\r
124 /// <returns>The newly constructed bounding box.</returns>
\r
125 static BoundingBox Merge( BoundingBox box1, BoundingBox box2 );
\r
128 /// Determines whether a box intersects the specified object.
\r
130 /// <param name="box1">The first box which will be tested for intersection.</param>
\r
131 /// <param name="box2">The second box that will be tested for intersection.</param>
\r
132 /// <returns><c>true</c> if the two objects are intersecting; otherwise, <c>false</c>.</returns>
\r
133 static bool Intersects( BoundingBox box1, BoundingBox box2 );
\r
136 /// Determines whether a box intersects the specified object.
\r
138 /// <param name="box">The box which will be tested for intersection.</param>
\r
139 /// <param name="sphere">The sphere that will be tested for intersection.</param>
\r
140 /// <returns><c>true</c> if the two objects are intersecting; otherwise, <c>false</c>.</returns>
\r
141 static bool Intersects( BoundingBox box, BoundingSphere sphere );
\r
144 /// Determines whether a box intersects the specified object.
\r
146 /// <param name="box">The box which will be tested for intersection.</param>
\r
147 /// <param name="ray">The ray that will be tested for intersection.</param>
\r
148 /// <param name="distance">When the method completes, contains the distance from the ray's origin in which the intersection with the box occured.</param>
\r
149 /// <returns><c>true</c> if the two objects are intersecting; otherwise, <c>false</c>.</returns>
\r
150 static bool Intersects( BoundingBox box, Ray ray, [Out] float% distance );
\r
153 /// Finds the intersection between a plane and a box.
\r
155 /// <param name="box">The box to check for intersection.</param>
\r
156 /// <param name="plane">The source plane.</param>
\r
157 /// <returns>A value from the <see cref="PlaneIntersectionType"/> enumeration describing the result of the intersection test.</returns>
\r
158 static PlaneIntersectionType Intersects( BoundingBox box, Plane plane );
\r
161 /// Tests for equality between two objects.
\r
163 /// <param name="left">The first value to compare.</param>
\r
164 /// <param name="right">The second value to compare.</param>
\r
165 /// <returns><c>true</c> if <paramref name="left"/> has the same value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
\r
166 static bool operator == ( BoundingBox left, BoundingBox right );
\r
169 /// Tests for inequality between two objects.
\r
171 /// <param name="left">The first value to compare.</param>
\r
172 /// <param name="right">The second value to compare.</param>
\r
173 /// <returns><c>true</c> if <paramref name="left"/> has a different value than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
\r
174 static bool operator != ( BoundingBox left, BoundingBox right );
\r
177 /// Converts the value of the object to its equivalent string representation.
\r
179 /// <returns>The string representation of the value of this instance.</returns>
\r
180 virtual System::String^ ToString() override;
\r
183 /// Returns the hash code for this instance.
\r
185 /// <returns>A 32-bit signed integer hash code.</returns>
\r
186 virtual int GetHashCode() override;
\r
189 /// Returns a value that indicates whether the current instance is equal to a specified object.
\r
191 /// <param name="obj">Object to make the comparison with.</param>
\r
192 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>
\r
193 virtual bool Equals( System::Object^ obj ) override;
\r
196 /// Returns a value that indicates whether the current instance is equal to the specified object.
\r
198 /// <param name="other">Object to make the comparison with.</param>
\r
199 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>
\r
200 virtual bool Equals( BoundingBox other );
\r
203 /// Determines whether the specified object instances are considered equal.
\r
205 /// <param name="value1"></param>
\r
206 /// <param name="value2"></param>
\r
207 /// <returns><c>true</c> if <paramref name="value1"/> is the same instance as <paramref name="value2"/> or
\r
208 /// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
\r
209 static bool Equals( BoundingBox% value1, BoundingBox% value2 );
\r