00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "bulletConeTwistConstraint.h"
00016 #include "bulletRigidBodyNode.h"
00017
00018 #include "deg_2_rad.h"
00019
00020 TypeHandle BulletConeTwistConstraint::_type_handle;
00021
00022
00023
00024
00025
00026
00027 BulletConeTwistConstraint::
00028 BulletConeTwistConstraint(const BulletRigidBodyNode *node_a,
00029 CPT(TransformState) frame_a) {
00030
00031 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
00032 btTransform trans_a = TransformState_to_btTrans(frame_a);
00033
00034 _constraint = new btConeTwistConstraint(*ptr_a, trans_a);
00035 }
00036
00037
00038
00039
00040
00041
00042 BulletConeTwistConstraint::
00043 BulletConeTwistConstraint(const BulletRigidBodyNode *node_a,
00044 const BulletRigidBodyNode *node_b,
00045 CPT(TransformState) frame_a,
00046 CPT(TransformState) frame_b) {
00047
00048 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
00049 btTransform trans_a = TransformState_to_btTrans(frame_a);
00050
00051 btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object());
00052 btTransform trans_b = TransformState_to_btTrans(frame_b);
00053
00054 _constraint = new btConeTwistConstraint(*ptr_a, *ptr_b, trans_a, trans_b);
00055 }
00056
00057
00058
00059
00060
00061
00062 btTypedConstraint *BulletConeTwistConstraint::
00063 ptr() const {
00064
00065 return _constraint;
00066 }
00067
00068
00069
00070
00071
00072
00073 void BulletConeTwistConstraint::
00074 set_limit(int index, PN_stdfloat value) {
00075
00076 value = deg_2_rad(value);
00077
00078 _constraint->setLimit(index, value);
00079 }
00080
00081
00082
00083
00084
00085
00086 void BulletConeTwistConstraint::
00087 set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) {
00088
00089 swing1 = deg_2_rad(swing1);
00090 swing2 = deg_2_rad(swing2);
00091 twist = deg_2_rad(twist);
00092
00093 _constraint->setLimit(swing1, swing2, twist, softness, bias, relaxation);
00094 }
00095
00096
00097
00098
00099
00100
00101 void BulletConeTwistConstraint::
00102 set_damping(PN_stdfloat damping) {
00103
00104 _constraint->setDamping(damping);
00105 }
00106
00107
00108
00109
00110
00111
00112 PN_stdfloat BulletConeTwistConstraint::
00113 get_fix_threshold() const {
00114
00115 return _constraint->getFixThresh();
00116 }
00117
00118
00119
00120
00121
00122
00123 void BulletConeTwistConstraint::
00124 set_fix_threshold(PN_stdfloat threshold) {
00125
00126 _constraint->setFixThresh(threshold);
00127 }
00128
00129
00130
00131
00132
00133
00134 void BulletConeTwistConstraint::
00135 enable_motor(bool enable) {
00136
00137 _constraint->enableMotor(enable);
00138 }
00139
00140
00141
00142
00143
00144
00145 void BulletConeTwistConstraint::
00146 set_max_motor_impulse(PN_stdfloat max_impulse) {
00147
00148 _constraint->setMaxMotorImpulse(max_impulse);
00149 }
00150
00151
00152
00153
00154
00155
00156 void BulletConeTwistConstraint::
00157 set_max_motor_impulse_normalized(PN_stdfloat max_impulse) {
00158
00159 _constraint->setMaxMotorImpulseNormalized(max_impulse);
00160 }
00161
00162
00163
00164
00165
00166
00167 void BulletConeTwistConstraint::
00168 set_motor_target(const LQuaternion &quat) {
00169
00170 _constraint->setMotorTarget(LQuaternion_to_btQuat(quat));
00171 }
00172
00173
00174
00175
00176
00177
00178 void BulletConeTwistConstraint::
00179 set_motor_target_in_constraint_space(const LQuaternion &quat) {
00180
00181 _constraint->setMotorTargetInConstraintSpace(LQuaternion_to_btQuat(quat));
00182 }
00183