Inheritance: PathPoint
 public Quaternion GetRotAt(float p)
 {
     if (shapePath != null)
     {
         PathVector pv  = shapePath.getPathInfo(p);
         Quaternion rot = pv.rot;
         return(rot);
     }
     else
     {
         return(Quaternion.identity);
     }
 }
Example #2
0
    public Vector3 getPointInfoVec3(float targetLength)
    {
        PathVector pVec = getPointInfo(targetLength);

        if (pVec == null)
        {
            Debug.LogWarning("PathVector is null");
            return(Vector3.zero);
        }
        else
        {
            return(new Vector3(pVec.x, pVec.y, pVec.z));
        }
    }
    // Update is called once per frame
    void OnDrawGizmos()
    {
        if (points == null || points.Count < 1)
        {
            return;
        }

        // ShapePath
        pointList = new PointList();

        // ShapePath
        if (pointList != null)
        {
            shapePath = pointList.GetShapePath(points.ToArray(), rots.ToArray());

            for (int i = 0; i < num; i++)
            {
                float v = (float)i / num;

                Vector3 pt;
//				pt = shapePath.getPointInfoVec3Percent(v);
                PathVector pv = shapePath.getPathInfo(v);
                pt = new Vector3(pv.x, pv.y, pv.z);

                Gizmos.color = color;
                Gizmos.DrawWireSphere(pt, 0.25f);

                Quaternion rot = pv.rot;

                //
                Gizmos.color = new Color(0, 0, 0, 0.25f);
                Gizmos.DrawRay(pt, rot * Vector3.up * 2);
                Gizmos.DrawRay(pt, rot * Vector3.right * 2);

                Quaternion q2 = GetQuaternionAt(v);
                Gizmos.color = Color.green;
                Gizmos.DrawRay(pt, q2 * Vector3.up);
                Gizmos.color = Color.red;
                Gizmos.DrawRay(pt, q2 * Vector3.right);
            }
        }
    }
Example #4
0
        public static void FindPaths(this List<LinkedList<PathVector>> allPaths, PathVector endPoint, PathVector position, LinkedList<PathVector> pathVectors, int[,] labyrinth)
        {
            if (labyrinth[position.Y, position.X] != Empty)
            {
                return;
            }

            labyrinth[position.Y, position.X] = Visited;
            pathVectors.AddLast((PathVector)position.Clone());

            if (position.CompareTo(endPoint) == 0)
            {
                allPaths.Add(new LinkedList<PathVector>(pathVectors));
            }
            else
            {
                foreach (var path in Paths)
                {
                    if (IsPathInRange(
                        position.Y + path.Y,
                        position.X + path.X,
                        labyrinth.GetLength(0),
                        labyrinth.GetLength(1)))
                    {
                        allPaths.FindPaths(
                            endPoint,
                            new PathVector()
                            {
                                Y = position.Y + path.Y,
                                X = position.X + path.X
                            },
                            pathVectors,
                            labyrinth);
                    }
                }
            }

            pathVectors.RemoveLast();
            labyrinth[position.Y, position.X] = Empty;
        }