Beispiel #1
0
        public PathPos MovePositionAlongPath(float targetDist)
        {
            // returns the position on the path after moving "target" units along the path
            float dst = 0;
            int   i   = 0;
            float lmd = 0;
            var   p1  = start.pt;
            var   p2  = p1;

            foreach (var w in waypts)
            {
                p2 = w.toNode.pt;
                //GraphUtil.Log("mpp i:" + i + "  p1wc:" + p1wc + "  p2wc:" + p2wc);
                var ndst = dst + w.distance;
                if (ndst > targetDist)
                {
                    lmd = (targetDist - dst) / w.distance;
                    var pt = lmd * (p2 - p1) + p1;
                    //GraphUtil.Log("mpp i:" + i + " lmd:" + lmd + "ptwc:"+ptwc);
                    var pp1 = new PathPos(this, pt, w, i, lmd);
                    return(pp1);
                }
                dst = ndst;
                p1  = p2;
                i++;
            }
            // Edge cases - at start and end of path
            PathPos pp2;
            var     wcnt = waypts.Count;

            if (wcnt == 0)
            {
                // at the start
                pp2 = new PathPos(this, p2, null, wcnt - 1, 1);
            }
            else
            {
                // at the end
                var ww = waypts[wcnt - 1];
                pp2 = new PathPos(this, p2, ww, wcnt - 1, 1);
            }
            return(pp2);
        }
Beispiel #2
0
 public LcNode PunchNewLinkPt(PathPos pp, string newptname = "", bool deleteparentlink = false)
 {
     return(PunchNewLinkPt(pp.weg.link, pp.pt, newptname: newptname, deleteparentlink: deleteparentlink));
 }