Panda3D
|
00001 // Filename: bulletSphericalConstraint.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 "bulletSphericalConstraint.h" 00016 #include "bulletRigidBodyNode.h" 00017 00018 TypeHandle BulletSphericalConstraint::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: BulletSphericalConstraint::Constructor 00022 // Access: Published 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 BulletSphericalConstraint:: 00026 BulletSphericalConstraint(const BulletRigidBodyNode *node_a, 00027 const LPoint3 &pivot_a) { 00028 00029 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object()); 00030 btVector3 pos_a = LVecBase3_to_btVector3(pivot_a); 00031 00032 _constraint = new btPoint2PointConstraint(*ptr_a, pos_a); 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: BulletSphericalConstraint::Constructor 00037 // Access: Published 00038 // Description: 00039 //////////////////////////////////////////////////////////////////// 00040 BulletSphericalConstraint:: 00041 BulletSphericalConstraint(const BulletRigidBodyNode *node_a, 00042 const BulletRigidBodyNode *node_b, 00043 const LPoint3 &pivot_a, 00044 const LPoint3 &pivot_b) { 00045 00046 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object()); 00047 btVector3 pos_a = LVecBase3_to_btVector3(pivot_a); 00048 00049 btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object()); 00050 btVector3 pos_b = LVecBase3_to_btVector3(pivot_b); 00051 00052 _constraint = new btPoint2PointConstraint(*ptr_a, *ptr_b, pos_a, pos_b); 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: BulletSphericalConstraint::ptr 00057 // Access: Public 00058 // Description: 00059 //////////////////////////////////////////////////////////////////// 00060 btTypedConstraint *BulletSphericalConstraint:: 00061 ptr() const { 00062 00063 return _constraint; 00064 } 00065 00066 //////////////////////////////////////////////////////////////////// 00067 // Function: BulletSphericalConstraint::set_pivot_a 00068 // Access: Published 00069 // Description: 00070 //////////////////////////////////////////////////////////////////// 00071 void BulletSphericalConstraint:: 00072 set_pivot_a(const LPoint3 &pivot_a) { 00073 00074 nassertv(!pivot_a.is_nan()); 00075 _constraint->setPivotA(LVecBase3_to_btVector3(pivot_a)); 00076 } 00077 00078 //////////////////////////////////////////////////////////////////// 00079 // Function: BulletSphericalConstraint::set_pivot_b 00080 // Access: Published 00081 // Description: 00082 //////////////////////////////////////////////////////////////////// 00083 void BulletSphericalConstraint:: 00084 set_pivot_b(const LPoint3 &pivot_b) { 00085 00086 nassertv(!pivot_b.is_nan()); 00087 _constraint->setPivotA(LVecBase3_to_btVector3(pivot_b)); 00088 } 00089 00090 //////////////////////////////////////////////////////////////////// 00091 // Function: BulletSphericalConstraint::set_pivot_in_a 00092 // Access: Published 00093 // Description: 00094 //////////////////////////////////////////////////////////////////// 00095 LPoint3 BulletSphericalConstraint:: 00096 get_pivot_in_a() const { 00097 00098 return btVector3_to_LPoint3(_constraint->getPivotInA()); 00099 } 00100 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: BulletSphericalConstraint::set_pivot_in_b 00103 // Access: Published 00104 // Description: 00105 //////////////////////////////////////////////////////////////////// 00106 LPoint3 BulletSphericalConstraint:: 00107 get_pivot_in_b() const { 00108 00109 return btVector3_to_LPoint3(_constraint->getPivotInB()); 00110 } 00111