Example #1
0
 //[email protected]}
 public Generic6DofConstraint(RigidBody rbA, RigidBody rbB, btTransform frameInA, btTransform frameInB, bool useLinearReferenceFrameA)
     : base(TypedConstraintType.D6_CONSTRAINT_TYPE, rbA, rbB)
 {
     m_linearLimits = new TranslationalLimitMotor();
     m_angularLimits = new RotationalLimitMotor[3];
     for (int i = 0; i < m_angularLimits.Length; i++)
         m_angularLimits[i] = new RotationalLimitMotor();
     m_frameInA = frameInA;
     m_frameInB = frameInB;
     m_useLinearReferenceFrameA = useLinearReferenceFrameA;
     m_useOffsetForConstraintFrame = D6_USE_FRAME_OFFSET;
     m_flags = bt6DofFlags.BT_6DOF_FLAGS_NONE;
     m_useSolveConstraintObsolete = D6_USE_OBSOLETE_METHOD;
     calculateTransforms();
 }
		internal btGeneric6DofConstraint( btRigidBody rbB, ref btTransform frameInB, bool useLinearReferenceFrameB )
			: base( btObjectTypes.D6_CONSTRAINT_TYPE, getFixedBody(), rbB )
		{
			m_frameInB = ( frameInB );
			m_useLinearReferenceFrameA = ( useLinearReferenceFrameB );
			m_useOffsetForConstraintFrame = ( D6_USE_FRAME_OFFSET );
			m_flags = ( 0 );
			m_useSolveConstraintObsolete = ( false );
			///not providing rigidbody A means implicitly using worldspace for body A
			rbB.m_worldTransform.Apply( ref m_frameInB, out m_frameInA );
			calculateTransforms();
		}
		internal btGeneric6DofConstraint( btRigidBody rbA, btRigidBody rbB, ref btTransform frameInA, ref btTransform frameInB, bool useLinearReferenceFrameA )
				: base( btObjectTypes.D6_CONSTRAINT_TYPE, rbA, rbB )
		{
			m_frameInA = ( frameInA );
			m_frameInB = ( frameInB );
			m_useLinearReferenceFrameA = ( useLinearReferenceFrameA );
			m_useOffsetForConstraintFrame = ( D6_USE_FRAME_OFFSET );
			m_flags = ( 0 );
			m_useSolveConstraintObsolete = ( D6_USE_OBSOLETE_METHOD );
			calculateTransforms();
		}
		///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5). 
		///If no axis is provided, it uses the default axis for this constraint.
		public override void setParam( btConstraintParams num, double value, int axis = -1 )
		{
			if( ( axis >= 0 ) && ( axis < 3 ) )
			{
				switch( num )
				{
					case btConstraintParams.BT_CONSTRAINT_STOP_ERP:
						m_linearLimits.m_stopERP[axis] = value;
						m_flags |= bt6DofFlagsIndexed.BT_6DOF_FLAGS_ERP_STOP[axis];
						break;
					case btConstraintParams.BT_CONSTRAINT_STOP_CFM:
						m_linearLimits.m_stopCFM[axis] = value;
						m_flags |= bt6DofFlagsIndexed.BT_6DOF_FLAGS_CFM_STOP[axis];
						break;
					case btConstraintParams.BT_CONSTRAINT_CFM:
						m_linearLimits.m_normalCFM[axis] = value;
						m_flags |= bt6DofFlagsIndexed.BT_6DOF_FLAGS_CFM_NORM[axis];
						break;
					default:
						btAssertConstrParams( false );
						break;
				}
			}
			else if( ( axis >= 3 ) && ( axis < 6 ) )
			{
				switch( num )
				{
					case btConstraintParams.BT_CONSTRAINT_STOP_ERP:
						m_angularLimits[axis - 3].m_stopERP = value;
						m_flags |= bt6DofFlagsIndexed.BT_6DOF_FLAGS_ERP_STOP[axis];
						break;
					case btConstraintParams.BT_CONSTRAINT_STOP_CFM:
						m_angularLimits[axis - 3].m_stopCFM = value;
						m_flags |= bt6DofFlagsIndexed.BT_6DOF_FLAGS_CFM_STOP[axis];
						break;
					case btConstraintParams.BT_CONSTRAINT_CFM:
						m_angularLimits[axis - 3].m_normalCFM = value;
						m_flags |= bt6DofFlagsIndexed.BT_6DOF_FLAGS_CFM_NORM[axis];
						break;
					default:
						btAssertConstrParams( false );
						break;
				}
			}
			else
			{
				btAssertConstrParams( false );
			}
		}
Example #5
0
 public Generic6DofConstraint(RigidBody rbB, btTransform frameInB, bool useLinearReferenceFrameB)
     : base(TypedConstraintType.D6_CONSTRAINT_TYPE, getFixedBody(), rbB)
 {
     m_linearLimits = new TranslationalLimitMotor();
     m_angularLimits = new RotationalLimitMotor[3];
     for (int i = 0; i < m_angularLimits.Length; i++)
         m_angularLimits[i] = new RotationalLimitMotor();
     m_frameInB = frameInB;
     m_useLinearReferenceFrameA = useLinearReferenceFrameB;
     m_useOffsetForConstraintFrame = D6_USE_FRAME_OFFSET;
     m_flags = bt6DofFlags.BT_6DOF_FLAGS_NONE;
     m_useSolveConstraintObsolete = false;
     ///not providing rigidbody A means implicitly using worldspace for body A
     m_frameInA = rbB.CenterOfMassTransform * m_frameInB;
     calculateTransforms();
 }