void OnCsvParsed(object data) { csvParsedCount++; if (csvParsedCount == 3) { Debug.Log("Generating map vectors..."); ThreadDataRequester.RequestData(() => { GetMapVectors(); return(true); }, OnMapVectorsGenerated); } }
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); }
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); }
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(); }
public void RequestMesh(HeightMap heightMap, MeshSettings meshSettings) { hasRequestedMesh = true; ThreadDataRequester.RequestData(() => MeshGenerator.GenerateTerrainMesh(heightMap.values, lod, meshSettings), OnMeshDataReceived); }
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); }
private void Awake() { instance = FindObjectOfType <ThreadDataRequester>(); }
void Awake() { instance = this; }