Exemplo n.º 1
0
    void Update()
    {
        for (int i = 0; i < boundaries.Length; i++)
        {
            if (!boundaries[i])
            {
                continue;
            }

            if (boundaries[i].bounds.Contains(target.position))
            {
                CameraBoundary cb = boundaries[i].GetComponent <CameraBoundary>();
                if (cb)
                {
                    currentCollider = cb.cameraBoundary;
                    if (confiner.m_BoundingVolume != cb.cameraBoundary)
                    {
                        confiner.m_BoundingVolume = cb.cameraBoundary;
                    }
                }
                else
                {
                    Debug.Log(this + ": Error confiner.m_BoundingVolume missing");
                }
                break;
            }
        }

        if (currentCollider)
        {
            Magnetize(currentCollider);

            /*
             * Debug.Log("col: "+currentCollider);
             * if (currentCollider.bounds.Contains(new Vector3(target.position.x, target.position.y, currentCollider.transform.position.z))){
             * transform.position = target.position;
             * Debug.Log("IN X,Y");
             * }
             * else {
             * if (currentCollider.bounds.Contains(new Vector3(target.position.x, currentCollider.transform.position.y, currentCollider.transform.position.z))){
             *  Debug.Log("IN X");
             *  transform.position = new Vector3(target.position.x, transform.position.y, target.position.z);
             * }
             * if (currentCollider.bounds.Contains(new Vector3(currentCollider.transform.position.x, target.position.y, currentCollider.transform.position.z))){
             *  Debug.Log("IN Y");
             *  transform.position = new Vector3(transform.position.x, target.position.y, target.position.z);
             * }
             * }
             */
        }
    }
Exemplo n.º 2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         this.config.getConfig();
         this.cameraBoundary     = new CameraBoundary(this, this.config.IpCamera);
         this.rangerControlRobot = new RangerControlRobot(this.config.RangerControlPortName);
         this.cameraBoundary.start();
         this.rangerControlRobot.connect();
         this.worker.DoWork             += worker_DoWork;
         this.worker.RunWorkerCompleted += worker_RunWorkerCompleted;
         this.worker.RunWorkerAsync();
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
         this.Close();
     }
 }
Exemplo n.º 3
0
    IEnumerator GenerateSpheres()
    {
        Debug.Log("Generating Camera Space Spheres ...");

        // Find a good sphere size


        // Make sure our bounds have updated positions
        CameraBoundary Bounds = GetComponent <CameraBoundary>();

        Bounds.CalcPositons();

        // Compute how much we move each step between spheres
        float Delta = 2f * (MaxSphereSize - Overlap);

        Debug.Assert(2f * (MinSphereSize - Overlap) > 1f, "Gap between spheres can become very small!");

        // The sum unit offsets between nodes
        Vector3 Offset = new Vector3(Delta, Delta, Delta);

        Debug.Assert(Delta > 0f);

        // Compute our starting and ending sphere positions
        Vector3 StartSpherePos = Bounds.FrontTopLeft;
        Vector3 EndSpherePos   = Bounds.BackBottomRight + 0.5f * Offset;

        Debug.Log("Placing Nodes from " + StartSpherePos + " to " + EndSpherePos);

        // Loop through all space in the camera bounds
        // and plop a sphere node down
        Vector3 CurrentSpherePos = StartSpherePos;

        int id = 0;

        // Loop on X
        for (CurrentSpherePos.x = StartSpherePos.x; // (Redundant)
             CurrentSpherePos.x <= EndSpherePos.x;
             CurrentSpherePos.x += Delta)
        {
            // Loop on Z
            for (CurrentSpherePos.z = StartSpherePos.z;
                 CurrentSpherePos.z <= EndSpherePos.z;
                 CurrentSpherePos.z += Delta)
            {
                // Loop on Y
                for (CurrentSpherePos.y = StartSpherePos.y;
                     CurrentSpherePos.y >= EndSpherePos.y;
                     CurrentSpherePos.y -= Delta) // Note the subtraction here -- we want our spheres to be connected vertically
                {
                    id++;
                    // Debug.Log("Adding node " + " at " + CurrentSpherePos);

                    float Radius = CheckNodeSize(CurrentSpherePos, MaxSphereSize);

                    if (Radius != 0f)
                    {
                        CameraGraphSphereNode Node = InstantiateNode(CurrentSpherePos, id);
                        Node.Radius = Radius;

                        Spheres.Add(Node);

                        if (ShouldOperationYield())
                        {
                            yield return(new WaitForEndOfFrame());
                        }

                        // Compute how much we move each step between spheres
                        Delta = 2f * (Radius - Overlap);
                    }
                }
            }
        }

        Debug.Log("Created " + Spheres.Count + " Spheres");
        yield return(null);
    }