Beispiel #1
0
    IEnumerator ThreadedAssemble()
    {
        int task = ThreadRunner.CreateThread(new System.Threading.ParameterizedThreadStart(ThreadedSphere), (object)SphereDetail);

        ThreadRunner.StartThread(task);

        while (!ThreadRunner.isComplete(task))
        {
            yield return(null);
        }

        ThreadedSimpleMesh myNewMesh = (ThreadedSimpleMesh)ThreadRunner.FetchData(task);

        Mesh newMesh = myNewMesh.GenerateMesh();
        int  verts   = newMesh.vertexCount;

        if (SaveSphere)
        {
            SaveSphere = false;

            AssetDatabase.CreateAsset(newMesh, "Assets/Meshes/IcoSpheres/IcoSphere-D" + SphereDetail + "-v" + verts + ".asset");
        }

        mf.sharedMesh = newMesh;
    }
Beispiel #2
0
    public IEnumerator GetPathTest(Vector3 entry, Vector3 exit)
    {
        // NavPath = null;
        int   task = ThreadedNavigator.GetPath(entry, exit);
        float time = Time.realtimeSinceStartup;

        while (!ThreadRunner.isComplete(task))
        {
            Debug.Log("Waiting for nav thread to complete...");
            yield return(null);
        }

        List <Vector3> myPath = (List <Vector3>)ThreadRunner.FetchData(task);

        // NavPath = myPath;



        if (myPath == null)
        {
            Debug.Log("No path found.");
        }
        else
        {
            Debug.Log("Path length: " + myPath.Count);

            for (int i = 0; i < myPath.Count - 1; i++)
            {
                Debug.DrawLine(myPath[i], myPath[i + 1], Color.magenta, 5f);
            }
        }
        Debug.Log("Took " + (Time.realtimeSinceStartup - time) + "s to generate.");
    }
Beispiel #3
0
    IEnumerator ThreadedAssemble()
    {
        if (mr == null)
        {
            mr = GetComponent <MeshRenderer>();
        }
        if (mr == null)
        {
            Debug.Log("BadScalingSphere: no MR"); yield break;
        }
        if (mf == null)
        {
            mf = GetComponent <MeshFilter>();
        }
        if (mf == null)
        {
            Debug.Log("BadScalingSphere: no MF"); yield break;
        }


        int task = ThreadRunner.CreateThread(new System.Threading.ParameterizedThreadStart(ThreadedSphere), (object)SphereDetail);

        ThreadRunner.StartThread(task);

        while (!ThreadRunner.isComplete(task))
        {
            yield return(null);
        }

        ThreadedSimpleMesh myNewMesh = (ThreadedSimpleMesh)ThreadRunner.FetchData(task);

        Mesh newMesh = myNewMesh.GenerateMesh();

        int poly = newMesh.triangles.GetLength(0) / 3;

        AssetDatabase.CreateAsset(newMesh, "Assets/Exported/ScalingSphere-" + SphereRadius + "m-" + poly + "v.asset");
        Debug.Log("[GENERATEPYRAMID] Exported mesh: /Assets/Exported/ScalingSphere-" + SphereRadius + "m-" + poly + "v.asset");

        mf.sharedMesh = newMesh;
    }
    IEnumerator GetPath(Vector3 entry, Vector3 exit)
    {
        NavPath = null;
        int task = ThreadedNavigator.GetPath(entry, exit);

        while (!ThreadRunner.isComplete(task))
        {
            // Debug.Log("Waiting for nav thread to complete...");
            yield return(null);
        }

        List <Vector3> myPath = (List <Vector3>)ThreadRunner.FetchData(task);

        NavPath = myPath;

        if (myPath == null)
        {
            Debug.Log("No path found.");
        }
        else
        {
            Debug.Log("Path length: " + myPath.Count);
        }
    }