예제 #1
0
        /// <summary>
        /// Adds the hinge constraint.
        /// </summary>
        /// <param name="rigidBodyA">The rigid body a.</param>
        /// <param name="pivotInA">The pivot in a.</param>
        /// <param name="axisInA">The axis in a.</param>
        /// <param name="useReferenceFrameA">if set to <c>true</c> [use reference frame a].</param>
        /// <returns></returns>
        public IHingeConstraintImp AddHingeConstraint(IRigidBodyImp rigidBodyA, float3 pivotInA, float3 axisInA, bool useReferenceFrameA)
        {
            var rigidBodyAImp = (RigidBodyImp)rigidBodyA;
            var btRigidBodyA  = rigidBodyAImp._rbi;

            var btHingeConstraint = new HingeConstraint(btRigidBodyA, new Vector3(pivotInA.x, pivotInA.y, pivotInA.z), new Vector3(axisInA.x, axisInA.y, axisInA.z), useReferenceFrameA);

            BtWorld.AddConstraint(btHingeConstraint);

            var retval = new HingeConstraintImp();

            retval._hci = btHingeConstraint;
            btHingeConstraint.UserObject = retval;
            return(retval);
        }
예제 #2
0
        /*//TODO: What about inheritance problems -> should return any constraint type
         * public IPoint2PointConstraintImp GetConstraint(int i)
         * {
         *  return (Point2PointConstraintImp)BtWorld.GetConstraint(0).UserObject;
         * }*/


        //HingeConstraint
        /// <summary>
        /// Adds the hinge 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 IHingeConstraintImp AddHingeConstraint(IRigidBodyImp rigidBodyA, float4x4 frameInA, bool useReferenceFrameA)
        {
            var rigidBodyAImp     = (RigidBodyImp)rigidBodyA;
            var btRigidBodyA      = rigidBodyAImp._rbi;
            var btFframeInA       = Translator.Float4X4ToBtMatrix(frameInA);
            var btHingeConstraint = new HingeConstraint(btRigidBodyA, btFframeInA, useReferenceFrameA);

            BtWorld.AddConstraint(btHingeConstraint);

            var retval = new HingeConstraintImp();

            retval._hci = btHingeConstraint;
            btHingeConstraint.UserObject = retval;
            return(retval);
        }