public float TrajectoryCost(AnimNode.AnimationClip anim, MatchingGoal goal, ref Pose.CGfxSkeletonPose pose)
        {
            var   duration = anim.Duration;
            var   count    = Math.Min(anim.Duration / 25, goal.Trajectory.Count);
            var   skeleton = CEngine.Instance.SkeletonAssetManager.GetSkeleton(CEngine.Instance.RenderContext, RName.GetRName(anim.GetElementProperty(ElementPropertyType.EPT_Skeleton)));
            float cost     = 0;

            for (int i = 0; i < count; ++i)
            {
                Skeleton.CGfxMotionState data = new Skeleton.CGfxMotionState();
                //anim.GetMotionData(i * 25, pose.Root.BoneDesc.NameHash, ref data);
                var p = data.Position;
                p.Y = 0;
                var hostLoc = goal.HostPlacement.Location;
                hostLoc.Y = goal.Trajectory[i].Y;
                cost     += (goal.HostPlacement.Rotation * p + hostLoc - goal.Trajectory[i]).Length();
                //if(i + 1 >= goal.Trajectory.Length)
                //{
                //    cost += data.Velocity.Length();
                //}
                //else
                //    cost += (goal.HostPlacement.Rotation * data.Velocity - (goal.Trajectory[i + 1] - goal.Trajectory[i]) / 25 * 1000.0f).Length();
            }

            return(cost);
        }
示例#2
0
        public static MotionPose CreateMotionPose(AnimNode.AnimationClip clip, long frameTime)
        {
            Pose.CGfxSkeletonPose animationPose = clip.GetAnimationSkeletonPose(frameTime);
            MotionPose            motionPose    = new MotionPose(clip.Name.GetHashCode(), frameTime, animationPose);

            motionPose.CalculateTrajectory(clip);
            return(motionPose);
        }