00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "bulletSphericalConstraint.h"
00016 #include "bulletRigidBodyNode.h"
00017
00018 TypeHandle BulletSphericalConstraint::_type_handle;
00019
00020
00021
00022
00023
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
00037
00038
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
00057
00058
00059
00060 btTypedConstraint *BulletSphericalConstraint::
00061 ptr() const {
00062
00063 return _constraint;
00064 }
00065
00066
00067
00068
00069
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
00080
00081
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
00092
00093
00094
00095 LPoint3 BulletSphericalConstraint::
00096 get_pivot_in_a() const {
00097
00098 return btVector3_to_LPoint3(_constraint->getPivotInA());
00099 }
00100
00101
00102
00103
00104
00105
00106 LPoint3 BulletSphericalConstraint::
00107 get_pivot_in_b() const {
00108
00109 return btVector3_to_LPoint3(_constraint->getPivotInB());
00110 }
00111