Panda3D
odeGeom.h
1 // Filename: odeGeom.h
2 // Created by: joswilso (27Dec06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ODEGEOM_H
16 #define ODEGEOM_H
17 
18 #include "pandabase.h"
19 #include "typedObject.h"
20 #include "luse.h"
21 #include "bitMask.h"
22 
23 #include "ode_includes.h"
24 #include "odeSpace.h"
25 #include "odeBody.h"
26 
27 class OdeBoxGeom;
29 // class OdeConvexGeom;
30 class OdeCylinderGeom;
31 // class OdeHeightfieldGeom;
32 class OdePlaneGeom;
33 class OdeRayGeom;
34 class OdeSphereGeom;
35 class OdeTriMeshGeom;
36 class OdeSimpleSpace;
37 class OdeHashSpace;
38 class OdeQuadTreeSpace;
39 
40 class OdeUtil;
41 class OdeCollisionEntry;
42 
43 ////////////////////////////////////////////////////////////////////
44 // Class : OdeGeom
45 // Description :
46 ////////////////////////////////////////////////////////////////////
47 class EXPCL_PANDAODE OdeGeom : public TypedObject {
48  friend class OdeContactGeom;
49  friend class OdeSpace;
50  friend class OdeUtil;
51  friend class OdeCollisionEntry;
52 
53 public:
54  OdeGeom(dGeomID id);
55 
56 PUBLISHED:
57  enum GeomClass { GC_sphere = 0,
58  GC_box,
59  GC_capped_cylinder,
60  GC_cylinder,
61  GC_plane,
62  GC_ray,
63  // GC_convex,
64  // GC_geom_transform,
65  GC_tri_mesh = 8,
66  // GC_heightfield,
67 
68  GC_simple_space = 10,
69  GC_hash_space,
70  GC_quad_tree_space,
71  };
72 
73  virtual ~OdeGeom();
74  void destroy();
75  INLINE bool is_empty() const;
76  INLINE dGeomID get_id() const;
77 
78  //INLINE void set_data(void* data);
79  INLINE void set_body(OdeBody &body);
80  INLINE bool has_body() const;
81  INLINE OdeBody get_body() const;
82  INLINE void set_position(dReal x, dReal y, dReal z);
83  INLINE void set_position(const LVecBase3f &pos);
84  INLINE void set_rotation(const LMatrix3f &r);
85  INLINE void set_quaternion(const LQuaternionf &q);
86  INLINE LPoint3f get_position() const;
87  INLINE LMatrix3f get_rotation() const;
88  INLINE LQuaternionf get_quaternion() const;
89  INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const;
90  EXTENSION(INLINE PyObject *get_AA_bounds() const);
91  INLINE int is_space();
92  INLINE int get_class() const;
93  INLINE void set_category_bits(const BitMask32 &bits);
94  INLINE void set_collide_bits(const BitMask32 &bits);
95  INLINE BitMask32 get_category_bits();
96  INLINE BitMask32 get_collide_bits();
97  INLINE void enable();
98  INLINE void disable();
99  INLINE int is_enabled();
100  INLINE void set_offset_position(dReal x, dReal y, dReal z);
101  INLINE void set_offset_position(const LVecBase3f &pos);
102  INLINE void set_offset_rotation(const LMatrix3f &r);
103  INLINE void set_offset_quaternion(const LQuaternionf &q);
104  INLINE void set_offset_world_position(dReal x, dReal y, dReal z);
105  INLINE void set_offset_world_position(const LVecBase3f &pos);
106  INLINE void set_offset_world_rotation(const LMatrix3f &r);
107  INLINE void set_offset_world_quaternion(const LQuaternionf &q);
108  INLINE void clear_offset();
109  INLINE int is_offset();
110  INLINE LPoint3f get_offset_position() const;
111  INLINE LMatrix3f get_offset_rotation() const;
112  INLINE LQuaternionf get_offset_quaternion() const;
113 
114  //int get_surface_type() ;
115  //int get_collide_id() ;
116  //int set_collide_id( int collide_id);
117  //void set_surface_type( int surface_type);
118 
119  //int test_collide_id( int collide_id);
120 
121  OdeSpace get_space() const;
122  EXTENSION(INLINE PyObject *get_converted_space() const);
123 
124  virtual void write(ostream &out = cout, unsigned int indent=0) const;
125  operator bool () const;
126  INLINE int compare_to(const OdeGeom &other) const;
127 
128  EXTENSION(PyObject *convert() const);
129  OdeBoxGeom convert_to_box() const;
130  OdeCappedCylinderGeom convert_to_capped_cylinder() const;
131  // OdeConvexGeom convert_to_convex() const;
132  OdeCylinderGeom convert_to_cylinder() const;
133  // OdeHeightfieldGeom convert_to_heightfield() const;
134  OdePlaneGeom convert_to_plane() const;
135  OdeRayGeom convert_to_ray() const;
136  OdeSphereGeom convert_to_sphere() const;
137  OdeTriMeshGeom convert_to_tri_mesh() const;
138  OdeSimpleSpace convert_to_simple_space() const;
139  OdeHashSpace convert_to_hash_space() const;
140  OdeQuadTreeSpace convert_to_quad_tree_space() const;
141 
142 public:
143  INLINE static int get_geom_class() { return -1; };
144 
145 protected:
146  dGeomID _id;
147 
148 
149 public:
150  static TypeHandle get_class_type() {
151  return _type_handle;
152  }
153  static void init_type() {
155  register_type(_type_handle, "OdeGeom",
156  TypedObject::get_class_type());
157  }
158  virtual TypeHandle get_type() const {
159  return get_class_type();
160  }
161  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
162 
163 private:
164  static TypeHandle _type_handle;
165 };
166 
167 #include "odeGeom.I"
168 
169 #endif
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A class used to hold information about a collision that has occurred.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:79
This is the base quaternion class.
Definition: lquaternion.h:96
bool is_empty() const
Returns true if the entry holds no contacts.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110