## Motor the Constraint why bodys move separate?

allenshen
Posts: 6
Joined: Mon Jan 28, 2013 2:51 am

### Motor the Constraint why bodys move separate?

Hi,I got a problem when add one Generic6DofConstraint and three HingeConstraint to simulate skimmer equipment,first of all,add the Constraints to the world:

Code: Select all

``````// HingeConstraint
btVector3 axisXB(1.f, 0.f, 0.f);
btVector3 axisSB(1.f, 0.f, 0.f);
btVector3 pivotXB(0.f, 210.f, 20.f);
btVector3 pivotSB(15.558686f, 156.306944f, 33.72809f);
constraintShangbi = new btHingeConstraint(*xiabiBody,*shangbiBody,pivotXB,pivotSB,axisXB,axisSB,true);
constraintShangbi->setLimit(0,0);

//HingeConstraint
btVector3 axiXB(1.f, 0.f, 0.f);
btVector3 axiYeya3(1.f, 0.f, 0.f);
btVector3 ptXB(-15.426056f, 157.f, -14.29511f);
btVector3 ptYeya3(0.f, 54.415254f, 10.37402f);
constraintYeyagan3 = new btHingeConstraint(*xiabiBody,*yeya3Body,ptXB,ptYeya3,axiXB,axiYeya3,true);
constraintYeyagan3->setLimit(0,0);

// HingeConstraint
btVector3 axiSB(1.f, 0.f, 0.f);
btVector3 axiYeyagan3(1.f, 0.f, 0.f);
btVector3 ptSB(0.033236f, -16.f, -25.94104f);
btVector3 ptYeyagan3(0., -53.33174f, -11.37402f);
constraintYeya3 = new btHingeConstraint(*shangbiBody,*yeyagan3Body,ptSB,ptYeyagan3,axiSB,axiYeyagan3,true);
constraintYeya3->setLimit(0,0);

// Generic6DofConstraint
localA.setIdentity();
localA.setOrigin(btVector3(0,0,0));
localB.setIdentity();
localB.setOrigin(btVector3(0.099394,11.55995,3.62598));
constraintSliderYeya3 = new btGeneric6DofConstraint(*yeya3Body,*yeyagan3Body,localA,localB,true);
constraintSliderYeya3->setAngularLowerLimit(btVector3(0,0,0));
constraintSliderYeya3->setAngularUpperLimit(btVector3(0,0,0));
constraintSliderYeya3->setLinearLowerLimit(btVector3(0, 0, 0));
constraintSliderYeya3->setLinearUpperLimit(btVector3(0, 0, 0));
constraintSliderYeya3->getTranslationalLimitMotor()->m_enableMotor[1] = true;
constraintSliderYeya3->getTranslationalLimitMotor()->m_enableMotor[2] = true;
constraintSliderYeya3->getTranslationalLimitMotor()->m_targetVelocity = btVector3(0,0,0);
constraintSliderYeya3->getTranslationalLimitMotor()->m_maxMotorForce =btVector3(0, (11.8*1000),(2.33*1000));
``````
then motor the constraintSliderYeya3:

Code: Select all

``````constraintShangbi->setLimit(-osg::PI,0);
constraintYeya3->setLimit(-osg::PI,0);
constraintYeyagan3->setLimit(-osg::PI,0);

constraintSliderYeya3->setLinearLowerLimit(btVector3(0,-94.4,-18.64));
constraintSliderYeya3->setLinearUpperLimit(btVector3(0,0,0));

constraintSliderYeya3->getTranslationalLimitMotor()->m_targetVelocity = btVector3(0,11.8,2.33);
``````
now something strange appear:
initial state

motored state

we can see that the constraintSliderYeya3 don't slider along a fixed line,and the two rigidbody don't keep together,can anyone help?
if it's not the right way ,how?
thx!