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