Panda3D
 All Classes Functions Variables Enumerations
odeSpace.h
00001 // Filename: odeSpace.h
00002 // Created by:  joswilso (27Dec06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef ODESPACE_H
00016 #define ODESPACE_H
00017 
00018 #include "pandabase.h"
00019 #include "typedObject.h"
00020 #include "luse.h"
00021 #include "bitMask.h"
00022 
00023 //included for collision tests
00024 #include "odeWorld.h"
00025 #include "odeJointGroup.h"
00026 
00027 #include "ode_includes.h"
00028 
00029 #ifdef HAVE_PYTHON
00030   #include "py_panda.h"
00031   #include "Python.h"
00032 #endif
00033 
00034 class OdeGeom;
00035 class OdeTriMeshGeom;
00036 class OdeSimpleSpace;
00037 class OdeHashSpace;
00038 class OdeQuadTreeSpace;
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //       Class : OdeSpace
00042 // Description : 
00043 ////////////////////////////////////////////////////////////////////
00044 class EXPCL_PANDAODE OdeSpace : public TypedObject {
00045   friend class OdeGeom;
00046   static const int MAX_CONTACTS;
00047 
00048 protected:
00049   OdeSpace(dSpaceID id);
00050   
00051 PUBLISHED:
00052   virtual ~OdeSpace();
00053   void destroy();
00054   INLINE bool is_empty() const;
00055 
00056   INLINE void set_cleanup(int mode);
00057   INLINE int get_cleanup() const;
00058   int query(const OdeGeom& geom) const;
00059   int query(const OdeSpace& space) const;
00060   INLINE int get_num_geoms() const;
00061   INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const;
00062   INLINE int is_space();
00063   INLINE int get_class() const;
00064   INLINE void set_category_bits(const BitMask32 &bits);
00065   INLINE void set_collide_bits(const BitMask32 &bits);
00066   INLINE BitMask32 get_category_bits();
00067   INLINE BitMask32 get_collide_bits();
00068   INLINE void enable();
00069   INLINE void disable();
00070   INLINE int is_enabled();
00071   void set_auto_collide_world(OdeWorld&);
00072   void set_auto_collide_joint_group(OdeJointGroup&);
00073 
00074   void add(OdeGeom& geom);
00075   void add(OdeSpace& space);
00076   void remove(OdeGeom& geom);
00077   void remove(OdeSpace& space);
00078   void clean();
00079   OdeGeom get_geom(int i); // Not INLINE because of forward declaration
00080   //static int get_surface_type(OdeSpace * self, dGeomID o1);
00081   
00082   INLINE OdeSpace get_space() const;
00083 
00084   virtual void write(ostream &out = cout, unsigned int indent=0) const;
00085   operator bool () const;
00086 
00087   OdeSimpleSpace convert_to_simple_space() const;
00088   OdeHashSpace convert_to_hash_space() const;
00089   OdeQuadTreeSpace convert_to_quad_tree_space() const;
00090   
00091   int auto_collide();
00092 #ifdef HAVE_PYTHON
00093   int collide(PyObject* arg, PyObject* near_callback);
00094 #endif
00095   static double get_contact_data(int data_index);
00096   int get_contact_id(int data_index, int first = 0);
00097   int set_collide_id(int collide_id, dGeomID id);
00098   int set_collide_id(OdeGeom& geom, int collide_id);
00099   void set_surface_type( int surface_type, dGeomID id);
00100   void set_surface_type(OdeGeom& geom, int surface_type);
00101   int get_surface_type(dGeomID o1);
00102   int get_surface_type(OdeGeom& geom);
00103   int get_collide_id(dGeomID o1);
00104   int get_collide_id(OdeGeom& geom);
00105 
00106   INLINE void set_collision_event(const string &event_name);
00107   INLINE string get_collision_event();
00108 
00109 public:
00110   static void auto_callback(void*, dGeomID, dGeomID);
00111 #ifdef HAVE_PYTHON
00112   static void near_callback(void*, dGeomID, dGeomID);
00113 #endif
00114   
00115   INLINE dSpaceID get_id() const;
00116   static OdeWorld* _collide_world;
00117   static OdeSpace* _collide_space;
00118   static dJointGroupID _collide_joint_group;
00119 #ifdef HAVE_PYTHON
00120   static PyObject* _python_callback;
00121 #endif
00122   static int contactCount;
00123   string _collision_event;
00124 
00125   static double contact_data[192]; // 64 times three
00126   static int contact_ids[128]; // 64 times two
00127 
00128 protected:
00129   dSpaceID _id;
00130   int _g; // REMOVE ME
00131   OdeWorld* my_world;
00132 
00133 public:
00134   static TypeHandle get_class_type() {
00135     return _type_handle;
00136   }
00137   static void init_type() {
00138     TypedObject::init_type();
00139     register_type(_type_handle, "OdeSpace",
00140                   TypedObject::get_class_type());
00141   }
00142   virtual TypeHandle get_type() const {
00143     return get_class_type();
00144   }
00145   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00146 
00147 private:
00148   static TypeHandle _type_handle;
00149 
00150   typedef pmap<dGeomID, int> GeomSurfaceMap;
00151   GeomSurfaceMap _geom_surface_map;
00152 
00153   typedef pmap<dGeomID, int> GeomCollideIdMap;
00154   GeomCollideIdMap _geom_collide_id_map;
00155 
00156 };
00157 
00158 #include "odeSpace.I"
00159 
00160 #endif
00161 
 All Classes Functions Variables Enumerations