public override void BuildWorldChunk(WorldData world, Chunk chunk) { IntVec3 size = world.ChunkSizeBlocks; for (int x = 0; x < size.x; x++) { for (int z = 0; z < size.z; z++) { int height = Random.Range(1, 10); for (int y = 0; y < height; y++) { world.SetBlock( x + chunk.WorldPos.x, y + chunk.WorldPos.y, z + chunk.WorldPos.z, m_SolidBlock); } } } }
private float[,] m_HeightField; // heightfield for landscape // Initialise the worldbuilder by creating a heightfield public override void Init(WorldData world) { m_HeightField = new float[world.WorldSizeBlocks.x, world.WorldSizeBlocks.z]; int worldHeightInBlocks = world.WorldSizeBlocks.y; int minimumGroundheight = worldHeightInBlocks / 4; int groundheightRange = (int)(worldHeightInBlocks * 0.75f); for (int blockX = 0; blockX < world.WorldSizeBlocks.x; blockX++) { for (int blockZ = 0; blockZ < world.WorldSizeBlocks.z; blockZ++) { float octave1 = PerlinSimplexNoise.noise(blockX * 0.0001f, blockZ * 0.0001f) * 0.5f; float octave2 = PerlinSimplexNoise.noise(blockX * 0.0005f, blockZ * 0.0005f) * 0.25f; float octave3 = PerlinSimplexNoise.noise(blockX * 0.005f, blockZ * 0.005f) * 0.12f; float octave4 = PerlinSimplexNoise.noise(blockX * 0.01f, blockZ * 0.01f) * 0.12f; float octave5 = PerlinSimplexNoise.noise(blockX * 0.03f, blockZ * 0.03f) * octave4; float lowerGroundHeight = octave1 + octave2 + octave3 + octave4 + octave5; lowerGroundHeight = (lowerGroundHeight * groundheightRange) + minimumGroundheight; m_HeightField[blockX, blockZ] = lowerGroundHeight; } } }
public virtual void Init(WorldData world) { }
public virtual void BuildWorldChunk(WorldData world, Chunk chunk) { }
private float m_BlockSize; // Size of block unit public GreedyMeshBuilder(WorldData worldData, float blockSize) { m_WorldData = worldData; m_BlockSize = blockSize; }
public Chunk(WorldData world, IntVec3 pos) { // chunk needs to know which world it belongs to and its world position in voxel coords m_World = world; m_WorldPos = pos; }
public MarchingCubesMeshBuilder(WorldData worldData, float blockSize) { m_WorldData = worldData; m_BlockSize = blockSize; }
public override void Init(WorldData world) { }