Panda3D
|
00001 // Filename: odeGeom.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 ODEGEOM_H 00016 #define ODEGEOM_H 00017 00018 #include "pandabase.h" 00019 #include "typedObject.h" 00020 #include "luse.h" 00021 #include "bitMask.h" 00022 00023 #include "ode_includes.h" 00024 #include "odeSpace.h" 00025 #include "odeBody.h" 00026 00027 class OdeBoxGeom; 00028 class OdeCappedCylinderGeom; 00029 // class OdeConvexGeom; 00030 class OdeCylinderGeom; 00031 // class OdeHeightfieldGeom; 00032 class OdePlaneGeom; 00033 class OdeRayGeom; 00034 class OdeSphereGeom; 00035 class OdeTriMeshGeom; 00036 class OdeSimpleSpace; 00037 class OdeHashSpace; 00038 class OdeQuadTreeSpace; 00039 00040 class OdeUtil; 00041 class OdeCollisionEntry; 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Class : OdeGeom 00045 // Description : 00046 //////////////////////////////////////////////////////////////////// 00047 class EXPCL_PANDAODE OdeGeom : public TypedObject { 00048 friend class OdeContactGeom; 00049 friend class OdeSpace; 00050 friend class OdeUtil; 00051 friend class OdeCollisionEntry; 00052 00053 protected: 00054 OdeGeom(dGeomID id); 00055 00056 PUBLISHED: 00057 enum GeomClass { GC_sphere = 0, 00058 GC_box, 00059 GC_capped_cylinder, 00060 GC_cylinder, 00061 GC_plane, 00062 GC_ray, 00063 // GC_convex, 00064 // GC_geom_transform, 00065 GC_tri_mesh = 8, 00066 // GC_heightfield, 00067 00068 GC_simple_space = 10, 00069 GC_hash_space, 00070 GC_quad_tree_space, 00071 }; 00072 00073 virtual ~OdeGeom(); 00074 void destroy(); 00075 INLINE bool is_empty() const; 00076 INLINE dGeomID get_id() const; 00077 00078 //INLINE void set_data(void* data); 00079 INLINE void set_body(OdeBody &body); 00080 INLINE bool has_body() const; 00081 INLINE OdeBody get_body() const; 00082 INLINE void set_position(dReal x, dReal y, dReal z); 00083 INLINE void set_position(const LVecBase3f &pos); 00084 INLINE void set_rotation(const LMatrix3f &r); 00085 INLINE void set_quaternion(const LQuaternionf &q); 00086 INLINE LPoint3f get_position() const; 00087 INLINE LMatrix3f get_rotation() const; 00088 INLINE LQuaternionf get_quaternion() const; 00089 INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const; 00090 INLINE int is_space(); 00091 INLINE int get_class() const; 00092 INLINE void set_category_bits(const BitMask32 &bits); 00093 INLINE void set_collide_bits(const BitMask32 &bits); 00094 INLINE BitMask32 get_category_bits(); 00095 INLINE BitMask32 get_collide_bits(); 00096 INLINE void enable(); 00097 INLINE void disable(); 00098 INLINE int is_enabled(); 00099 INLINE void set_offset_position(dReal x, dReal y, dReal z); 00100 INLINE void set_offset_position(const LVecBase3f &pos); 00101 INLINE void set_offset_rotation(const LMatrix3f &r); 00102 INLINE void set_offset_quaternion(const LQuaternionf &q); 00103 INLINE void set_offset_world_position(dReal x, dReal y, dReal z); 00104 INLINE void set_offset_world_position(const LVecBase3f &pos); 00105 INLINE void set_offset_world_rotation(const LMatrix3f &r); 00106 INLINE void set_offset_world_quaternion(const LQuaternionf &q); 00107 INLINE void clear_offset(); 00108 INLINE int is_offset(); 00109 INLINE LPoint3f get_offset_position() const; 00110 INLINE LMatrix3f get_offset_rotation() const; 00111 INLINE LQuaternionf get_offset_quaternion() const; 00112 00113 //int get_surface_type() ; 00114 //int get_collide_id() ; 00115 //int set_collide_id( int collide_id); 00116 //void set_surface_type( int surface_type); 00117 00118 //int test_collide_id( int collide_id); 00119 00120 00121 OdeSpace get_space() const; 00122 00123 virtual void write(ostream &out = cout, unsigned int indent=0) const; 00124 operator bool () const; 00125 INLINE int compare_to(const OdeGeom &other) const; 00126 00127 OdeBoxGeom convert_to_box() const; 00128 OdeCappedCylinderGeom convert_to_capped_cylinder() const; 00129 // OdeConvexGeom convert_to_convex() const; 00130 OdeCylinderGeom convert_to_cylinder() const; 00131 // OdeHeightfieldGeom convert_to_heightfield() const; 00132 OdePlaneGeom convert_to_plane() const; 00133 OdeRayGeom convert_to_ray() const; 00134 OdeSphereGeom convert_to_sphere() const; 00135 OdeTriMeshGeom convert_to_tri_mesh() const; 00136 OdeSimpleSpace convert_to_simple_space() const; 00137 OdeHashSpace convert_to_hash_space() const; 00138 OdeQuadTreeSpace convert_to_quad_tree_space() const; 00139 00140 00141 00142 public: 00143 INLINE static int get_geom_class() { return -1; }; 00144 00145 protected: 00146 dGeomID _id; 00147 00148 00149 public: 00150 static TypeHandle get_class_type() { 00151 return _type_handle; 00152 } 00153 static void init_type() { 00154 TypedObject::init_type(); 00155 register_type(_type_handle, "OdeGeom", 00156 TypedObject::get_class_type()); 00157 } 00158 virtual TypeHandle get_type() const { 00159 return get_class_type(); 00160 } 00161 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00162 00163 private: 00164 static TypeHandle _type_handle; 00165 }; 00166 00167 #include "odeGeom.I" 00168 00169 #endif