/// <summary> /// Initializes the chunk file, chunk generation thread and initializes all needed variables. /// </summary> public void Start() { // Make sure we are at 0|0|0 this.transform.position = new Vector3(0, 0, 0); // Singleton if (instance != null) { Debug.LogError("Multiple CubicTerrain Script GameObject detected! Error! Disabling this instance."); this.enabled = false; return; } instance = this; // Terrain stream? if (this.serializeTerrain) { this.terrainFile = new CubicTerrainFile(this.chunkFilesPath + "table.clt", this.chunkFilesPath + "data.cfd"); } // Initialize lists this.chunkObjects = new List3D <GameObject> (); this.chunkData = new List3D <CubicTerrainData> (); this.generationJobs = new List3D <ChunkGenerationJob> (); this.terrainGenerator = this.GetComponent <ATerrainGenerator> (); this.chunkGenerationThread = new Thread(this.ChunkGenerationThread); this.chunkGenerationThread.Start(); // Init this.terrainMaterial.SetTexture("_MainTex", Blocks.textureAtlas); this.transparentTerrainMaterial.SetTexture("_MainTex", Blocks.textureAtlas); if (!this.loadPlayerChunkFirst) { return; } Vector3 chunkPosition = this.GetChunkPosition(this.playerTransform.position); this.GenerateChunk((int)chunkPosition.x, (int)chunkPosition.z); this.transformPosition = this.transform.position; }
/// <summary> /// Initializes the chunk file, chunk generation thread and initializes all needed variables. /// </summary> public void Start() { // Make sure we are at 0|0|0 this.transform.position = new Vector3 (0, 0, 0); // Singleton if (instance != null) { Debug.LogError ("Multiple CubicTerrain Script GameObject detected! Error! Disabling this instance."); this.enabled = false; return; } instance = this; // Terrain stream? if (this.serializeTerrain) this.terrainFile = new CubicTerrainFile(this.chunkFilesPath+"table.clt", this.chunkFilesPath+"data.cfd"); // Initialize lists this.chunkObjects = new List3D<GameObject> (); this.chunkData = new List3D<CubicTerrainData> (); this.generationJobs = new List3D<ChunkGenerationJob> (); this.terrainGenerator = this.GetComponent<ATerrainGenerator> (); this.chunkGenerationThread = new Thread (this.ChunkGenerationThread); this.chunkGenerationThread.Start (); // Init this.terrainMaterial.SetTexture ("_MainTex", Blocks.textureAtlas); this.transparentTerrainMaterial.SetTexture ("_MainTex", Blocks.textureAtlas); if (!this.loadPlayerChunkFirst) return; Vector3 chunkPosition = this.GetChunkPosition(this.playerTransform.position); this.GenerateChunk((int)chunkPosition.x,(int)chunkPosition.z); this.transformPosition = this.transform.position; }