From 635bbb5324ac2f091463d5d66aec72460e0d7f86 Mon Sep 17 00:00:00 2001 From: rponom Date: Wed, 3 Nov 2010 21:34:26 +0000 Subject: [PATCH] Sample of 6DOF constraint with motor attached to the world added to AppConstraintDemo --- Demos/ConstraintDemo/ConstraintDemo.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Demos/ConstraintDemo/ConstraintDemo.cpp b/Demos/ConstraintDemo/ConstraintDemo.cpp index 97a9cf3d4..5590e9fcf 100644 --- a/Demos/ConstraintDemo/ConstraintDemo.cpp +++ b/Demos/ConstraintDemo/ConstraintDemo.cpp @@ -493,6 +493,31 @@ void ConstraintDemo::initPhysics() } #endif +#if ENABLE_ALL_DEMOS + { // 6DOF connected to the world, with motor + btTransform tr; + tr.setIdentity(); + tr.setOrigin(btVector3(btScalar(10.), btScalar(-15.), btScalar(0.))); + btRigidBody* pBody = localCreateRigidBody( 1.0, tr, shape); + pBody->setActivationState(DISABLE_DEACTIVATION); + btTransform frameB; + frameB.setIdentity(); + btGeneric6DofConstraint* pGen6Dof = new btGeneric6DofConstraint( *pBody, frameB, false ); + m_dynamicsWorld->addConstraint(pGen6Dof); + pGen6Dof->setDbgDrawSize(btScalar(5.f)); + + pGen6Dof->setAngularLowerLimit(btVector3(0,0,0)); + pGen6Dof->setAngularUpperLimit(btVector3(0,0,0)); + pGen6Dof->setLinearLowerLimit(btVector3(-10., 0, 0)); + pGen6Dof->setLinearUpperLimit(btVector3(10., 0, 0)); + + pGen6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true; + pGen6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f; + pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f; + } +#endif + + #ifdef TEST_SERIALIZATION int maxSerializeBufferSize = 1024*1024*5;