OSGAdapter.h

Go to the documentation of this file.
00001 /* $Id:$ */
00002 
00003 #ifndef __OSG_ADAPTER_H
00004 #define __OSG_ADAPTER_H
00005 
00006 #include <esg/Group.h>
00007 #include <esg/spacesorting/BVH.h>
00008 #include <esg/explorer/RayIntExplorer.h>
00009 #include <esg/explorer/ExtentExplorer.h>
00010 #include <esg/explorer/NExtentsExplorer.h>
00011 #include <esg/OSGPolygon.h>
00012 #include <esg/Export>
00013 
00014 #include <osg/Array>
00015 #include <osg/PrimitiveSet>
00016 #include <osg/Geometry>
00017 
00018 namespace esg {
00019 
00030 class ESG_OSG_EXPORT OSGAdapter {
00031 protected:
00032         Group* _pGroupNode;
00033         
00034         void _put_polygon(osg::Geometry::PrimitiveSetList *,
00035                           osg::Vec3Array *,
00036                           osg::Vec3Array *,
00037                           osg::Geometry::AttributeBinding);
00038 
00039 public:
00043         enum bvType { BV_FDH14, BV_AABB, BV_SPHERE };
00044     
00045 public:
00046         OSGAdapter (osg::Geometry*        /* OSG geometry            */,
00047                     unsigned              /* BVH leaf limit          */,
00048                     unsigned              /* BVH depth limit         */,
00049                     BVList::SplitStrategy /* variation or extent     */,
00050                     bvType                /* type of bounding volume */);
00051         
00052     OSGAdapter (AutoPtr<Geometry>*    /* ESG geometry            */,
00053                 unsigned              /* BVH leaf limit          */,
00054                 unsigned              /* BVH depth limit         */,
00055                 BVList::SplitStrategy /* variation or extent     */,
00056                 bvType                /* type of bounding volume */);
00057 
00058     // Geometry becames the private object of the adapter and is destroyed
00059     // when adapter is destroyed!
00060     OSGAdapter (Geometry*             /* ESG geometry            */,
00061                 unsigned              /* BVH leaf limit          */,
00062                 unsigned              /* BVH depth limit         */,
00063                 BVList::SplitStrategy /* variation or extent     */,
00064                 bvType                /* type of bounding volume */);
00065 
00066     virtual ~OSGAdapter () { if (_pGroupNode) delete _pGroupNode; }
00067 
00068     /*
00069      * Operations available for OSG
00070      */
00071 
00072     // Returns verices of OSG object
00073     double* getVertices (Matrix4*  /* tr. matrix             */,
00074                          unsigned* /* size of returned array */);
00075 
00076 
00077     // See BVH for more details
00078     double distance (Matrix4*    /* my tr. matrix                          */,
00079                      OSGAdapter& /* tested object                          */,
00080                      Matrix4*    /* its tr. matrix                         */,
00081                      BVH::Node** /* my best leaf from prev. pass           */,
00082                      BVH::Node** /* partner's  -"-                         */,
00083                      Vector3* pDir=NULL   /* approx. direction of distance */,
00084                      unsigned d1=UINT_MAX /* my maximal depth of recursion */,
00085                      unsigned d2=UINT_MAX /* partner's max. depth          */);
00086 
00087     // See BVH for more details
00088     bool separation (Matrix4*    /* my tr. matrix                          */,
00089                      OSGAdapter& /* tested object                          */,
00090                      Matrix4*    /* its tr. matrix                         */,
00091                      Vector3* pDir=NULL   /* approx. direction of distance */,
00092                      unsigned d1=UINT_MAX /* my maximal depth of recursion */,
00093                      unsigned d2=UINT_MAX /* partner's max. depth          */);
00094 
00095     // See BVH for more details
00096     Geometry** collision (Matrix4*            /* my tr.. matrix */,
00097                           float, float, float /* 3D point */,
00098                           float               /* rasius */,
00099                           int*                /* # of returned obj.*/);
00100 
00101     // See ReyIntExplorer for more details
00102     PointEnv* rayIntersection (const Matrix4* pTrMat /* my tr. matrix */,
00103                                const Vector3& origin,
00104                                const Vector3& direction,
00105                                int            mask = (ENV_WANT_INTERSECTION|ENV_WANT_NORMAL|ENV_WANT_TRANSFORMATION),
00106                                float          maxDist = FLT_MAX);
00107 
00108     // See ExtentExplorer for more details
00109     Interval extent (const Matrix4* pTrMat /* my tr. matrix */,
00110                      const Vector3& direction);
00111 
00112     // See NExtentsExplorer for more details
00113     Interval* nExtents (const Matrix4* pTrMat /* my tr. matrix */,
00114                         const Vector3* directions,
00115                         unsigned       nDirs);
00116 };
00117     
00118 }; // namespace
00119 
00120 #endif // __OSG_ADAPTER_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6