00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Ramin Kamal 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: UT_BoundingSphere.h ( Utility Library, C++) 00015 * 00016 * COMMENTS: 00017 * This class implements a bounding sphere (with unity scale). 00018 * It's not very precise. It's mainly meant for a one time 00019 * calculation of a bounding sphere. If you try combining bounding 00020 * spheres, you get rather gross results compared to your initial 00021 * points. 00022 */ 00023 00024 #ifndef __UT_BoundingSphere__ 00025 #define __UT_BoundingSphere__ 00026 00027 #include "UT_API.h" 00028 #include "UT_Vector3.h" 00029 #include "UT_Vector4.h" 00030 #include "UT_Vector3Array.h" 00031 00032 class UT_API UT_BoundingSphere 00033 { 00034 public: 00035 UT_BoundingSphere(); 00036 ~UT_BoundingSphere(); 00037 00038 int isInside(const UT_Vector3 &pt) const; 00039 00040 fpreal getRadius() const { return myRadius; } 00041 const UT_Vector3 &getCenter() const { return myCenter; } 00042 00043 void initialize(int requiresUpdate = 0); 00044 void computeBound(); 00045 fpreal computeRadius(const UT_Vector3 ¢er) const; 00046 00047 void addPoint(const UT_Vector3 &pt); 00048 void addPoint(const UT_Vector4 &pt); 00049 void addPoint(const float *pt); 00050 00051 void addSphere(const UT_BoundingSphere &bsphere); 00052 UT_BoundingSphere &operator=(const UT_BoundingSphere &bsphere); 00053 void transform(const UT_Matrix4 &xform); 00054 00055 private: 00056 UT_Vector3 myCenter; 00057 fpreal myRadius; 00058 fpreal myRadiusSquared; 00059 UT_Vector3 myMins[3]; 00060 UT_Vector3 myMaxs[3]; 00061 int myDoDynamic; 00062 UT_Vector3Array myPointArray; 00063 }; 00064 #endif 00065
1.5.9