00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027
00029 #ifndef __HLSHAPE_H__
00030 #define __HLSHAPE_H__
00031
00032 #include "HLObject.h"
00033 #include "H3DTypes.h"
00034 #include "Bound.h"
00035 #include <map>
00036 #include <map>
00037 #include <vector>
00038
00039 namespace H3D {
00040
00041 class HLHapticsDevice;
00042 class X3DGeometryNode;
00047 class H3DAPI_API HLShape: public HLObject {
00048 protected:
00049 typedef std::map< std::pair< X3DGeometryNode *, HLHapticsDevice * >,
00050 unsigned int > ShapeIdMap;
00051
00060 static ShapeIdMap shape_id_db ;
00061
00062 #ifdef HAVE_OPENHAPTICS
00063 typedef std::multimap< HLuint, HLShape * > HLShapeMap;
00065 static HLShapeMap hl_shape_map;
00066
00068 std::vector< HLuint > shape_ids;
00069 #endif
00070 public:
00073 virtual void hlRender( HLHapticsDevice *hd ) = 0;
00074 #ifdef HAVE_OPENHAPTICS
00075
00076 virtual ~HLShape();
00077
00079 HLuint getShapeId( HLHapticsDevice *hd );
00080
00082 inline static HLShape *getHLShape( HLuint id ) {
00083 HLShapeMap::iterator i = hl_shape_map.find( id );
00084 if( i == hl_shape_map.end() ) return NULL;
00085 else return (*i).second;
00086 }
00087 #endif
00090 inline static void resetShapeIdDB() {
00091 shape_id_db.clear();
00092 }
00093
00099 inline static unsigned int getFreeShapeIdIndex( X3DGeometryNode *geom,
00100 HLHapticsDevice *hd ) {
00101 ShapeIdMap::iterator i = shape_id_db.find( std::make_pair( geom, hd ) );
00102 if( i != shape_id_db.end() ) {
00103 (*i).second++;
00104 return (*i).second;
00105 } else {
00106 shape_id_db.insert( i, std::make_pair( std::make_pair( geom,
00107 hd ), 0 ) );
00108 return 0;
00109 }
00110 }
00111
00117 virtual bool closeEnoughToBound( const Vec3f &p,
00118 const Vec3f &previous_p,
00119 const Matrix4f &m,
00120 X3DGeometryNode *geom );
00121
00122 };
00123 }
00124
00125 #endif