Esempio n. 1
0
        //GenericoDofConstraint
        /// <summary>
        /// Adds the generic6 dof constraint.
        /// </summary>
        /// <param name="rigidBodyA">The rigid body a.</param>
        /// <param name="frameInA">The frame in a.</param>
        /// <param name="useReferenceFrameA">if set to <c>true</c> [use reference frame a].</param>
        /// <returns></returns>
        public IGeneric6DofConstraintImp AddGeneric6DofConstraint(IRigidBodyImp rigidBodyA, float4x4 frameInA, bool useReferenceFrameA)
        {
            var rigidBodyAImp           = (RigidBodyImp)rigidBodyA;
            var btRigidBodyA            = rigidBodyAImp._rbi;
            var btFframeInA             = Translator.Float4X4ToBtMatrix(frameInA);
            var btGeneric6DofConstraint = new Generic6DofConstraint(btRigidBodyA, btFframeInA, useReferenceFrameA);

            BtWorld.AddConstraint(btGeneric6DofConstraint);

            var retval = new Generic6DofConstraintImp();

            retval._g6dofci = btGeneric6DofConstraint;
            btGeneric6DofConstraint.UserObject = retval;
            return(retval);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds the slider constraint.
        /// </summary>
        /// <param name="rigidBodyA">The rigid body a.</param>
        /// <param name="frameInA">The frame in a.</param>
        /// <param name="useLinearReferenceFrameA">if set to <c>true</c> [use linear reference frame a].</param>
        /// <returns></returns>
        public ISliderConstraintImp AddSliderConstraint(IRigidBodyImp rigidBodyA, float4x4 frameInA, bool useLinearReferenceFrameA)
        {
            var rigidBodyAImp      = (RigidBodyImp)rigidBodyA;
            var btRigidBodyA       = rigidBodyAImp._rbi;
            var btFrameInA         = Translator.Float4X4ToBtMatrix(frameInA);
            var btSliderConstraint = new SliderConstraint(btRigidBodyA, btFrameInA, useLinearReferenceFrameA);

            BtWorld.AddConstraint(btSliderConstraint);

            var retval = new SliderConstraintImp();

            retval._sci = btSliderConstraint;
            btSliderConstraint.UserObject = retval;
            return(retval);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the child shape.
        /// </summary>
        /// <param name="localTransform">The local transform.</param>
        /// <param name="shape">The shape.</param>
        public void AddChildShape(float4x4 localTransform, IMultiSphereShapeImp shape)
        {
            var btPositions = new Vector3[shape.SphereCount];
            var btRadi      = new float[shape.SphereCount];

            for (int i = 0; i < shape.SphereCount; i++)
            {
                var pos = Translator.Float3ToBtVector3(shape.GetSpherePosition(i));
                btPositions[i] = pos;
                btRadi[i]      = shape.GetSphereRadius(i);
            }
            var btChildShape     = new MultiSphereShape(btPositions, btRadi);
            var btLocalTransform = Translator.Float4X4ToBtMatrix(localTransform);

            BtCompoundShape.AddChildShape(btLocalTransform, btChildShape);
        }
Esempio n. 4
0
        //ConeTwistConstraint
        /// <summary>
        /// Adds the cone twist constraint.
        /// </summary>
        /// <param name="rigidBodyA">The rigid body a.</param>
        /// <param name="rbAFrame">The rb a frame.</param>
        /// <returns></returns>
        public IConeTwistConstraintImp AddConeTwistConstraint(IRigidBodyImp rigidBodyA, float4x4 rbAFrame)
        {
            var rigidBodyAImp = (RigidBodyImp)rigidBodyA;
            var btRigidBodyA  = rigidBodyAImp._rbi;
            var btRbAFrame    = Translator.Float4X4ToBtMatrix(rbAFrame);

            var btCTConstraint = new ConeTwistConstraint(btRigidBodyA, btRbAFrame);

            BtWorld.AddConstraint(btCTConstraint);

            var retval = new ConeTwistConstraintImp();

            retval._cti = btCTConstraint;
            btCTConstraint.UserObject = retval;
            return(retval);
        }
Esempio n. 5
0
        /// <summary>
        /// Adds the hinge constraint.
        /// </summary>
        /// <param name="rigidBodyA">The rigid body a.</param>
        /// <param name="rigidBodyB">The rigid body b.</param>
        /// <param name="brAFrame">The br a frame.</param>
        /// <param name="brBFrame">The br b frame.</param>
        /// <param name="useReferenceFrameA">if set to <c>true</c> [use reference frame a].</param>
        /// <returns></returns>
        public IHingeConstraintImp AddHingeConstraint(IRigidBodyImp rigidBodyA, IRigidBodyImp rigidBodyB, float4x4 brAFrame, float4x4 brBFrame, bool useReferenceFrameA)
        {
            var rigidBodyAImp = (RigidBodyImp)rigidBodyA;
            var btRigidBodyA  = rigidBodyAImp._rbi;

            var rigidBodyBImp = (RigidBodyImp)rigidBodyB;
            var btRigidBodyB  = rigidBodyBImp._rbi;

            var btRbAFrame = Translator.Float4X4ToBtMatrix(brAFrame);
            var btRbBFrame = Translator.Float4X4ToBtMatrix(brBFrame);

            var btHingeConstraint = new HingeConstraint(btRigidBodyA, btRigidBodyB, btRbAFrame, btRbBFrame, useReferenceFrameA);

            BtWorld.AddConstraint(btHingeConstraint);

            var retval = new HingeConstraintImp();

            retval._hci = btHingeConstraint;
            btHingeConstraint.UserObject = retval;
            return(retval);
        }
 /// <summary>
 /// Calculates the transforms.
 /// </summary>
 /// <param name="transA">The trans a.</param>
 /// <param name="transB">The trans b.</param>
 public void CalculateTransforms(float4x4 transA, float4x4 transB)
 {
     _g6dofci.CalculateTransforms(Translator.Float4X4ToBtMatrix(transA), Translator.Float4X4ToBtMatrix(transB));
 }
 /// <summary>
 /// Sets the frames.
 /// </summary>
 /// <param name="frameA">The frame a.</param>
 /// <param name="frameB">The frame b.</param>
 public void SetFrames(float4x4 frameA, float4x4 frameB)
 {
     _g6dofci.SetFrames(Translator.Float4X4ToBtMatrix(frameA), Translator.Float4X4ToBtMatrix(frameB));
 }
Esempio n. 8
0
        /// <summary>
        /// Sets the frames.
        /// </summary>
        /// <param name="frameA">The frame a.</param>
        /// <param name="frameB">The frame b.</param>
        public void SetFrames(float4x4 frameA, float4x4 frameB)
        {
            var o = (SliderConstraintImp)_sci.UserObject;

            o._sci.SetFrames(Translator.Float4X4ToBtMatrix(frameA), Translator.Float4X4ToBtMatrix(frameB));
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the hinge angle.
        /// </summary>
        /// <param name="transA">The trans a.</param>
        /// <param name="transB">The trans b.</param>
        /// <returns></returns>
        public float GetHingeAngle(float4x4 transA, float4x4 transB)
        {
            var retval = _hci.GetHingeAngle(Translator.Float4X4ToBtMatrix(transA), Translator.Float4X4ToBtMatrix(transB));

            return(retval);
        }
Esempio n. 10
0
 /// <summary>
 /// Calculates the angle info2.
 /// </summary>
 /// <param name="transA">The trans a.</param>
 /// <param name="transB">The trans b.</param>
 /// <param name="invInertiaWorldA">The inv inertia world a.</param>
 /// <param name="invInertiaWorldB">The inv inertia world b.</param>
 public void CalcAngleInfo2(float4x4 transA, float4x4 transB, float4x4 invInertiaWorldA, float4x4 invInertiaWorldB)
 {
     _cti.CalcAngleInfo2(Translator.Float4X4ToBtMatrix(transA), Translator.Float4X4ToBtMatrix(transB), Translator.Float4X4ToBtMatrix(invInertiaWorldA), Translator.Float4X4ToBtMatrix(invInertiaWorldB));
 }