Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Volume
[Base]


Classes

class  osg::BoxVolume
class  osg::CylinderVolume
class  osg::DynamicVolume
class  osg::FrustumVolume
class  osg::SphereVolume
class  osg::Volume

Functions

bool osg::intersect (const Volume &vol1, const Volume &vol2)
 intersect Volume / Volume
bool osg::intersect (const BoxVolume &box1, const BoxVolume &box2)
 intersect Box / Box
bool osg::intersect (const BoxVolume &box, const SphereVolume &sphere)
 intersect BoxVolume / Sphere
bool osg::intersect (const BoxVolume &box, const CylinderVolume &cylinder)
 intersect BoxVolume / Cylinder
bool osg::intersect (const BoxVolume &box, const FrustumVolume &frustum)
 intersect BoxVolume / Frustum
bool osg::intersect (const BoxVolume &box, const Volume &vol)
 intersect Box / Volume
bool osg::intersect (const SphereVolume &vol1, const BoxVolume &vol2)
 intersect Sphere / Box
bool osg::intersect (const SphereVolume &sphere1, const SphereVolume &sphere2)
 intersect SphereVolume / Sphere
bool osg::intersect (const SphereVolume &sphere, const CylinderVolume &cylinder)
 intersect SphereVolume / Cylinder
bool osg::intersect (const SphereVolume &sphere, const FrustumVolume &frustum)
 intersect SphereVolume / Frustum
bool osg::intersect (const SphereVolume &sphere, const Volume &vol)
 intersect Sphere / Volume
bool osg::intersect (const CylinderVolume &vol1, const BoxVolume &vol2)
 intersect Cylinder / Box
bool osg::intersect (const CylinderVolume &vol1, const SphereVolume &vol2)
 intersect CylinderVolume / Sphere
bool osg::intersect (const CylinderVolume &cylinder1, const CylinderVolume &cylinder2)
 intersect CylinderVolume / Cylinder
bool osg::intersect (const CylinderVolume &cylinder, const FrustumVolume &frustum)
 intersect CylinderVolume / Frustum
bool osg::intersect (const CylinderVolume &cylinder, const Volume &vol)
 intersect Cylinder / Volume
bool osg::intersect (const FrustumVolume &vol1, const BoxVolume &vol2)
 intersect Frustum / Box
bool osg::intersect (const FrustumVolume &vol1, const SphereVolume &vol2)
 intersect FrustumVolume / Sphere
bool osg::intersect (const FrustumVolume &vol1, const CylinderVolume &vol2)
 intersect FrustumVolume / Cylinder
bool osg::intersect (const FrustumVolume &frustum1, const FrustumVolume &frustum2)
 intersect FrustumVolume / Frustum
bool osg::intersect (const FrustumVolume &frustum, const Volume &vol)
 intersect Frustum / Volume
bool osg::intersect (const Volume &srcVol, const BoxVolume &vol)
 extend Frustum / Box
bool osg::intersect (const Volume &srcVol, const SphereVolume &vol)
 extend volume / Sphere
bool osg::intersect (const Volume &srcVol, const CylinderVolume &vol)
 extend volume / Cylinder
bool osg::intersect (const Volume &srcVol, const FrustumVolume &vol)
 extend volume / Frustum
void osg::extend (BoxVolume &srcVol, const BoxVolume &vol)
 extend Box / Box
void osg::extend (BoxVolume &srcVol, const SphereVolume &vol)
 extend BoxVolume / Sphere
void osg::extend (BoxVolume &srcVol, const CylinderVolume &vol)
 extend BoxVolume / Cylinder
void osg::extend (BoxVolume &srcVol, const FrustumVolume &vol)
 extend BoxVolume / Frustum
void osg::extend (BoxVolume &srcVol, const Volume &vol)
 extend Box / Volume
void osg::extend (SphereVolume &srcVol, const BoxVolume &vol)
 extend Sphere / Box
void osg::extend (SphereVolume &srcVol, const SphereVolume &vol)
 extend SphereVolume / Sphere
void osg::extend (SphereVolume &srcVol, const CylinderVolume &vol)
 extend SphereVolume / Cylinder
void osg::extend (SphereVolume &srcVol, const FrustumVolume &vol)
 extend SphereVolume / Frustum
void osg::extend (SphereVolume &srcVol, const Volume &vol)
 extend SphereVolume / Volume
void osg::extend (CylinderVolume &srcVol, const BoxVolume &vol)
 extend Cylinder / Box
void osg::extend (CylinderVolume &srcVol, const SphereVolume &vol)
 extend CylinderVolume / Sphere
void osg::extend (CylinderVolume &srcVol, const CylinderVolume &vol)
 extend CylinderVolume / Cylinder
void osg::extend (CylinderVolume &srcVol, const FrustumVolume &vol)
 extend CylinderVolume / Frustum
void osg::extend (CylinderVolume &srcVol, const Volume &vol)
 extend Sphere / Volume
void osg::extend (FrustumVolume &srcVol, const BoxVolume &vol)
 extend Frustum / Box
void osg::extend (FrustumVolume &srcVol, const SphereVolume &vol)
 extend FrustumVolume / Sphere
void osg::extend (FrustumVolume &srcVol, const CylinderVolume &vol)
 extend FrustumVolume / Cylinder
void osg::extend (FrustumVolume &srcVol, const FrustumVolume &vol)
 extend FrustumVolume / Frustum
void osg::extend (FrustumVolume &srcVol, const Volume &vol)
 extend Frustum / Volume

Detailed Description

ToDo

Function Documentation

bool osg::intersect const Volume &  vol1,
const Volume &  vol2
 

Definition at line 53 of file OSGVolumeFunctions.cpp.

References osg::intersect().

00054 {
00055     bool                  retCode = false;
00056 
00057     const DynamicVolume  *dv      = dynamic_cast<const DynamicVolume *>(&vol1);
00058     const Volume         *v       = dv ? &(dv->getInstance()) : &vol1;
00059     const BoxVolume      *bv;
00060     const SphereVolume   *sv;
00061     const CylinderVolume *cv;
00062     const FrustumVolume  *fv;
00063 
00064     if((bv = dynamic_cast<const BoxVolume *>(v)) != NULL)
00065     {
00066         retCode = intersect(*bv, vol2);
00067     }
00068     else if((sv = dynamic_cast<const SphereVolume   *>(v)) != NULL)
00069     {
00070         retCode = intersect(*sv, vol2);
00071     }
00072     else if((cv = dynamic_cast<const CylinderVolume *>(v)) != NULL)
00073     {
00074         retCode = intersect(*cv, vol2);
00075     }
00076     else if((fv = dynamic_cast<const FrustumVolume  *>(v)) != NULL)
00077     {
00078         retCode = intersect(*fv, vol2);
00079     }
00080 
00081     return retCode;
00082 }

bool osg::intersect const BoxVolume &  vol1,
const BoxVolume &  vol2
 

Definition at line 87 of file OSGVolumeFunctions.cpp.

00088 {
00089     bool retCode = false;
00090 
00091     if(box1.isEmpty() == true || box2.isEmpty() == true)
00092     {
00093         retCode = false;
00094     }
00095     else if(box1.isInfinite() == true || box2.isInfinite() == true)
00096     {
00097         retCode = true;
00098     }
00099     else
00100     {
00101         retCode =
00102             (box1.getMin()[0] <= box2.getMax()[0] &&
00103              box1.getMax()[0] >= box2.getMin()[0]   ) &&
00104             (box1.getMin()[1] <= box2.getMax()[1] &&
00105              box1.getMax()[1] >= box2.getMin()[1]   ) &&
00106             (box1.getMin()[2] <= box2.getMax()[2] &&
00107              box1.getMax()[2] >= box2.getMin()[2]   );
00108     }
00109 
00110     return retCode;
00111 }

bool osg::intersect const BoxVolume &  vol1,
const SphereVolume &  vol2
 

Definition at line 115 of file OSGVolumeFunctions.cpp.

00116 {
00117     // source:
00118     // J. Arvo. A simple method for box-sphere intersection testing.
00119     // In A. Glassner, editor, Graphics Gems, pp. 335-339,
00120     // Academic Press, Boston, MA, 1990
00121 
00122     bool    retCode;
00123    
00124     if(box.isEmpty() == true || sphere.isEmpty() == true)
00125     {
00126         retCode = false;
00127     }
00128     else if(box.isInfinite() == true || sphere.isInfinite() == true)
00129     {
00130         retCode = true;
00131     }
00132     else
00133     {
00134         Real32  s;
00135         Real32  d = 0.f;
00136 
00137         //find the square of the distance from the sphere to the box
00138 
00139         for(Int32 i = 0; i < 3; i++)
00140         {
00141             if(sphere.getCenter()[i] < box.getMin()[i])
00142             {
00143                 s  = sphere.getCenter()[i] - box.getMin()[i];
00144                 d += s * s;
00145             }
00146             else if(sphere.getCenter()[i] > box.getMax()[i])
00147             {
00148                 s  = sphere.getCenter()[i] - box.getMax()[i];
00149                 d += s * s;
00150             }
00151         }
00152 
00153         retCode = (d <= (sphere.getRadius() * sphere.getRadius()));
00154     }
00155 
00156     return retCode;
00157 }

bool osg::intersect const BoxVolume &  vol1,
const CylinderVolume &  vol2
 

Definition at line 160 of file OSGVolumeFunctions.cpp.

References p.

00161 {
00162     bool  retCode;
00163     Pnt3f apos;
00164     Vec3f adir;
00165 
00166     cylinder.getAxis(apos, adir);
00167 
00168     if(box.isEmpty() == true || cylinder.isEmpty() == true)
00169     {
00170         retCode = false;
00171     }
00172     else if(box.isInfinite() == true || cylinder.isInfinite() == true)
00173     {
00174         retCode = true;
00175     }
00176     else
00177     {
00178         Real32  s1 = 0, s2 = 0, s3 = 0, s4 = 0, d = 0, d1 = 0, d2 = 0;
00179         Pnt3f   c, p, p1, p2;
00180         Vec3f   u, u1, u2;
00181 
00182         // find the distance between the min and the max of the box
00183         //with the lower point and the upper point of the cylinder respectively
00184 
00185         s1 = (apos - box.getMin()).length();
00186         s2 = (apos - box.getMax()).length();
00187 
00188         s3 = (apos + adir - box.getMin()).length();
00189         s4 = (apos + adir - box.getMax()).length();
00190 
00191         //Check the minimum of the above distances
00192 
00193         if(s1 <= s2)
00194         {
00195             d1 = s1;
00196             p1 = box.getMin();
00197         }
00198         else
00199         {
00200             d1 = s2;
00201             p1 = box.getMax();
00202         }
00203 
00204         if(s3 <= s4)
00205         {
00206             d2 = s3;
00207             p2 = box.getMin();
00208         }
00209         else
00210         {
00211             d2 = s4;
00212             p2 = box.getMax();
00213         }
00214 
00215         //set the value of the vector corresponding to the shortest distance
00216         if(d1 <= d2)
00217         {
00218             d = d1;
00219             c = apos;
00220             p = p1;
00221         }
00222         else
00223         {
00224             d = d2;
00225             c = apos + adir;
00226             p = p2;
00227         }
00228 
00229         // decompose the vector in u1 and u2 which are parallel and 
00230         // perpendicular to the cylinder axis respectively
00231         u  = p - c;
00232         u1 = (u[0] * adir[0] + u[1] * adir[1] + u[2] * adir[2]) /
00233             (adir.length() * adir.length()) * adir;
00234 
00235         u2 = u - u1;
00236 
00237         if(u1.length() <= 10e-6)
00238         {
00239             retCode = true;
00240         }
00241         else if(u2.length() <= 10e-6)
00242         {
00243             retCode = (d <= 10e-6);
00244         }
00245         else
00246         {
00247             retCode = (u2.length() <= cylinder.getRadius());
00248         }
00249     }
00250 
00251     return retCode;
00252 }

bool osg::intersect const BoxVolume &  vol1,
const FrustumVolume &  vol2
 

Definition at line 256 of file OSGVolumeFunctions.cpp.

00257 {
00258     Pnt3f min, max;
00259     box.getBounds(min, max);
00260 
00261     const Plane       *frust = frustum.getPlanes();
00262 
00263     // check each point of the box to the 6 planes
00264 
00265     for(Int32 i = 0; i < 6; i++)
00266     {
00267         if(frust[i].isOutHalfSpace(min, max))
00268             return false;
00269     }
00270 
00271     return true;
00272 }

bool osg::intersect const BoxVolume &  vol1,
const Volume &  vol2
 

Definition at line 275 of file OSGVolumeFunctions.cpp.

References osg::intersect().

00276 {
00277     bool                 retCode = false;
00278 
00279     const DynamicVolume  *dv     = dynamic_cast<const DynamicVolume *>(&vol);
00280     const Volume         *v      = dv ? &(dv->getInstance()) : &vol;
00281     const BoxVolume      *bv;
00282     const SphereVolume   *sv;
00283     const CylinderVolume *cv;
00284     const FrustumVolume  *fv;
00285 
00286     if((bv = dynamic_cast<const BoxVolume *>(v)) != NULL)
00287     {
00288         retCode = intersect(box, *bv);
00289     }
00290     else if((sv = dynamic_cast<const SphereVolume   *>(v)) != NULL)
00291     {
00292         retCode = intersect(box, *sv);
00293     }
00294     else if((cv = dynamic_cast<const CylinderVolume *>(v)) != NULL)
00295     {
00296         retCode = intersect(box, *cv);
00297     }
00298     else if((fv = dynamic_cast<const FrustumVolume  *>(v)) != NULL)
00299     {
00300         retCode = intersect(box, *fv);
00301     }
00302 
00303     return retCode;
00304 }

bool osg::intersect const SphereVolume &  vol1,
const BoxVolume &  vol2
[inline]
 

Definition at line 55 of file OSGVolumeFunctions.inl.

References osg::intersect().

00056 {
00057     return intersect(box, sphere);
00058 }

bool osg::intersect const SphereVolume &  vol1,
const SphereVolume &  vol2
 

Definition at line 310 of file OSGVolumeFunctions.cpp.

00311 {
00312     bool    retCode = false;
00313     Real32  dist    = (sphere2.getCenter() - sphere1.getCenter()).length();
00314 
00315     if(sphere1.isEmpty() || sphere2.isEmpty())
00316     {
00317         retCode = false;
00318     }
00319     else if(sphere1.isInfinite() || sphere2.isInfinite())
00320     {
00321         retCode = true;
00322     }
00323     else if(dist < sphere1.getRadius() + sphere2.getRadius())
00324     {
00325         // the distance between the center of the 2 spheres is bigger
00326         // than the sum of the 2 radiuses
00327 
00328         retCode = true;
00329     }
00330 
00331     return retCode;
00332 }

bool osg::intersect const SphereVolume &  vol1,
const CylinderVolume &  vol2
 

Definition at line 336 of file OSGVolumeFunctions.cpp.

00337 {
00338     bool  retCode;
00339     Pnt3f apos;
00340     Vec3f adir;
00341 
00342     cylinder.getAxis(apos, adir);
00343 
00344     if(sphere.isEmpty() || cylinder.isEmpty())
00345     {
00346         retCode = false;
00347     }
00348     else if(sphere.isInfinite() || cylinder.isInfinite())
00349     {
00350         retCode = true;
00351     }
00352     else
00353     {
00354         Real32  d = 0.f, s1 = 0.f, s2 = 0.f;
00355         Pnt3f   c;
00356         Vec3f   u, u1, u2;
00357 
00358         //get the distance between the upper and lower point of the cylinder
00359         // and the sphere center
00360 
00361         s1 = (apos        - sphere.getCenter()).length();
00362         s2 = (apos + adir - sphere.getCenter()).length();
00363 
00364         if ((s1<=DBL_EPSILON) || (s2<=DBL_EPSILON)) 
00365             return true;
00366         
00367         //check the smallest distance and set the vector coordinate
00368         if(s1 <= s2)
00369         {
00370             d = s1;
00371             c = apos;
00372         }
00373         else
00374         {
00375             d = s2;
00376             c = apos + adir;
00377         }
00378 
00379         // decompose the vector in u1 and u2 which are parallel and 
00380         // perpendicular to the cylinder axis respectively
00381 
00382         u  = ((d - sphere.getRadius()) / d) * (c - sphere.getCenter());
00383 
00384         u1 = (u[0] * adir[0] + u[1] * adir[1] + u[2] * adir[2]) / 
00385              (adir.length() * adir.length()) * adir;
00386         u2 = u - u1;
00387 
00388         if(u2.length() <= 10e-6)
00389         {
00390             retCode = (d <= sphere.getRadius());
00391         }
00392         else
00393         {
00394             retCode = (u2.length() <= cylinder.getRadius());
00395         }
00396     }
00397 
00398     return retCode;
00399 }

bool osg::intersect const SphereVolume &  vol1,
const FrustumVolume &  vol2
 

Definition at line 403 of file OSGVolumeFunctions.cpp.

00404 {
00405     const Plane             *frust = frustum.getPlanes();
00406 
00407     //check the center of the sphere with each plane of the frustum
00408     for(Int32 i = 0; i < 6; i++)
00409     {
00410         if(frust[i].distance(sphere.getCenter()) < -sphere.getRadius())
00411             return false;
00412     }
00413 
00414     return true;
00415 }

bool osg::intersect const SphereVolume &  vol1,
const Volume &  vol2
 

Definition at line 419 of file OSGVolumeFunctions.cpp.

References osg::intersect().

00420 {
00421     bool                 retCode = false;
00422 
00423     const DynamicVolume  *dv     = dynamic_cast<const DynamicVolume *>(&vol);
00424     const Volume         *v      = dv ? &(dv->getInstance()) : &vol;
00425     const BoxVolume      *bv;
00426     const SphereVolume   *sv;
00427     const CylinderVolume *cv;
00428     const FrustumVolume  *fv;
00429 
00430     if((bv = dynamic_cast<const BoxVolume *>(v)) != NULL)
00431     {
00432         retCode = intersect(sphere, *bv);
00433     }
00434     else if((sv = dynamic_cast<const SphereVolume   *>(v)) != NULL)
00435     {
00436         retCode = intersect(sphere, *sv);
00437     }
00438     else if((cv = dynamic_cast<const CylinderVolume *>(v)) != NULL)
00439     {
00440         retCode = intersect(sphere, *cv);
00441     }
00442     else if((fv = dynamic_cast<const FrustumVolume  *>(v)) != NULL)
00443     {
00444         retCode = intersect(sphere, *fv);
00445     }
00446 
00447     return retCode;
00448 }

bool osg::intersect const CylinderVolume &  vol1,
const BoxVolume &  vol2
[inline]
 

Definition at line 64 of file OSGVolumeFunctions.inl.

References osg::intersect().

00065 {
00066     return intersect(box, cylinder);
00067 }

bool osg::intersect const CylinderVolume &  vol1,
const SphereVolume &  vol2
[inline]
 

Definition at line 70 of file OSGVolumeFunctions.inl.

References osg::intersect().

00071 {
00072     return intersect(sphere, cylinder);
00073 }

bool osg::intersect const CylinderVolume &  vol1,
const CylinderVolume &  vol2
 

Definition at line 454 of file OSGVolumeFunctions.cpp.

References p.

00456 {
00457     Vec3f   adir1, adir2, n, p;
00458     Pnt3f   apos1, apos2;
00459     double  d;
00460     bool    retCode = false;
00461 
00462     cylinder1.getAxis(apos1, adir1);
00463     cylinder2.getAxis(apos2, adir2);
00464 
00465     //get the shortest distance between the two axes of the cylinders
00466 
00467     n = adir1.cross(adir2);
00468     n.normalize();
00469 
00470     p = apos1 - apos2;
00471     d = fabs(n.dot(p.addToZero()));
00472 
00473     if(cylinder1.isEmpty() == true || cylinder2.isEmpty() == true)
00474     {
00475         retCode = false;
00476     }
00477     else if(cylinder1.isInfinite() == true || cylinder2.isInfinite() == true)
00478     {
00479         retCode = true;
00480     }
00481     else if(d <= cylinder1.getRadius() + cylinder2.getRadius())
00482     {
00483         // the distance is smaller than the sum of the 2 radiuses
00484         retCode = true;
00485     }
00486 
00487     return retCode;
00488 }

bool osg::intersect const CylinderVolume &  vol1,
const FrustumVolume &  vol2
 

Definition at line 492 of file OSGVolumeFunctions.cpp.

00493 {
00494     Pnt3f min, max;
00495     cylinder.getBounds(min, max);
00496 
00497     const Plane       *frust = frustum.getPlanes();
00498 
00499     // check each point of the box to the 6 planes
00500 
00501     for(Int32 i = 0; i < 6; i++)
00502     {
00503         if(frust[i].isOutHalfSpace(min, max))
00504             return false;
00505     }
00506 
00507     return true;
00508 }

bool osg::intersect const CylinderVolume &  vol1,
const Volume &  vol2
 

Definition at line 512 of file OSGVolumeFunctions.cpp.

References osg::intersect().

00513 {
00514     bool                 retCode = false;
00515 
00516     const DynamicVolume  *dv     = dynamic_cast<const DynamicVolume *>(&vol);
00517     const Volume         *v      = dv ? &(dv->getInstance()) : &vol;
00518     const BoxVolume      *bv;
00519     const SphereVolume   *sv;
00520     const CylinderVolume *cv;
00521     const FrustumVolume  *fv;
00522 
00523     if((bv = dynamic_cast<const BoxVolume *>(v)) != NULL)
00524     {
00525         retCode = intersect(cylinder, *bv);
00526     }
00527     else if((sv = dynamic_cast<const SphereVolume *>(v)) != NULL)
00528     {
00529         retCode = intersect(cylinder, *sv);
00530     }
00531     else if((cv = dynamic_cast<const CylinderVolume *>(v)) != NULL)
00532     {
00533         retCode = intersect(cylinder, *cv);
00534     }
00535     else if((fv = dynamic_cast<const FrustumVolume *>(v)) != NULL)
00536     {
00537         retCode = intersect(cylinder, *fv);
00538     }
00539 
00540     return retCode;
00541 }

bool osg::intersect const FrustumVolume &  vol1,
const BoxVolume &  vol2
[inline]
 

Definition at line 80 of file OSGVolumeFunctions.inl.

References osg::intersect().

00081 {
00082     return intersect(box, frustum);
00083 }

bool osg::intersect const FrustumVolume &  vol1,
const SphereVolume &  vol2
[inline]
 

Definition at line 86 of file OSGVolumeFunctions.inl.

References osg::intersect().

00087 {
00088     return intersect(sphere,frustum);
00089 }

bool osg::intersect const FrustumVolume &  vol1,
const CylinderVolume &  vol2
[inline]
 

Definition at line 92 of file OSGVolumeFunctions.inl.

References osg::intersect().

00093 {
00094     return intersect(cylinder,frustum);
00095 }

bool osg::intersect const FrustumVolume &  vol1,
const FrustumVolume &  vol2
 

Definition at line 547 of file OSGVolumeFunctions.cpp.

References FFATAL.

00549 {
00550     FFATAL(("intersect (frustum/frustum) is not impl.\n"));
00551     return false;
00552 }

bool osg::intersect const FrustumVolume &  vol1,
const Volume &  vol2
 

Definition at line 555 of file OSGVolumeFunctions.cpp.

References osg::intersect().

00556 {
00557     bool                  retCode = false;
00558 
00559     const DynamicVolume  *dv      = dynamic_cast<const DynamicVolume *>(&vol);
00560     const Volume         *v       = dv ? &(dv->getInstance()) : &vol;
00561     const BoxVolume      *bv;
00562     const SphereVolume   *sv;
00563     const CylinderVolume *cv;
00564     const FrustumVolume  *fv;
00565 
00566     if((bv = dynamic_cast<const BoxVolume *>(v)) != NULL)
00567     {
00568         retCode = intersect(frustum, *bv);
00569     }
00570     else if((sv = dynamic_cast<const SphereVolume *>(v)) != NULL)
00571     {
00572         retCode = intersect(frustum, *sv);
00573     }
00574     else if((cv = dynamic_cast<const CylinderVolume *>(v)) != NULL)
00575     {
00576         retCode = intersect(frustum, *cv);
00577     }
00578     else if((fv = dynamic_cast<const FrustumVolume *>(v)) != NULL)
00579     {
00580         retCode = intersect(frustum, *fv);
00581     }
00582 
00583     return retCode;
00584 }

bool osg::intersect const Volume &  srcVol,
const BoxVolume &  vol
[inline]
 

Definition at line 101 of file OSGVolumeFunctions.inl.

References osg::intersect().

00102 {
00103     return intersect(vol,srcVol);
00104 }

bool osg::intersect const Volume &  srcVol,
const SphereVolume &  vol
[inline]
 

Definition at line 107 of file OSGVolumeFunctions.inl.

References osg::intersect().

00108 {
00109     return intersect(vol,srcVol);
00110 }

bool osg::intersect const Volume &  srcVol,
const CylinderVolume &  vol
[inline]
 

Definition at line 113 of file OSGVolumeFunctions.inl.

References osg::intersect().

00114 {
00115     return intersect(vol,srcVol);
00116 }

bool osg::intersect const Volume &  srcVol,
const FrustumVolume &  vol
[inline]
 

Definition at line 119 of file OSGVolumeFunctions.inl.

References osg::intersect().

00120 {
00121     return intersect(vol,srcVol);
00122 }

void osg::extend BoxVolume &  srcVol,
const BoxVolume &  vol
 

Definition at line 603 of file OSGVolumeFunctions.cpp.

References osg::osgMax(), and osg::osgMin().

00604 {
00605     if( (!srcVol.isValid   () && !srcVol.isEmpty()) ||
00606           srcVol.isInfinite()                       ||
00607           srcVol.isStatic  ()                         )
00608     {
00609         return;
00610     }
00611 
00612     if(!vol.isValid())
00613         return;
00614 
00615     if(srcVol.isEmpty())
00616     {
00617         if(vol.isEmpty())
00618         {
00619             return;
00620         }
00621         else
00622         {
00623             srcVol = vol;
00624             return;
00625         }
00626     }
00627     else if(vol.isEmpty())
00628     {
00629         return;
00630     }
00631 
00632     srcVol.setBounds(osgMin(vol.getMin().x(), srcVol.getMin().x()),
00633                      osgMin(vol.getMin().y(), srcVol.getMin().y()),
00634                      osgMin(vol.getMin().z(), srcVol.getMin().z()),
00635                      osgMax(vol.getMax().x(), srcVol.getMax().x()),
00636                      osgMax(vol.getMax().y(), srcVol.getMax().y()),
00637                      osgMax(vol.getMax().z(), srcVol.getMax().z()));
00638 
00639     if(vol.isInfinite())
00640         srcVol.setInfinite(true);
00641 
00642     return;
00643 }

void osg::extend BoxVolume &  srcVol,
const SphereVolume &  vol
 

Definition at line 647 of file OSGVolumeFunctions.cpp.

References osg::osgMax(), and osg::osgMin().

00648 {
00649     Pnt3f   min, max;
00650 
00651     if((!srcVol.isValid   () && !srcVol.isEmpty()) ||
00652          srcVol.isInfinite()                       ||
00653          srcVol.isStatic  ()                         )
00654     {
00655         return;
00656     }
00657 
00658     if(!vol.isValid())
00659         return;
00660 
00661     if(srcVol.isEmpty())
00662     {
00663         if(vol.isEmpty())
00664         {
00665             return;
00666         }
00667         else
00668         {
00669             vol   .getBounds(min, max);
00670             srcVol.setBounds(min, max);
00671 
00672             return;
00673         }
00674     }
00675     else if(vol.isEmpty())
00676     {
00677         return;
00678     }
00679 
00680     vol.getBounds(min, max);
00681 
00682     srcVol.setBounds(osgMin(min.x(), srcVol.getMin().x()),
00683                      osgMin(min.y(), srcVol.getMin().y()),
00684                      osgMin(min.z(), srcVol.getMin().z()),
00685                      osgMax(max.x(), srcVol.getMax().x()),
00686                      osgMax(max.y(), srcVol.getMax().y()),
00687                      osgMax(max.z(), srcVol.getMax().z()));
00688 
00689     if(vol.isInfinite())
00690         srcVol.setInfinite(true);
00691 
00692     return;
00693 }

void osg::extend BoxVolume &  srcVol,
const CylinderVolume &  vol
 

Definition at line 697 of file OSGVolumeFunctions.cpp.

References osg::osgMax(), and osg::osgMin().

00698 {
00699     Pnt3f min, max;
00700 
00701     if((!srcVol.isValid   () && !srcVol.isEmpty()) ||
00702          srcVol.isInfinite()                       ||
00703          srcVol.isStatic  ()                         )
00704     {
00705         return;
00706     }
00707 
00708     if(!vol.isValid())
00709         return;
00710 
00711     if(srcVol.isEmpty())
00712     {
00713         if(vol.isEmpty())
00714         {
00715             return;
00716         }
00717         else
00718         {
00719             vol   .getBounds(min, max);
00720             srcVol.setBounds(min, max);
00721 
00722             return;
00723         }
00724     }
00725     else if(vol.isEmpty())
00726     {
00727         return;
00728     }
00729 
00730     vol.getBounds(min, max);
00731 
00732     srcVol.setBounds(osgMin(min.x(), srcVol.getMin().x()),
00733                      osgMin(min.y(), srcVol.getMin().y()),
00734                      osgMin(min.z(), srcVol.getMin().z()),
00735                      osgMax(max.x(), srcVol.getMax().x()),
00736                      osgMax(max.y(), srcVol.getMax().y()),
00737                      osgMax(max.z(), srcVol.getMax().z()));
00738 
00739     if(vol.isInfinite())
00740         srcVol.setInfinite(true);
00741 
00742     return;
00743 }

void osg::extend BoxVolume &  srcVol,
const FrustumVolume &  vol
 

Definition at line 747 of file OSGVolumeFunctions.cpp.

References FFATAL.

00749 {
00750     FFATAL(("extend (box/frustum) is not impl.\n"));
00751     return;
00752 }

void osg::extend BoxVolume &  srcVol,
const Volume &  vol
 

Definition at line 761 of file OSGVolumeFunctions.cpp.

References osg::extend().

00762 {
00763     const Volume        *v       = &vol;
00764     const BoxVolume     *box;
00765     const DynamicVolume *dynamic = dynamic_cast<const DynamicVolume *>(v);
00766 
00767     if(dynamic)
00768     {
00769         v = &(dynamic->getInstance());
00770     }
00771 
00772     if((box = dynamic_cast<const BoxVolume *>(v)))
00773     {
00774         OSG::extend(srcVol, *box);
00775     }
00776     else
00777     {
00778         BoxVolume   localBox;
00779         Pnt3f       min, max;
00780 
00781         v->getBounds(min, max);
00782 
00783         localBox.setBounds(min, max);
00784 
00785         OSG::extend(srcVol, localBox);
00786     }
00787 }

void osg::extend SphereVolume &  srcVol,
const BoxVolume &  vol
 

Definition at line 797 of file OSGVolumeFunctions.cpp.

References osg::osgMax(), and osg::osgMin().

00798 {
00799     Pnt3f     min, max, min1, max1, c;
00800     Real32    r;
00801     BoxVolume vol1;
00802 
00803     vol.getBounds(min, max);
00804 
00805     if((!srcVol.isValid   () && !srcVol.isEmpty()) ||
00806          srcVol.isInfinite()                       ||
00807          srcVol.isStatic  ()                         )
00808     {
00809         return;
00810     }
00811 
00812     if(!vol.isValid())
00813         return;
00814 
00815     if(srcVol.isEmpty())
00816     {
00817         if(vol.isEmpty())
00818         {
00819             return;
00820         }
00821         else
00822         {
00823             c = Pnt3f((min.x() + max.x()) * 0.5f, 
00824                       (min.y() + max.y()) * 0.5f,
00825                       (min.z() + max.z()) * 0.5f);
00826 
00827             r = ((max - min).length()) / 2;
00828 
00829             srcVol.setValue(c, r);
00830 
00831             return;
00832         }
00833     }
00834     else if(vol.isEmpty())
00835     {
00836         return;
00837     }
00838 
00839     srcVol.getBounds(min1, max1);
00840 
00841     vol1.setBounds(osgMin(min.x(), min1.x()), osgMin(min.y(), min1.y()),
00842                    osgMin(min.z(), min1.z()), osgMax(max.x(), max1.x()),
00843                    osgMax(max.y(), max1.y()), osgMax(max.z(), max1.z()));
00844 
00845     vol1.getBounds(min, max);
00846 
00847     c = Pnt3f((min.x() + max.x()) * 0.5f, 
00848               (min.y() + max.y()) * 0.5f,
00849               (min.z() + max.z()) * 0.5f);
00850 
00851     r = ((max - min).length()) / 2;
00852 
00853     srcVol.setValue(c, r);
00854 
00855     return;
00856 }

void osg::extend SphereVolume &  srcVol,
const SphereVolume &  vol
 

Definition at line 860 of file OSGVolumeFunctions.cpp.

References osg::osgMax(), and osg::osgMin().

00861 {
00862     Pnt3f   min, max, min1, max1, min2, max2, c;
00863     Real32  r;
00864 
00865     if((!srcVol.isValid   () && !srcVol.isEmpty()) ||
00866          srcVol.isInfinite()                       ||
00867          srcVol.isStatic  ()                         )
00868     {
00869         return;
00870     }
00871 
00872     if(!vol.isValid())
00873         return;
00874 
00875     if(srcVol.isEmpty())
00876     {
00877         if(vol.isEmpty())
00878         {
00879             return;
00880         }
00881         else
00882         {
00883             srcVol = vol;
00884 
00885             return;
00886         }
00887     }
00888     else if(vol.isEmpty())
00889     {
00890         return;
00891     }
00892 
00893     srcVol.getBounds(min,  max );
00894     vol   .getBounds(min1, max1);
00895 
00896     min2 = Pnt3f(osgMin(min.x(), min1.x()), 
00897                  osgMin(min.y(), min1.y()),
00898                  osgMin(min.z(), min1.z()));
00899 
00900     max2 = Pnt3f(osgMax(max.x(), max1.x()), 
00901                  osgMax(max.y(), max1.y()),
00902                  osgMax(max.z(), max1.z()));
00903 
00904     c = Pnt3f((min2.x() + max2.x()) * 0.5f, 
00905               (min2.y() + max2.y()) * 0.5f,
00906               (min2.z() + max2.z()) * 0.5f);
00907 
00908     r = ((max2 - min2).length()) * 0.5f;
00909 
00910     srcVol.setValue(c, r);
00911 
00912     return;
00913 }

void osg::extend SphereVolume &  srcVol,
const CylinderVolume &  vol
 

Definition at line 917 of file OSGVolumeFunctions.cpp.

References osg::osgMax(), and osg::osgMin().

00918 {
00919     Pnt3f   min, max, min1, max1, min2, max2, c;
00920     Real32  r;
00921 
00922     if((!srcVol.isValid   () && !srcVol.isEmpty()) ||
00923          srcVol.isInfinite()                       ||
00924          srcVol.isStatic  ()                         )
00925     {
00926         return;
00927     }
00928 
00929     if(!vol.isValid())
00930         return;
00931 
00932     if(srcVol.isEmpty())
00933     {
00934         if(vol.isEmpty())
00935         {
00936             return;
00937         }
00938         else
00939         {
00940             vol.getBounds(min, max);
00941             vol.getCenter(c);
00942 
00943             r = (min - c).length();
00944 
00945             srcVol.setValue(c, r);
00946 
00947             return;
00948         }
00949     }
00950     else if(vol.isEmpty())
00951     {
00952         return;
00953     }
00954 
00955     srcVol.getBounds(min,  max);
00956     vol   .getBounds(min1, max1);
00957 
00958     min2 = Pnt3f(osgMin(min.x(), min1.x()), 
00959                  osgMin(min.y(), min1.y()),
00960                  osgMin(min.z(), min1.z()));
00961 
00962     max2 = Pnt3f(osgMax(max.x(), max1.x()), 
00963                  osgMax(max.y(), max1.y()),
00964                  osgMax(max.z(), max1.z()));
00965 
00966     c = Pnt3f((min2.x() + max2.x()) * 0.5f, 
00967               (min2.y() + max2.y()) * 0.5f,
00968               (min2.z() + max2.z()) * 0.5f);
00969 
00970     r = ((max2 - min2).length()) * 0.5f;
00971 
00972     srcVol.setValue(c, r);
00973 
00974     return;
00975 }

void osg::extend SphereVolume &  srcVol,
const FrustumVolume &  vol
 

Definition at line 979 of file OSGVolumeFunctions.cpp.

References FFATAL.