Panda3D
Loading...
Searching...
No Matches
odeBody.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 odeBody.h
10 * @author joswilso
11 * @date 2006-12-27
12 */
13
14#ifndef ODEBODY_H
15#define ODEBODY_H
16
17#include "pandabase.h"
18#include "typedObject.h"
19#include "luse.h"
20
21#include "ode_includes.h"
22#include "odeWorld.h"
23#include "odeMass.h"
24
25class OdeJoint;
26class OdeGeom;
28
29/**
30 *
31 */
32class EXPCL_PANDAODE OdeBody : public TypedObject {
33 friend class OdeJoint;
34 friend class OdeGeom;
35 friend class OdeCollisionEntry;
36
37public:
38 OdeBody(dBodyID id);
39
40PUBLISHED:
41 OdeBody(OdeWorld &world);
42 virtual ~OdeBody();
43 void destroy();
44 INLINE bool is_empty() const;
45 INLINE dBodyID get_id() const;
46
47 INLINE void set_auto_disable_linear_threshold(dReal linear_threshold);
48 INLINE void set_auto_disable_angular_threshold(dReal angular_threshold);
49 INLINE void set_auto_disable_steps(int steps);
50 INLINE void set_auto_disable_time(dReal time);
51 INLINE void set_auto_disable_flag(int do_auto_disable);
52 INLINE void set_auto_disable_defaults();
53 INLINE void set_data(void *data);
54 EXTENSION(void set_data(PyObject *data));
55
56 INLINE void set_position(dReal x, dReal y, dReal z);
57 INLINE void set_position(const LVecBase3f &pos);
58 INLINE void set_rotation(const LMatrix3f &r);
59 INLINE void set_quaternion(const LQuaternionf &q);
60 INLINE void set_linear_vel(dReal x, dReal y, dReal z);
61 INLINE void set_linear_vel(const LVecBase3f &vel);
62 INLINE void set_angular_vel(dReal x, dReal y, dReal z);
63 INLINE void set_angular_vel(const LVecBase3f &vel);
64 INLINE void set_mass(OdeMass &mass);
65
66
67 INLINE dReal get_auto_disable_linear_threshold() const;
68 INLINE dReal get_auto_disable_angular_threshold() const;
69 INLINE int get_auto_disable_steps() const;
70 INLINE dReal get_auto_disable_time() const;
71 INLINE int get_auto_disable_flag() const;
72#ifndef CPPPARSER
73 INLINE void *get_data() const;
74#endif
75 EXTENSION(PyObject *get_data() const);
76
77 INLINE LVecBase3f get_position() const;
78 INLINE LMatrix3f get_rotation() const;
79 INLINE LVecBase4f get_quaternion() const;
80 INLINE LVecBase3f get_linear_vel() const;
81 INLINE LVecBase3f get_angular_vel() const;
82 INLINE OdeMass get_mass() const;
83
84 INLINE void add_force(dReal fx, dReal fy, dReal fz);
85 INLINE void add_force(const LVecBase3f &f);
86 INLINE void add_torque(dReal fx, dReal fy, dReal fz);
87 INLINE void add_torque(const LVecBase3f &f);
88 INLINE void add_rel_force(dReal fx, dReal fy, dReal fz);
89 INLINE void add_rel_force(const LVecBase3f &f);
90 INLINE void add_rel_torque(dReal fx, dReal fy, dReal fz);
91 INLINE void add_rel_torque(const LVecBase3f &f);
92 INLINE void add_force_at_pos(dReal fx, dReal fy, dReal fz,
93 dReal px, dReal py, dReal pz);
94 INLINE void add_force_at_pos(const LVecBase3f &f,
95 const LVecBase3f &pos);
96 INLINE void add_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
97 dReal px, dReal py, dReal pz);
98 INLINE void add_force_at_rel_pos(const LVecBase3f &f,
99 const LVecBase3f &pos);
100 INLINE void add_rel_force_at_pos(dReal fx, dReal fy, dReal fz,
101 dReal px, dReal py, dReal pz);
102 INLINE void add_rel_force_at_pos(const LVecBase3f &f,
103 const LVecBase3f &pos);
104 INLINE void add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz,
105 dReal px, dReal py, dReal pz);
106 INLINE void add_rel_force_at_rel_pos(const LVecBase3f &f,
107 const LVecBase3f &pos);
108 INLINE void set_force(dReal x, dReal y, dReal z);
109 INLINE void set_force(const LVecBase3f &f);
110 INLINE void set_torque(dReal x, dReal y, dReal z);
111 INLINE void set_torque(const LVecBase3f &f);
112
113 INLINE LPoint3f get_rel_point_pos(dReal px, dReal py, dReal pz) const;
114 INLINE LPoint3f get_rel_point_pos(const LVecBase3f &pos) const;
115 INLINE LPoint3f get_rel_point_vel(dReal px, dReal py, dReal pz) const;
116 INLINE LPoint3f get_rel_point_vel(const LVecBase3f &pos) const;
117 INLINE LPoint3f get_point_vel(dReal px, dReal py, dReal pz) const;
118 INLINE LPoint3f get_point_vel(const LVecBase3f &pos) const;
119 INLINE LPoint3f get_pos_rel_point(dReal px, dReal py, dReal pz) const;
120 INLINE LPoint3f get_pos_rel_point(const LVecBase3f &pos) const;
121 INLINE LVecBase3f vector_to_world(dReal px, dReal py, dReal pz) const;
122 INLINE LVecBase3f vector_to_world(const LVecBase3f &pos) const;
123 INLINE LVecBase3f vector_from_world(dReal px, dReal py, dReal pz) const;
124 INLINE LVecBase3f vector_from_world(const LVecBase3f &pos) const;
125
126 INLINE void set_finite_rotation_mode(int mode);
127 INLINE void set_finite_rotation_axis(dReal x, dReal y, dReal z);
128 INLINE void set_finite_rotation_axis(const LVecBase3f &axis);
129 INLINE int get_finite_rotation_mode() const;
130 INLINE LVecBase3f get_finite_rotation_axis() const;
131
132 INLINE int get_num_joints() const;
133 OdeJoint get_joint(int index) const;
134 MAKE_SEQ(get_joints, get_num_joints, get_joint);
135 EXTENSION(INLINE PyObject *get_converted_joint(int i) const);
136 MAKE_SEQ_PROPERTY(joints, get_num_joints, get_converted_joint);
137
138 INLINE void enable();
139 INLINE void disable();
140 INLINE int is_enabled() const;
141 INLINE void set_gravity_mode(int mode);
142 INLINE int get_gravity_mode() const;
143
144 virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const;
145 operator bool () const;
146 INLINE int compare_to(const OdeBody &other) const;
147
148private:
149 dBodyID _id;
150
151public:
152 typedef void (*DestroyCallback)(OdeBody &body);
153 DestroyCallback _destroy_callback = nullptr;
154
155public:
156 static TypeHandle get_class_type() {
157 return _type_handle;
158 }
159 static void init_type() {
161 register_type(_type_handle, "OdeBody",
162 TypedObject::get_class_type());
163 }
164 virtual TypeHandle get_type() const {
165 return get_class_type();
166 }
167 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
168
169private:
170 static TypeHandle _type_handle;
171};
172
173#include "odeBody.I"
174
175#endif
A class used to hold information about a collision that has occurred.
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.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
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(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.