Esempio n. 1
0
 void OnCsvParsed(object data)
 {
     csvParsedCount++;
     if (csvParsedCount == 3)
     {
         Debug.Log("Generating map vectors...");
         ThreadDataRequester.RequestData(() => {
             GetMapVectors();
             return(true);
         }, OnMapVectorsGenerated);
     }
 }
Esempio n. 2
0
 public void CalculateMap()
 {
     Debug.Log("Parsing CSV files...");
     ThreadDataRequester.RequestData(() => {
         ParseCSV("Assets/Data/Xkrig.csv", out xData);
         return(true);
     }, OnCsvParsed);
     ThreadDataRequester.RequestData(() => {
         ParseCSV("Assets/Data/Ykrig.csv", out yData);
         return(true);
     }, OnCsvParsed);
     ThreadDataRequester.RequestData(() => {
         ParseCSV("Assets/Data/Zhat.csv", out zData);
         return(true);
     }, OnCsvParsed);
 }
Esempio n. 3
0
    void OnMapVectorsGenerated(object data)
    {
        int xLength    = mapVectors.GetLength(0);
        int yLength    = mapVectors.GetLength(1);
        int xMeshCount = xLength / meshSize;
        int yMeshCount = yLength / meshSize;

        Mesh[,] meshes = new Mesh[xMeshCount, yMeshCount];
        for (int xMesh = 0; xMesh < meshes.GetLength(0); xMesh++)
        {
            for (int yMesh = 0; yMesh < meshes.GetLength(1); yMesh++)
            {
                meshes[xMesh, yMesh] = new Mesh();
            }
        }
        Debug.Log("Generating " + (xMeshCount * yMeshCount) + " meshes...");
        ThreadDataRequester.RequestData(() => {
            GenerateMesh(mapVectors);
            return(true);
        }, OnMeshesGenerated);
    }
Esempio n. 4
0
    public void ClearGeneratedData()
    {
        ThreadDataRequester.ClearDataQueue();

        foreach (TerrainChunk chunk in terrainChunkDictionary.Values)
        {
            chunk.ClearAll();
        }

        terrainChunkDictionary.Clear();
        visibleTerrainChunks.Clear();

        // Delete Earlier Chunks
        for (int i = transform.childCount - 1; i >= 0; i--)
        {
            Transform chunkTransform = transform.GetChild(i);
            GameObject.Destroy(chunkTransform.gameObject);
        }

        //// Call garbage collector
        System.GC.Collect();
    }
Esempio n. 5
0
 public void RequestMesh(HeightMap heightMap, MeshSettings meshSettings)
 {
     hasRequestedMesh = true;
     ThreadDataRequester.RequestData(() => MeshGenerator.GenerateTerrainMesh(heightMap.values, lod, meshSettings), OnMeshDataReceived);
 }
Esempio n. 6
0
 public void Load()
 {
     // Add request for data in mapGenererator and create a thread
     // Lamda expression required because parameters cannot be passed
     ThreadDataRequester.RequestData(() => HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMapSettings, sampleCenter), OnHeightMapReceived);
 }
Esempio n. 7
0
 private void Awake()
 {
     instance = FindObjectOfType <ThreadDataRequester>();
 }
 void Awake()
 {
     instance = this;
 }