Panda3D
|
00001 // Filename: bulletHingeConstraint.h 00002 // Created by: enn0x (01Mar10) 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 __BULLET_HINGE_CONSTRAINT_H__ 00016 #define __BULLET_HINGE_CONSTRAINT_H__ 00017 00018 #include "pandabase.h" 00019 00020 #include "bullet_includes.h" 00021 #include "bullet_utils.h" 00022 #include "bulletConstraint.h" 00023 00024 #include "luse.h" 00025 00026 class BulletRigidBodyNode; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : BulletHingeConstraint 00030 // Description : The hinge constraint lets two bodies rotate around 00031 // a given axis while adhering to specified limits. 00032 // It's motor can apply angular force to them. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDABULLET BulletHingeConstraint : public BulletConstraint { 00035 00036 PUBLISHED: 00037 BulletHingeConstraint(const BulletRigidBodyNode *node_a, 00038 const LPoint3 &pivot_a, 00039 const LVector3 &axis_a, 00040 bool use_frame_a=false); 00041 BulletHingeConstraint(const BulletRigidBodyNode *node_a, 00042 const BulletRigidBodyNode *node_b, 00043 const LPoint3 &pivot_a, 00044 const LPoint3 &pivot_b, 00045 const LVector3 &axis_a, 00046 const LVector3 &axis_b, 00047 bool use_frame_a=false); 00048 INLINE ~BulletHingeConstraint(); 00049 00050 PN_stdfloat get_hinge_angle(); 00051 PN_stdfloat get_lower_limit() const; 00052 PN_stdfloat get_upper_limit() const; 00053 bool get_angular_only() const; 00054 00055 void set_angular_only(bool value); 00056 void set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness=0.9f, PN_stdfloat bias=0.3f, PN_stdfloat relaxation=1.0f); 00057 void set_axis(const LVector3 &axis); 00058 00059 void enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_impulse); 00060 void enable_motor(bool enable); 00061 void set_max_motor_impulse(PN_stdfloat max_impulse); 00062 void set_motor_target(const LQuaternion &quat, PN_stdfloat dt); 00063 void set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt); 00064 00065 public: 00066 virtual btTypedConstraint *ptr() const; 00067 00068 private: 00069 btHingeConstraint *_constraint; 00070 00071 //////////////////////////////////////////////////////////////////// 00072 public: 00073 static TypeHandle get_class_type() { 00074 return _type_handle; 00075 } 00076 static void init_type() { 00077 BulletConstraint::init_type(); 00078 register_type(_type_handle, "BulletHingeConstraint", 00079 BulletConstraint::get_class_type()); 00080 } 00081 virtual TypeHandle get_type() const { 00082 return get_class_type(); 00083 } 00084 virtual TypeHandle force_init_type() { 00085 init_type(); 00086 return get_class_type(); 00087 } 00088 00089 private: 00090 static TypeHandle _type_handle; 00091 }; 00092 00093 #include "bulletHingeConstraint.I" 00094 00095 #endif // __BULLET_HINGE_CONSTRAINT_H__