- Timestamp:
- 12/01/08 16:50:13 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/AxisAlignedBox3.h
r3070 r3202 17 17 18 18 19 /** A very simple ray structure. 20 */ 19 21 struct SimpleRay 20 22 { … … 22 24 23 25 SimpleRay(const Vector3 &o, const Vector3 &d): mOrigin(o), mDirection(d) {} 24 25 Vector3 mOrigin;26 Vector3 mDirection;27 26 28 27 Vector3 Extrap(const float t) const … … 30 29 return mOrigin + mDirection * t; 31 30 } 31 32 33 //////////////7 34 35 Vector3 mOrigin; 36 Vector3 mDirection; 37 32 38 }; 33 39 … … 45 51 //-- Constructors. 46 52 53 /** Default constructor creating an existing box. 54 The user has to call Initialize once in order 55 to be able to use the box. 56 */ 47 57 AxisAlignedBox3(); 48 58 /** Constructor taking the minimum and maximum as parameters. 59 */ 49 60 AxisAlignedBox3(const Vector3 &nMin, const Vector3 &nMax); 50 61 /** initialization to the non existing bounding box … … 57 68 */ 58 69 Vector3 Diagonal() const; 59 70 /** Computes the mid point in the given axis. 71 */ 60 72 float Center(const int axis) const; 61 73 /** The vertex of the box with the smallest values in all dimensions. 74 */ 62 75 float Min(const int axis) const; 63 76 /** The vertex of the box with the largest values in all dimensions. 77 */ 64 78 float Max(const int axis) const; 65 79 /** The extent of the box in the given axis. 80 */ 66 81 float Size(const int axis) const; 67 82 /** Returns axis where box has largest extent. … … 71 86 */ 72 87 const Vector3& Min() const; 88 /** See Min 89 */ 73 90 const Vector3& Max() const; 74 91 /** Enlarges box in all dimensions by adding with the given value. 92 */ 75 93 void Enlarge(const Vector3 &v); 76 94 /** If the box is degenerate, this function enlarges the box 95 to the minimum valid size. 96 */ 77 97 void EnlargeToMinSize(); 78 98 /** Sets a new minimum of the box. 99 */ 79 100 void SetMin(const Vector3 &v); 80 101 /** Sets a new maximum of the box. 102 */ 81 103 void SetMax(const Vector3 &v); 82 104 /** Sets the minimum for one dimension. 105 */ 83 106 void SetMin(int axis, const float value); 84 107 /** Sets the maximum for one dimension. 108 */ 85 109 void SetMax(int axis, const float value); 86 110 /** Decrease box by given splitting plane 87 111 */ 88 112 void Reduce(int axis, int right, float value); 89 113 /** Returns true if the box intersects the line given by the end 114 vertices. 115 */ 90 116 bool Intersects(const Vector3 &lStart, const Vector3 &lEnd) const; 91 92 // the size of the box along all the axes117 /** The size of the box along all the axes 118 */ 93 119 Vector3 Size() const; 94 float Radius() const { return 0.5f * Magnitude(Size()); } 95 float SqrRadius() const { return 0.5f * SqrMagnitude(Size()); } 120 /** The diagonal radius of the box. 121 */ 122 float Radius() const; 123 /** The square radius. 124 */ 125 float SqrRadius() const; 96 126 /** Return whether the box is unbounded. Unbounded boxes appear 97 127 when unbounded objects such as quadric surfaces are included. … … 99 129 bool Unbounded() const; 100 130 101 // Expand the axis-aligned box to include the given object. 131 /** Expand the axis-aligned box to include the given object. 132 */ 102 133 void Include(const Vector3 &newpt); 103 134 void Include(const AxisAlignedBox3 &bbox); … … 111 142 */ 112 143 bool Includes(const AxisAlignedBox3 &b) const; 113 114 144 /** Returns true if this point is inside box. 115 145 */ … … 160 190 ID_Top = 5}; 161 191 162 // Writes a brief description of the object, indenting by the given 163 // number of spaces first. 192 /** Writes a brief description of the object, indenting by the given 193 number of spaces first. 194 */ 164 195 virtual void Describe(std::ostream& app, int ind) const; 165 196 166 // For edge .. number <0..11> returns two incident vertices 197 /** For edge .. number <0..11> returns two incident vertices 198 */ 167 199 void GetEdge(int edge, Vector3 *a, Vector3 *b) const; 168 169 // Compute the coordinates of one vertex of the box for 0/1 in each axis170 // 0 .. smaller coordinates, 1 .. large coordinates200 /** Compute the coordinates of one vertex of the box for 0/1 in each axis 201 0 .. smaller coordinates, 1 .. large coordinates 202 */ 171 203 Vector3 GetVertex(int xAxis, int yAxis, int zAxis) const; 172 173 // Compute the vertex for number N=<0..7>, N = 4*x + 2*y + z, where174 // x,y,z are either 0 or 1; (0 .. lower coordinate, 1 .. large coordinate)175 // (xmin,ymin, zmin) .. N = 0, (xmax, ymax, zmax) .. N= 7 204 /** Compute the vertex for number N=<0..7>, N = 4*x + 2*y + z, where 205 x,y,z are either 0 or 1; (0 .. lower coordinate, 1 .. large coordinate) 206 (xmin,ymin, zmin) .. N = 0, (xmax, ymax, zmax) .. N= 7 207 */ 176 208 void GetVertex(int N, Vector3 &vertex) const; 177 209 /** Convencience method that returns a vertex internally using the 210 above routine. 211 */ 178 212 Vector3 GetVertex(int N) const; 213 /** Uses different vertex order: vertices are chosen so that they 214 only differ by one value (min or max) in the x, y, z triple 215 */ 216 void GetVertex2(int N, Vector3 &vertex) const; 179 217 /** get the extent of face. 180 218 */ … … 322 360 // -------------------------------------------------------------------------- 323 361 // Implementation of inline (member) functions 362 363 inline float AxisAlignedBox3::Radius() const 364 { 365 return 0.5f * Magnitude(Size()); 366 } 367 368 369 inline float AxisAlignedBox3::SqrRadius() const 370 { 371 return 0.5f * SqrMagnitude(Size()); 372 } 373 324 374 325 375 inline bool
Note: See TracChangeset
for help on using the changeset viewer.