Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

[Bullet] btGeneric6DofSpringConstraint rotation

$
0
0
I want to simulate a object on a rope. Here is what I've tried: btScalar SpringLength( 3 ); btScalar PivotOffset( 0 ); btScalar SpringRange( 7 ); PlaneShape = new btBoxShape( btVector3( 1, 1, 1 ) ); btTransform tr; tr.setIdentity( ); tr.setOrigin( btVector3( 0, 0, 0 ) ); tr.getBasis( ).setEulerYPR( 0, 0, 0 ); MotionState = new btDefaultMotionState( ); MotionState->setWorldTransform( tr ); btRigidBody* pBodyA = new btRigidBody( 1, MotionState, PlaneShape ); m_pWorld->addRigidBody( pBodyA ); btTransform frameInA; frameInA = btTransform::getIdentity( ); frameInA.setOrigin( btVector3( 0, 0, 0 ) ); tr.setIdentity( ); tr.setOrigin( btVector3( 0, 60 - SpringLength - PivotOffset, 0 ) ); tr.getBasis( ).setEulerYPR( 0, 0, 0 ); MotionState = new btDefaultMotionState( ); MotionState->setWorldTransform( tr ); BoxShape = new btBoxShape( btVector3( 1, 1, 1 ) ); btRigidBody* pBodyB = new btRigidBody( 0, MotionState, BoxShape ); m_pWorld->addRigidBody( pBodyB ); btTransform frameInB; frameInB = btTransform::getIdentity( ); frameInB.setOrigin( btVector3( PivotOffset, -10, 0 ) ); btGeneric6DofSpringConstraint * pGen6DOFSpring = new btGeneric6DofSpringConstraint( *pBodyA, *pBodyB, frameInA, frameInB, true ); pGen6DOFSpring->setLinearLowerLimit( btVector3( - SpringRange, - 0, - SpringRange ) ); pGen6DOFSpring->setLinearUpperLimit( btVector3( + SpringRange, + 0, + SpringRange ) ); pGen6DOFSpring->setAngularLowerLimit( btVector3( - SpringRange, - SpringRange, - SpringRange ) ); pGen6DOFSpring->setAngularUpperLimit( btVector3( + SpringRange, + SpringRange, + SpringRange ) ); m_pWorld->addConstraint( pGen6DOFSpring, true ); for ( int i = 0; i < 3; ++i ) { pGen6DOFSpring->enableSpring( i, true ); pGen6DOFSpring->setStiffness( i, 1 ); pGen6DOFSpring->setStiffness( i + 3, 1 ); pGen6DOFSpring->setDamping( i, btScalar( 0.99 ) ); pGen6DOFSpring->setDamping( i + 3, btScalar( 0.99 ) ); pGen6DOFSpring->setParam( BT_CONSTRAINT_STOP_CFM, btScalar( (1.0E-5) ), i ); pGen6DOFSpring->setParam( BT_CONSTRAINT_STOP_CFM, btScalar( ( 1.0E-5 ) ), i + 3 ); pGen6DOFSpring->setParam( BT_CONSTRAINT_CFM, btScalar( ( 1.0E-5 ) ), i ); pGen6DOFSpring->setParam( BT_CONSTRAINT_CFM, btScalar( ( 1.0E-5 ) ), i+3 ); } pGen6DOFSpring->setEquilibriumPoint( ); The object moves like it's on a rope, but it doesn't rotate at all. I am an absolute beginner.

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>