Universe.Physics.BulletSPlugin.BSConstraint6Dof.TranslationalLimitMotor C# (CSharp) Method

TranslationalLimitMotor() public method

public TranslationalLimitMotor ( bool enable, float targetVelocity, float maxMotorForce ) : bool
enable bool
targetVelocity float
maxMotorForce float
return bool
        public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce)
        {
            bool ret = false;
            float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
            if (m_enabled)
            {
                ret = PhysicsScene.PE.TranslationalLimitMotor(m_constraint, onOff, targetVelocity, maxMotorForce);
                m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}",
                    BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce);
            }
            return ret;
        }

Usage Example

        // Note that this relies on being called at TaintTime
        void AddAxisLockConstraint()
        {
            if (LockAxisConstraint == null)
            {
                // Lock that axis by creating a 6DOF constraint that has one end in the world and
                //    the other in the object.
                // http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?p=20817
                // http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?p=26380

                // Remove any existing axis constraint (just to be sure)
                RemoveAxisLockConstraint();

                BSConstraint6Dof axisConstrainer = new BSConstraint6Dof(m_physicsScene.World, m_controllingPrim.PhysBody,
                                                                        OMV.Vector3.Zero, OMV.Quaternion.Identity,
                                                                        false /* useLinearReferenceFrameB */, true /* disableCollisionsBetweenLinkedBodies */);
                LockAxisConstraint = axisConstrainer;
                m_physicsScene.Constraints.AddConstraint(LockAxisConstraint);

                // Remember the clocking being inforce so we can notice if they have changed
                LockAxisLinearFlags  = m_controllingPrim.LockedLinearAxis;
                LockAxisAngularFlags = m_controllingPrim.LockedAngularAxis;

                // The constraint is tied to the world and oriented to the prim.
                if (
                    !axisConstrainer.SetLinearLimits(m_controllingPrim.LockedLinearAxisLow,
                                                     m_controllingPrim.LockedLinearAxisHigh))
                {
                    m_physicsScene.DetailLog("{0},BSActorLockAxis.AddAxisLockConstraint,failedSetLinearLimits",
                                             m_controllingPrim.LocalID);
                }

                if (
                    !axisConstrainer.SetAngularLimits(m_controllingPrim.LockedAngularAxisLow,
                                                      m_controllingPrim.LockedAngularAxisHigh))
                {
                    m_physicsScene.DetailLog("{0},BSActorLockAxis.AddAxisLockConstraint,failedSetAngularLimits", m_controllingPrim.LocalID);
                }

                m_physicsScene.DetailLog(
                    "{0},BSActorLockAxis.AddAxisLockConstraint,create,linLow={1},linHi={2},angLow={3},angHi={4}",
                    m_controllingPrim.LocalID, m_controllingPrim.LockedLinearAxisLow,
                    m_controllingPrim.LockedLinearAxisHigh, m_controllingPrim.LockedAngularAxisLow,
                    m_controllingPrim.LockedAngularAxisHigh);

                // Constants from one of the posts mentioned above and used in Bullet's ConstraintDemo.
                axisConstrainer.TranslationalLimitMotor(true /* enable */, 5.0f, 0.1f);
                axisConstrainer.RecomputeConstraintVariables(m_controllingPrim.RawMass);
                RegisterForBeforeStepCallback();
            }
        }
All Usage Examples Of Universe.Physics.BulletSPlugin.BSConstraint6Dof::TranslationalLimitMotor