00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __BULLET_BODY_NODE_H__
00016 #define __BULLET_BODY_NODE_H__
00017
00018 #include "pandabase.h"
00019
00020 #include "bullet_includes.h"
00021 #include "bullet_utils.h"
00022
00023 #include "pandaNode.h"
00024 #include "collideMask.h"
00025 #include "collisionNode.h"
00026 #include "transformState.h"
00027
00028 class BulletShape;
00029
00030
00031
00032
00033
00034 class EXPCL_PANDABULLET BulletBodyNode : public PandaNode {
00035
00036 PUBLISHED:
00037 BulletBodyNode(const char *name);
00038 INLINE ~BulletBodyNode();
00039
00040
00041 void add_shape(BulletShape *shape, CPT(TransformState) xform=NULL);
00042 void remove_shape(BulletShape *shape);
00043
00044 INLINE int get_num_shapes() const;
00045 INLINE BulletShape *get_shape(int idx) const;
00046 MAKE_SEQ(get_shapes, get_num_shapes, get_shape);
00047
00048 LPoint3 get_shape_pos(int idx) const;
00049 LMatrix4 get_shape_mat(int idx) const;
00050
00051 void add_shapes_from_collision_solids(CollisionNode *cnode);
00052
00053
00054 INLINE bool is_static() const;
00055 INLINE bool is_kinematic() const;
00056
00057 INLINE void set_static(bool value);
00058 INLINE void set_kinematic(bool value);
00059
00060
00061 INLINE void set_into_collide_mask(CollideMask mask);
00062
00063 INLINE void notify_collisions(bool value);
00064 INLINE bool notifies_collisions() const;
00065
00066 INLINE void set_collision_response(bool value);
00067 INLINE bool get_collision_response() const;
00068
00069 bool check_collision_with(PandaNode *node);
00070
00071 bool has_contact_response() const;
00072
00073 PN_stdfloat get_contact_processing_threshold() const;
00074 void set_contact_processing_threshold(PN_stdfloat threshold);
00075
00076
00077 bool is_active() const;
00078 void set_active(bool active, bool force=false);
00079
00080 void set_deactivation_time(PN_stdfloat dt);
00081 PN_stdfloat get_deactivation_time() const;
00082
00083 void set_deactivation_enabled(const bool enabled, const bool force=false);
00084 bool is_deactivation_enabled() const;
00085
00086
00087 INLINE void set_debug_enabled(const bool enabled);
00088 INLINE bool is_debug_enabled() const;
00089
00090
00091 INLINE PN_stdfloat get_restitution() const;
00092 INLINE void set_restitution(PN_stdfloat restitution);
00093
00094 INLINE PN_stdfloat get_friction() const;
00095 INLINE void set_friction(PN_stdfloat friction);
00096
00097 INLINE bool has_anisotropic_friction() const;
00098 void set_anisotropic_friction(const LVecBase3 &friction);
00099 LVecBase3 get_anisotropic_friction() const;
00100
00101
00102 PN_stdfloat get_ccd_swept_sphere_radius() const;
00103 PN_stdfloat get_ccd_motion_threshold() const;
00104 void set_ccd_swept_sphere_radius(PN_stdfloat radius);
00105 void set_ccd_motion_threshold(PN_stdfloat threshold);
00106
00107 public:
00108 virtual btCollisionObject *get_object() const = 0;
00109
00110 virtual CollideMask get_legal_collide_mask() const;
00111
00112 virtual bool safe_to_flatten() const;
00113 virtual bool safe_to_transform() const;
00114 virtual bool safe_to_modify_transform() const;
00115 virtual bool safe_to_combine() const;
00116 virtual bool safe_to_combine_children() const;
00117 virtual bool safe_to_flatten_below() const;
00118
00119 virtual void output(ostream &out) const;
00120
00121 protected:
00122 INLINE void set_collision_flag(int flag, bool value);
00123 INLINE bool get_collision_flag(int flag) const;
00124
00125 btCollisionShape *_shape;
00126
00127 typedef PTA(PT(BulletShape)) BulletShapes;
00128 BulletShapes _shapes;
00129
00130 private:
00131 virtual void shape_changed();
00132
00133 static bool is_identity(btTransform &trans);
00134
00135
00136 public:
00137 static TypeHandle get_class_type() {
00138 return _type_handle;
00139 }
00140 static void init_type() {
00141 PandaNode::init_type();
00142 register_type(_type_handle, "BulletBodyNode",
00143 PandaNode::get_class_type());
00144 }
00145 virtual TypeHandle get_type() const {
00146 return get_class_type();
00147 }
00148 virtual TypeHandle force_init_type() {
00149 init_type();
00150 return get_class_type();
00151 }
00152
00153 private:
00154 static TypeHandle _type_handle;
00155 };
00156
00157 #include "bulletBodyNode.I"
00158
00159 #endif // __BULLET_BODY_NODE_H__
00160