//--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="NoRotationConstraint"/> class.
 /// </summary>
 public NoRotationConstraint()
 {
     _angularLimit = new AngularLimit
       {
     Minimum = new Vector3F(0, 0, 0),
     Maximum = new Vector3F(0, 0, 0),
       };
 }
Example #2
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="NoRotationConstraint"/> class.
        /// </summary>
        public NoRotationConstraint()
        {
            _angularLimit = new AngularLimit
            {
                Minimum = new Vector3F(0, 0, 0),
                Maximum = new Vector3F(0, 0, 0),
            };
        }
Example #3
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="PrismaticJoint"/> class.
        /// </summary>
        public PrismaticJoint()
        {
            _linearLimit = new LinearLimit
            {
                Minimum = new Vector3F(float.NegativeInfinity, 0, 0),
                Maximum = new Vector3F(float.PositiveInfinity, 0, 0),
            };
            _angularLimit = new AngularLimit
            {
                Minimum = new Vector3F(0, 0, 0),
                Maximum = new Vector3F(0, 0, 0),
            };
        }
Example #4
0
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="PrismaticJoint"/> class.
 /// </summary>
 public PrismaticJoint()
 {
     _linearLimit = new LinearLimit
       {
     Minimum = new Vector3F(float.NegativeInfinity, 0, 0),
     Maximum = new Vector3F(float.PositiveInfinity, 0, 0),
       };
       _angularLimit = new AngularLimit
       {
     Minimum = new Vector3F(0, 0, 0),
     Maximum = new Vector3F(0, 0, 0),
       };
 }
Example #5
0
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedJoint"/> class.
 /// </summary>
 public FixedJoint()
 {
     _linearLimit = new LinearLimit
       {
     Minimum = new Vector3F(0, 0, 0),
     Maximum = new Vector3F(0, 0, 0),
       };
       _angularLimit = new AngularLimit
       {
     Minimum = new Vector3F(0, 0, 0),
     Maximum = new Vector3F(0, 0, 0),
       };
 }
Example #6
0
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="Hinge2Joint"/> class.
 /// </summary>
 public Hinge2Joint()
 {
     _linearLimit = new LinearLimit
       {
     Minimum = new Vector3F(0, 0, 0),
     Maximum = new Vector3F(0, 0, 0),
       };
       _angularLimit = new AngularLimit
       {
     Minimum = new Vector3F(-ConstantsF.PiOver4, 0, float.NegativeInfinity),
     Maximum = new Vector3F(ConstantsF.PiOver4, 0, float.PositiveInfinity),
       };
 }
Example #7
0
        //public float RelativePosition
        //{
        //  get { return _angularLimit.RelativePosition.X; }
        //}
        #endregion


        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="Hinge2Joint"/> class.
        /// </summary>
        public Hinge2Joint()
        {
            _linearLimit = new LinearLimit
            {
                Minimum = new Vector3F(0, 0, 0),
                Maximum = new Vector3F(0, 0, 0),
            };
            _angularLimit = new AngularLimit
            {
                Minimum = new Vector3F(-ConstantsF.PiOver4, 0, float.NegativeInfinity),
                Maximum = new Vector3F(ConstantsF.PiOver4, 0, float.PositiveInfinity),
            };
        }
Example #8
0
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="UniversalJoint"/> class.
 /// </summary>
 public UniversalJoint()
 {
     _linearLimit = new LinearLimit
       {
     Minimum = new Vector3F(0, 0, 0),
     Maximum = new Vector3F(0, 0, 0),
       };
       _angularLimit = new AngularLimit
       {
     Minimum = new Vector3F(-ConstantsF.PiOver4, 0, -ConstantsF.PiOver4),
     Maximum = new Vector3F(ConstantsF.PiOver4, 0, ConstantsF.PiOver4),
       };
 }
Example #9
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="FixedJoint"/> class.
        /// </summary>
        public FixedJoint()
        {
            _linearLimit = new LinearLimit
            {
                Minimum = new Vector3F(0, 0, 0),
                Maximum = new Vector3F(0, 0, 0),
            };
            _angularLimit = new AngularLimit
            {
                Minimum = new Vector3F(0, 0, 0),
                Maximum = new Vector3F(0, 0, 0),
            };
        }
Example #10
0
        //public float RelativePosition
        //{
        //  get { return _angularLimit.RelativePosition.X; }
        //}
        #endregion


        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="UniversalJoint"/> class.
        /// </summary>
        public UniversalJoint()
        {
            _linearLimit = new LinearLimit
            {
                Minimum = new Vector3F(0, 0, 0),
                Maximum = new Vector3F(0, 0, 0),
            };
            _angularLimit = new AngularLimit
            {
                Minimum = new Vector3F(-ConstantsF.PiOver4, 0, -ConstantsF.PiOver4),
                Maximum = new Vector3F(ConstantsF.PiOver4, 0, ConstantsF.PiOver4),
            };
        }
        /// <summary>
        /// Adds an AngularLimit between the specified bones.
        /// </summary>
        /// <param name="skeletonPose">The skeleton pose.</param>
        /// <param name="ragdoll">The ragdoll.</param>
        /// <param name="parent">The parent bone.</param>
        /// <param name="child">The childbone .</param>
        /// <param name="minimum">The minimum limits for each constraint axis (x/y/z).</param>
        /// <param name="maximum">The maximum limits for each constraint axis (x/y/z).</param>
        /// <remarks>
        /// The constraint anchor orientation is the orientation of the child bone.
        /// </remarks>
        private static void AddAngularLimit(SkeletonPose skeletonPose, Ragdoll ragdoll, int parent, int child, Vector3F minimum, Vector3F maximum)
        {
            var skeleton = skeletonPose.Skeleton;
              var childBody = ragdoll.Bodies[child];
              var childOffset = ragdoll.BodyOffsets[child];
              var parentBody = ragdoll.Bodies[parent];
              var parentOffset = ragdoll.BodyOffsets[parent];

              var parentBindPoseAbsolute = (Pose)skeleton.GetBindPoseAbsoluteInverse(parent).Inverse;
              var childBindPoseAbsolute = (Pose)skeleton.GetBindPoseAbsoluteInverse(child).Inverse;
              var bindPoseRelative = parentBindPoseAbsolute.Inverse * childBindPoseAbsolute;

              var limit = new AngularLimit
              {
            BodyA = parentBody,
            BodyB = childBody,
            AnchorOrientationALocal = parentOffset.Orientation.Transposed * bindPoseRelative.Orientation,
            AnchorOrientationBLocal = childOffset.Orientation.Transposed,
            Minimum = minimum,
            Maximum = maximum,
            ErrorReduction = new Vector3F(0.2f),
            Softness = new Vector3F(0.001f)
              };
              ragdoll.Limits.Add(limit);
        }
Example #12
0
        private static void DrawAngularLimit(BallJoint joint, AngularLimit limit)
        {
            Vector3F jointPosition = joint.BodyA.Pose.ToWorldPosition(joint.AnchorPositionALocal);

              // A transformation that converts from constraint anchor space to world space.
              Pose constraintToWorld = limit.BodyA.Pose * new Pose(limit.AnchorOrientationALocal);

              // Draw an arc for each rotation axis.
              DrawArc(constraintToWorld, jointPosition, Vector3F.UnitX, Vector3F.UnitY, limit.Minimum.X, limit.Maximum.X, Color.Red);
              DrawArc(constraintToWorld, jointPosition, Vector3F.UnitY, Vector3F.UnitX, limit.Minimum.Y, limit.Maximum.Y, Color.Green);
              DrawArc(constraintToWorld, jointPosition, Vector3F.UnitZ, Vector3F.UnitX, limit.Minimum.Z, limit.Maximum.Z, Color.Blue);
        }
Example #13
0
        private static void AddAngularLimit(Ragdoll ragdoll, Skeleton skeleton, AvatarBone parentBone, AvatarBone childBone, Matrix33F orientationA, Matrix33F orientationB, Vector3F minimum, Vector3F maximum)
        {
            // Similar to AddTwistSwingLimit

              int parentIndex = (int)parentBone;
              int childIndex = (int)childBone;

              var limit = new AngularLimit
              {
            BodyA = ragdoll.Bodies[parentIndex],
            BodyB = ragdoll.Bodies[childIndex],
            AnchorOrientationALocal = ragdoll.BodyOffsets[parentIndex].Orientation.Transposed * skeleton.GetBindPoseAbsoluteInverse(parentIndex).Rotation.ToRotationMatrix33() * orientationA,
            AnchorOrientationBLocal = ragdoll.BodyOffsets[childIndex].Orientation.Transposed * skeleton.GetBindPoseAbsoluteInverse(childIndex).Rotation.ToRotationMatrix33() * orientationB,
            Minimum = minimum,
            Maximum = maximum,
            ErrorReduction = new Vector3F(0.2f),
            Softness = new Vector3F(0.001f)
              };
              ragdoll.Limits[childIndex] = limit;
        }