Ejemplo n.º 1
0
        /// <summary> Fills the ref-argument VectorHand with interpolated data
        /// between the 4 other VectorHands, by t (unclamped), and return true.
        /// If either a, b, c or d is null, the ref-argument VectorHand is also set to
        /// null, and the method returns false.
        /// An exception is thrown if the interpolation arguments a and b don't
        /// have the same chirality.
        /// </summary>
        public bool FillSplined(VectorHand a, VectorHand b, VectorHand c, VectorHand d, float t)
        {
            if (a == null || b == null || c == null || d == null)
            {
                return(false);
            }
            if (b.isLeft != c.isLeft)
            {
                throw new System.Exception("VectorHands must be interpolated with the " +
                                           "same chirality.");
            }
            isLeft  = a.isLeft;
            palmPos = CatmullRom.ToCHS(
                a.palmPos, b.palmPos, c.palmPos, d.palmPos, false).PositionAt(t);
            palmRot = Quaternion.SlerpUnclamped(b.palmRot, c.palmRot, t);
            //Quaternion splines are not as robust
            //CatmullRom.ToQuaternionCHS(
            //  a.palmRot, b.palmRot, c.palmRot, d.palmRot, false).RotationAt(t);

            for (int i = 0; i < jointPositions.Length; i++)
            {
                jointPositions[i] = CatmullRom.ToCHS(
                    a.jointPositions[i],
                    b.jointPositions[i],
                    c.jointPositions[i],
                    d.jointPositions[i], false).PositionAt(t);
            }
            return(true);
        }
Ejemplo n.º 2
0
 public bool FillSplined(Pose a, Pose b, Pose c, Pose d, float t)
 {
     position = CatmullRom.ToCHS(a.position, b.position, c.position, d.position,
                                 centripetal: false).PositionAt(t);
     rotation = Quaternion.SlerpUnclamped(b.rotation, c.rotation, t);
     return(true);
 }