Exemplo n.º 1
0
//	private float turnSpeed = 10000;

//	private bool onePoint = true;
//	private bool twoPoint = true;

    private void inizializeTree(Vector3 source, Vector3 dest)
    {
        tree = new rrDubinTree();
        rrtNode node = new rrtNode(source, null);

        node.forward = transform.forward;
        tree.addNode(node);
    }
Exemplo n.º 2
0
    private bool addRandomNode(rrDubinTree tree, int dim)
    {
        Vector3 newPoint = new Vector3(myRnd(dim), y, myRnd(dim));

        createPoint(newPoint);

        rrtNode   point     = tree.findClosestNode(newPoint);
        ArrayList dubinConn = freePath(point.point, newPoint);

        if (point != null && dubinConn.Count > 0)
        {
            //if it is possible to reach the point from the previous point
            //add the connection
            rrtNode p2 = new rrtNode(newPoint, point);
            //p2.connection = dubinConn;
            tree.addNode(p2);
            //myDrawLine (point.point, newPoint, Color.blue);
            return(true);
        }
        return(true);
    }
Exemplo n.º 3
0
    private bool addRandomNode(rrDubinTree tree, int dimX, int dimZ)
    {
        Vector3 newPoint = new Vector3(myRnd(dimX), mainY, myRnd(dimZ));

        draw.drawLine(newPoint, new Vector3(newPoint.x + 1, newPoint.y, newPoint.z + 1), Color.green);

        rrtNode   point    = tree.findClosestNode(newPoint);
        ArrayList dubinWay = freeCarPath(point.point, point.forward, newPoint);

        if (point != null && dubinWay.Count > 0)
        {
            //if it is possible to reach the point from the previous point
            //add the connection
            rrtNode p2 = new rrtNode(newPoint, point);
            p2.forward = ((Vector3)dubinWay[dubinWay.Count - 1] - (Vector3)dubinWay[dubinWay.Count - 2]).normalized;
            //conn.Reverse();
            p2.connection = dubinWay;
            tree.addNode(p2);
            draw.drawMultipleLines(p2.connection, Color.magenta);
            return(true);
        }
        return(true);
    }
Exemplo n.º 4
0
 private void moveKinematic()
 {
     if (Input.GetMouseButtonDown(0))
     {
         destination   = DirectionUtility.getMouseDirection();
         destination.y = transform.position.y;
         //go = true;
         calculating = true;
         tree        = new rrDubinTree();
         tree.addNode(new rrtNode(transform.position, null));
         draw.clean();
     }
     else
     {
         if (go && path.Count > 0)
         {
             destination = (Vector3)path[path_index];
             float d = Vector3.Distance(transform.position, destination);
             if (d > 0.5)
             {
                 Vector3 direction = (destination - transform.position).normalized;
                 DirectionUtility.makeKinematicMove(rigidbody, direction, speed);
             }
             else
             {
                 rigidbody.velocity = Vector3.zero;
                 transform.position = destination;
                 path_index++;
                 if (path_index == path.Count)
                 {
                     go = false; path_index = 0;
                 }
             }
         }
     }
 }