예제 #1
0
        /// <summary>
        /// Retrieves a joint location for a particular timestamp; in joint-local coordinates
        /// </summary>
        public SSSkeletalJointLocation computeJointFrame(int jointIdx, float t)
        {
            int leftFrameIdx = (int)(t / frameDuration);
            SSSkeletalJointLocation leftJointFrame = _frames [leftFrameIdx] [jointIdx];
            float remainder = t - ((float)leftFrameIdx * frameDuration);

            if (remainder == 0)
            {
                return(leftJointFrame);
            }
            else
            {
                SSSkeletalJointLocation rightJointFrame = _frames [leftFrameIdx + 1] [jointIdx];
                return(SSSkeletalJointLocation.interpolate(
                           leftJointFrame, rightJointFrame, remainder / frameDuration));
            }
        }
 public SSSkeletalJointLocation computeJointFrame(int jointIdx)
 {
     if (_currAnimation != null)
     {
         var loc = _currAnimation.computeJointFrame(jointIdx, _currT);
         if (_prevAnimation == null)
         {
             //GL.Color3 (1f, 0f, 0f);
             return(loc);
         }
         else
         {
             var prevTime = Math.Min(_prevT, _prevAnimation.totalDuration);
             var prevLoc  = _prevAnimation.computeJointFrame(jointIdx, prevTime);
                                     #if PREV_PREV_FADE
             if (_prevPrevAnimation != null)
             {
                 var prevPrevLoc = _prevPrevAnimation.ComputeJointFrame(jointIdx, _prevPrevT);
                 var prevFade    = _prevT / _prevTransitionTime;
                 prevLoc = SSSkeletalJointLocation.Interpolate(prevPrevLoc, prevLoc, prevFade);
             }
                                     #endif
             var fadeInRatio = _currT / _transitionTime;
             GL.Color3(fadeInRatio, 1f - fadeInRatio, 0);
             return(SSSkeletalJointLocation.interpolate(prevLoc, loc, fadeInRatio));
         }
     }
     else if (_prevAnimation != null)
     {
         //GL.Color3 (0f, 1f, 0f);
         return(_prevAnimation.computeJointFrame(jointIdx, _prevT));
     }
     else
     {
         var errMsg = "Attempting to compute a joint frame location from an inactive channel.";
         System.Console.WriteLine(errMsg);
         throw new Exception(errMsg);
     }
 }
예제 #3
0
        private SSSkeletalJointLocation _computeJointLocWithControllers(
            SSSkeletalJointRuntime joint, List <SSSkeletalChannelController> controllers, int controllerIdx)
        {
            var channel = controllers [controllerIdx];

            if (channel.isActive(joint))
            {
                var channelLoc = channel.computeJointLocation(joint);
                if (joint.parent != null)
                {
                    channelLoc.applyPrecedingTransform(joint.parent.currentLocation);
                }
                if (!channel.interChannelFade ||
                    channel.interChannelFadeIndentisy() >= 1f ||
                    controllerIdx == 0)
                {
                    return(channelLoc);
                }
                else
                {
                    var fallbackLoc
                        = _computeJointLocWithControllers(joint, controllers, controllerIdx - 1);
                    return(SSSkeletalJointLocation.interpolate(
                               fallbackLoc, channelLoc, channel.interChannelFadeIndentisy()));
                }
            }
            else
            {
                if (controllerIdx > 0)
                {
                    return(_computeJointLocWithControllers(joint, controllers, controllerIdx - 1));
                }
                else
                {
                    throw new Exception("fell through without an active skeletal channel controller");
                }
            }
        }