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