Panda3D
 All Classes Functions Variables Enumerations
bulletSliderConstraint.cxx
00001 // Filename: bulletSliderConstraint.cxx
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 #include "bulletSliderConstraint.h"
00016 #include "bulletRigidBodyNode.h"
00017 
00018 #include "deg_2_rad.h"
00019 
00020 TypeHandle BulletSliderConstraint::_type_handle;
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //     Function: BulletSliderConstraint::Constructor
00024 //       Access: Published
00025 //  Description:
00026 ////////////////////////////////////////////////////////////////////
00027 BulletSliderConstraint::
00028 BulletSliderConstraint(const BulletRigidBodyNode *node_a, 
00029                        CPT(TransformState) frame_a,
00030                        bool use_frame_a) {
00031 
00032   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
00033   btTransform trans_a = TransformState_to_btTrans(frame_a);
00034 
00035   _constraint = new btSliderConstraint(*ptr_a, trans_a, use_frame_a);
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: BulletSliderConstraint::Constructor
00040 //       Access: Published
00041 //  Description:
00042 ////////////////////////////////////////////////////////////////////
00043 BulletSliderConstraint::
00044 BulletSliderConstraint(const BulletRigidBodyNode *node_a,
00045                        const BulletRigidBodyNode *node_b,
00046                        CPT(TransformState) frame_a,
00047                        CPT(TransformState) frame_b,
00048                        bool use_frame_a) {
00049 
00050   btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
00051   btTransform trans_a = TransformState_to_btTrans(frame_a);
00052 
00053   btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object());
00054   btTransform trans_b = TransformState_to_btTrans(frame_b);
00055 
00056   _constraint = new btSliderConstraint(*ptr_a, *ptr_b, trans_a, trans_b, use_frame_a);
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: BulletSliderConstraint::ptr
00061 //       Access: Public
00062 //  Description:
00063 ////////////////////////////////////////////////////////////////////
00064 btTypedConstraint *BulletSliderConstraint::
00065 ptr() const {
00066 
00067   return _constraint;
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: BulletSliderConstraint::get_lower_linear_limit
00072 //       Access: Published
00073 //  Description:
00074 ////////////////////////////////////////////////////////////////////
00075 PN_stdfloat BulletSliderConstraint::
00076 get_lower_linear_limit() const {
00077 
00078   return (PN_stdfloat)_constraint->getLowerLinLimit();
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: BulletSliderConstraint::get_upper_linear_limit
00083 //       Access: Published
00084 //  Description:
00085 ////////////////////////////////////////////////////////////////////
00086 PN_stdfloat BulletSliderConstraint::
00087 get_upper_linear_limit() const {
00088 
00089   return (PN_stdfloat)_constraint->getUpperLinLimit();
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: BulletSliderConstraint::get_lower_angular_limit
00094 //       Access: Published
00095 //  Description:
00096 ////////////////////////////////////////////////////////////////////
00097 PN_stdfloat BulletSliderConstraint::
00098 get_lower_angular_limit() const {
00099 
00100   return rad_2_deg(_constraint->getLowerAngLimit());
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: BulletSliderConstraint::get_upper_angular_limit
00105 //       Access: Published
00106 //  Description:
00107 ////////////////////////////////////////////////////////////////////
00108 PN_stdfloat BulletSliderConstraint::
00109 get_upper_angular_limit() const {
00110 
00111   return rad_2_deg(_constraint->getUpperAngLimit());
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: BulletSliderConstraint::set_lower_linear_limit
00116 //       Access: Published
00117 //  Description:
00118 ////////////////////////////////////////////////////////////////////
00119 void BulletSliderConstraint::
00120 set_lower_linear_limit(PN_stdfloat value) {
00121 
00122   _constraint->setLowerLinLimit((btScalar)value);
00123 }
00124 
00125 ////////////////////////////////////////////////////////////////////
00126 //     Function: BulletSliderConstraint::set_upper_linear_limit
00127 //       Access: Published
00128 //  Description:
00129 ////////////////////////////////////////////////////////////////////
00130 void BulletSliderConstraint::
00131 set_upper_linear_limit(PN_stdfloat value) {
00132 
00133   _constraint->setUpperLinLimit((btScalar)value);
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: BulletSliderConstraint::set_lower_angular_limit
00138 //       Access: Published
00139 //  Description:
00140 ////////////////////////////////////////////////////////////////////
00141 void BulletSliderConstraint::
00142 set_lower_angular_limit(PN_stdfloat value) {
00143 
00144   _constraint->setLowerAngLimit((btScalar)deg_2_rad(value));
00145 }
00146 
00147 ////////////////////////////////////////////////////////////////////
00148 //     Function: BulletSliderConstraint::set_upper_angular_limit
00149 //       Access: Published
00150 //  Description:
00151 ////////////////////////////////////////////////////////////////////
00152 void BulletSliderConstraint::
00153 set_upper_angular_limit(PN_stdfloat value) {
00154 
00155   _constraint->setUpperAngLimit((btScalar)deg_2_rad(value));
00156 }
00157 
00158 ////////////////////////////////////////////////////////////////////
00159 //     Function: BulletSliderConstraint::get_linear_pos
00160 //       Access: Published
00161 //  Description:
00162 ////////////////////////////////////////////////////////////////////
00163 PN_stdfloat BulletSliderConstraint::
00164 get_linear_pos() const {
00165 
00166   return (PN_stdfloat)_constraint->getLinearPos();
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: BulletSliderConstraint::get_angular_pos
00171 //       Access: Published
00172 //  Description:
00173 ////////////////////////////////////////////////////////////////////
00174 PN_stdfloat BulletSliderConstraint::
00175 get_angular_pos() const {
00176 
00177   return (PN_stdfloat)_constraint->getAngularPos();
00178 }
00179 
00180 ////////////////////////////////////////////////////////////////////
00181 //     Function: BulletSliderConstraint::set_powered_linear_motor
00182 //       Access: Published
00183 //  Description:
00184 ////////////////////////////////////////////////////////////////////
00185 void BulletSliderConstraint::
00186 set_powered_linear_motor(bool on) {
00187 
00188   _constraint->setPoweredLinMotor(on);
00189 }
00190 
00191 ////////////////////////////////////////////////////////////////////
00192 //     Function: BulletSliderConstraint::set_target_linear_motor_velocity
00193 //       Access: Published
00194 //  Description:
00195 ////////////////////////////////////////////////////////////////////
00196 void BulletSliderConstraint::
00197 set_target_linear_motor_velocity(PN_stdfloat target_velocity) {
00198 
00199   _constraint->setTargetLinMotorVelocity((btScalar)target_velocity);
00200 }
00201 
00202 ////////////////////////////////////////////////////////////////////
00203 //     Function: BulletSliderConstraint::set_max_linear_motor_force
00204 //       Access: Published
00205 //  Description:
00206 ////////////////////////////////////////////////////////////////////
00207 void BulletSliderConstraint::
00208 set_max_linear_motor_force(PN_stdfloat max_force) {
00209 
00210   _constraint->setMaxLinMotorForce((btScalar)max_force);
00211 }
00212 
00213 ////////////////////////////////////////////////////////////////////
00214 //     Function: BulletSliderConstraint::get_powered_linear_motor
00215 //       Access: Published
00216 //  Description:
00217 ////////////////////////////////////////////////////////////////////
00218 bool BulletSliderConstraint::
00219 get_powered_linear_motor() const {
00220 
00221   return _constraint->getPoweredLinMotor();
00222 }
00223 
00224 ////////////////////////////////////////////////////////////////////
00225 //     Function: BulletSliderConstraint::get_target_linear_motor_velocity
00226 //       Access: Published
00227 //  Description:
00228 ////////////////////////////////////////////////////////////////////
00229 PN_stdfloat BulletSliderConstraint::
00230 get_target_linear_motor_velocity() const {
00231 
00232   return (PN_stdfloat)_constraint->getTargetLinMotorVelocity();
00233 }
00234 
00235 ////////////////////////////////////////////////////////////////////
00236 //     Function: BulletSliderConstraint::get_max_linear_motor_force
00237 //       Access: Published
00238 //  Description:
00239 ////////////////////////////////////////////////////////////////////
00240 PN_stdfloat BulletSliderConstraint::
00241 get_max_linear_motor_force() const {
00242 
00243   return (PN_stdfloat)_constraint->getMaxLinMotorForce();
00244 }
00245 
00246 ////////////////////////////////////////////////////////////////////
00247 //     Function: BulletSliderConstraint::set_powered_angular_motor
00248 //       Access: Published
00249 //  Description:
00250 ////////////////////////////////////////////////////////////////////
00251 void BulletSliderConstraint::
00252 set_powered_angular_motor(bool on) {
00253 
00254   _constraint->setPoweredAngMotor(on);
00255 }
00256 
00257 ////////////////////////////////////////////////////////////////////
00258 //     Function: BulletSliderConstraint::set_target_angular_motor_velocity
00259 //       Access: Published
00260 //  Description:
00261 ////////////////////////////////////////////////////////////////////
00262 void BulletSliderConstraint::
00263 set_target_angular_motor_velocity(PN_stdfloat target_velocity) {
00264 
00265   _constraint->setTargetAngMotorVelocity((btScalar)target_velocity);
00266 }
00267 
00268 ////////////////////////////////////////////////////////////////////
00269 //     Function: BulletSliderConstraint::set_max_angular_motor_force
00270 //       Access: Published
00271 //  Description:
00272 ////////////////////////////////////////////////////////////////////
00273 void BulletSliderConstraint::
00274 set_max_angular_motor_force(PN_stdfloat max_force) {
00275 
00276   _constraint->setMaxAngMotorForce((btScalar)max_force);
00277 }
00278 
00279 ////////////////////////////////////////////////////////////////////
00280 //     Function: BulletSliderConstraint::get_powered_angular_motor
00281 //       Access: Published
00282 //  Description:
00283 ////////////////////////////////////////////////////////////////////
00284 bool BulletSliderConstraint::
00285 get_powered_angular_motor() const {
00286 
00287   return _constraint->getPoweredAngMotor();
00288 }
00289 
00290 ////////////////////////////////////////////////////////////////////
00291 //     Function: BulletSliderConstraint::get_target_angular_motor_velocity
00292 //       Access: Published
00293 //  Description:
00294 ////////////////////////////////////////////////////////////////////
00295 PN_stdfloat BulletSliderConstraint::
00296 get_target_angular_motor_velocity() const {
00297 
00298   return (PN_stdfloat)_constraint->getTargetAngMotorVelocity();
00299 }
00300 
00301 ////////////////////////////////////////////////////////////////////
00302 //     Function: BulletSliderConstraint::get_max_angular_motor_force
00303 //       Access: Published
00304 //  Description:
00305 ////////////////////////////////////////////////////////////////////
00306 PN_stdfloat BulletSliderConstraint::
00307 get_max_angular_motor_force() const {
00308 
00309   return (PN_stdfloat)_constraint->getMaxAngMotorForce();
00310 }
00311 
 All Classes Functions Variables Enumerations