Example #1
0
        public static void SetPathControlPoints(ARAPDeformation arap)
        {
            if (arap == null)
            {
                return;
            }

            arap.ClearControlPoints();

            var path = arap.GetPath();

            if (path == null)
            {
                return;
            }

            for (int i = 0; i < path.Count; i++)
            {
                arap.AddControlPoint(arap.meshPointList[i], arap.orgMeshPointList[i]);
            }
        }
Example #2
0
        public static void SetSkeletalControlPoints(ARAPDeformation arap, SkeletonAnnotation an, int linearSpan, Dictionary <BoneAnnotation, List <PointF> > boneToControls)
        {
            if (arap == null)
            {
                return;
            }

            boneToControls.Clear();
            arap.ClearControlPoints();

            // ボーン沿いに制御点を追加
            HashSet <PointF> pts = new HashSet <PointF>();

            if (an != null && linearSpan >= 1)
            {
                foreach (var b in an.bones)
                {
                    PointF p0    = b.src.position;
                    PointF p1    = b.dst.position;
                    float  dist  = FMath.Distance(p0, p1);
                    int    ptNum = Math.Max(2, (int)(dist / linearSpan) + 1);

                    boneToControls[b] = new List <PointF>();

                    for (int i = 0; i < ptNum; i++)
                    {
                        float  t = (float)i / (ptNum - 1);
                        PointF p = i == 0 ? p0 : i == ptNum - 1 ? p1 : FMath.Interpolate(p0, p1, t);
                        if (!pts.Contains(p))
                        {
                            arap.AddControlPoint(p, p);
                        }
                        boneToControls[b].Add(p);
                        pts.Add(p);
                    }
                }
            }
        }