#include <bsphere.h>
Nevrax France
Definition at line 45 of file bsphere.h.
Public Member Functions | |
| CBSphere (const CVector ¢er, float radius) | |
| Constructor. | |
| CBSphere () | |
| Empty Constructor. | |
| bool | include (const CBSphere &s) const |
| Does the sphere include TOTALY this sphere? | |
| bool | include (const CVector &p) const |
| Does the sphere include this point? | |
| bool | intersect (const CBSphere &s) const |
| Does the sphere intersect the other? | |
| void | setUnion (const CBSphere &sa, const CBSphere &sb) |
| Build the union of the 2 sphere ans set to *this. work if this==s1 || this==s2. | |
transform | |
| void | applyTransform (const CMatrix &mat, CBSphere &res) |
Clip | |
| bool | clipBack (const CPlane &p) const |
| Is the bbox partially in back of the plane?? p MUST be normalized. | |
| bool | clipFront (const CPlane &p) const |
| Is the bbox partially in front of the plane?? p MUST be normalized. | |
Data Fields | |
| CVector | Center |
| float | Radius |
|
|
Empty Constructor.
Definition at line 52 of file bsphere.h.
00052 {}
|
|
||||||||||||
|
Constructor.
Definition at line 54 of file bsphere.h.
|
|
||||||||||||
|
compute res= mat * this. NB: radius is maximized, taking max of the 3 axis of the matrix. NB: this may be false if the matrix is not orthogonal... Definition at line 88 of file bsphere.cpp. References NLMISC::CMatrix::getI(), NLMISC::CMatrix::getJ(), NLMISC::CMatrix::getK(), NLMISC::CMatrix::getScaleUniform(), NLMISC::CMatrix::hasScalePart(), NLMISC::CMatrix::hasScaleUniform(), res, and NLMISC::CVector::sqrnorm(). Referenced by NL3D::CSkeletonShape::clip(), NL3D::CSegRemanenceShape::clip(), NL3D::CMeshMRMSkinnedGeom::clip(), NL3D::CMeshMRMGeom::clip(), NL3D::CMeshGeom::clip(), and NL3D::CSkeletonModel::computeWorldBBoxForShadow().
00089 {
00090 res.Center= mat*Center;
00091
00092 if(!mat.hasScalePart())
00093 res.Radius= Radius;
00094 else
00095 {
00096 if(mat.hasScaleUniform())
00097 res.Radius= Radius*mat.getScaleUniform();
00098 else
00099 {
00100 // must compute max of 3 axis.
00101 float m, mx;
00102 CVector i,j,k;
00103 i= mat.getI();
00104 j= mat.getJ();
00105 k= mat.getK();
00106 // take the max of the 3 axis.
00107 m= i.sqrnorm();
00108 mx= m;
00109 m= j.sqrnorm();
00110 mx= max(m, mx);
00111 m= k.sqrnorm();
00112 mx= max(m, mx);
00113
00114 // result.
00115 res.Radius= Radius * (float)sqrt(mx);
00116 }
00117 }
00118 }
|
|
|
Is the bbox partially in back of the plane?? p MUST be normalized.
Definition at line 50 of file bsphere.cpp. Referenced by NL3D::CVegetableClipBlock::clip(), NL3D::CTessBlock::clip(), and NL3D::CZone::clipPatchs().
|
|
|
Is the bbox partially in front of the plane?? p MUST be normalized.
Definition at line 37 of file bsphere.cpp.
|
|
|
Does the sphere include TOTALY this sphere?
Definition at line 69 of file bsphere.cpp. References s, and NLMISC::sqr().
|
|
|
Does the sphere include this point?
Definition at line 63 of file bsphere.cpp. References NLMISC::sqr(), and NLMISC::CVector::sqrnorm(). Referenced by NL3D::CLightingManager::addDynamicLight(), NL3D::CZoneLighter::CPointLightRT::testRaytrace(), and NL3D::CInstanceLighter::CPointLightRT::testRaytrace().
|
|
|
Does the sphere intersect the other?
Definition at line 79 of file bsphere.cpp. References s, and NLMISC::sqr(). Referenced by NL3D::CLandscape::buildCollideFaces(), NL3D::CLandscape::computeDynamicLighting(), and NL3D::CMiniCol::setCenter().
|
|
||||||||||||
|
Build the union of the 2 sphere ans set to *this. work if this==s1 || this==s2.
Definition at line 122 of file bsphere.cpp. References Center, NLMISC::CVector::normalize(), and Radius.
00123 {
00124 float r2= (sb.Center-sa.Center).norm();
00125
00126 // Name Sphere 0 the biggest one, and Sphere 1 the other
00127 const CBSphere *s0;
00128 const CBSphere *s1;
00129 if(sa.Radius>sb.Radius)
00130 {
00131 s0= &sa;
00132 s1= &sb;
00133 }
00134 else
00135 {
00136 s0= &sb;
00137 s1= &sa;
00138 }
00139 float r0= s0->Radius;
00140 float r1= s1->Radius;
00141
00142 // If Sphere1 is included into Sphere0, then the union is simply Sphere0
00143 if(r2<=(r0-r1))
00144 {
00145 *this= *s0;
00146 }
00147 else
00148 {
00149 /* Compute the Union sphere Diameter. It is D= r0 + r2 + r1
00150 do the draw, works for intersect and don't intersect case,
00151 acknowledge that Sphere1 not included inton Sphere0
00152 */
00153 float diameter= r0 + r2 + r1;
00154
00155 // compute dir from big center to small one.
00156 CVector dir= s1->Center - s0->Center;
00157 dir.normalize();
00158
00159 // Then finally set Radius and center
00160 Center= s0->Center + dir * (diameter/2 - r0);
00161 Radius= diameter/2;
00162 }
00163 }
|
|
|
1.3.6