Beispiel #1
0
        // todo: make smarter, should use driveways of buildings of void paths
        private void updateApproachRoute(Sequence <PathDescription> pathSequence)
        {
            Vector3 start, startTangent, end, endTangent;

            var startTransform = CurrentTransform;

            start        = startTransform.MultiplyPoint3x4(Vector3.zero);
            startTangent = startTransform.MultiplyVector(Vector3.forward);

            var pathDesc = pathSequence[0];
            var path     = pathDesc.Path;

            path.LoftPath.SnapTo(start, out end, out var distance);
            var approachProgress = path.GetDistanceFromLoftPath(distance);


            var transform = path.GetTransform(approachProgress);

            pathSequence[0] = new PathDescription(path, approachProgress / path.GetLength(), 1);

            endTangent = -transform.MultiplyVector(Vector3.forward);


            var loft = new BiArcLoftPath(start, startTangent, end, endTangent);

            var approachPath = new AgentAIPath(loft);

            var descr = new PathDescription(Path: approachPath, Start: 0, End: 1);

            pathSequence.Insert(0, descr);
        }
Beispiel #2
0
        // todo: make smarter, should use driveways of buildings instead of void paths
        private void updateDepartRoute(Sequence <PathDescription> pathSequence)
        {
            Vector3 start, startTangent, end, endTangent;


            var index    = pathSequence.Count - 1;
            var pathDesc = pathSequence[index];
            var path     = pathDesc.Path;

            path.LoftPath.SnapTo(Destination, out start, out var distance);

            var departProgress = path.GetDistanceFromLoftPath(distance);

            var endProgress = departProgress / path.GetLength();

            pathSequence[index] = new PathDescription(path, 0, endProgress);

            end = Destination;

            startTangent = -path.GetTransform(departProgress).MultiplyVector(Vector3.forward);

            endTangent = (start - end).normalized;

            var loft = new BiArcLoftPath(start, startTangent, end, endTangent);

            var departPath = new AgentAIPath(loft);

            var desc = new PathDescription(departPath, 0, 1);

            pathSequence.Add(desc);
        }