/// <summary> /// Initializes a new instance of the <see cref="XTerrainChunk"/> class. /// </summary> /// <param name="setting">Setting.</param> /// <param name="noise">Noise.</param> /// <param name="x">The x coordinate.</param> /// <param name="z">The z coordinate.</param> public XTerrainChunk(XTerrainChunkSetting setting, XNoise noise, int x, int z) { HeightmapThread = new object(); Setting = setting; NoiseProvider = noise; Neighborhood = new XChunkNeighborhood(); Position = new XVec2I(x, z); TreePoint = new List <Vector3>(); ChopPoint = new List <Vector3>(); }
/// <summary> /// Generates the chunk. /// </summary> /// <param name="x">The x coordinate.</param> /// <param name="z">The z coordinate.</param> private void GenerateChunk(int x, int z) { if (Cache.ChunkCanBeAdded(x, z)) { XNoise noise = null; if (NoiseType == XNoiseType.NT_NONE) { noise = NoiseProvider; } else if (NoiseType == XNoiseType.NT_PERLIN) { noise = new XNoisePerlin(); if (x > 0) { int offset = (noise.bottom - noise.top) * x; noise.top = noise.top + offset; noise.bottom = noise.bottom + offset; } else { int offset = (noise.bottom - noise.top) * x; noise.top = noise.top + offset; noise.bottom = noise.bottom + offset; } if (z > 0) { int offset = (noise.right - noise.left) * z; noise.left = noise.left + offset; noise.right = noise.right + offset; } else { int offset = (noise.right - noise.left) * z; noise.left = noise.left + offset; noise.right = noise.right + offset; } } var chunk = new XTerrainChunk(Settings, noise, x, z); Cache.AddNewChunk(chunk); } }
/// <summary> /// Inits the generate. /// </summary> public void InitGenerate() { Settings = new XTerrainChunkSetting(HeightmapResolution, AlphamapResolution, Length, Height, TerrainMaterial, Textures, Trees); NoiseProvider = new XNoiseDefault(); Cache = new XTerrainChunkCache(); }