Beispiel #1
0
    private void CreateRandom(Shape shape, bool append = false)
    {
        //World world = GameObject.Find("World Spawner").GetComponentInChildren<World>();
        Index blockIndex = new Index((int)(Random.value * Chunk.Width), (int)(Random.value * Chunk.Height), (int)(Random.value * Chunk.Width));
        Index chunkIndex = new Index((int)(Random.value * world.Width), 0, (int)(Random.value * world.Width));
        Work  work       = new Work(world.chunks[chunkIndex.i, chunkIndex.j, chunkIndex.k], blockIndex, shape);

        ChunkMeshGenerator.EnqueueWork(work);
    }
Beispiel #2
0
    private void CreateBlock(RaycastHit hit, Shape shape, bool append = false)
    {
        Chunk chunk = hit.transform.GetComponent <Chunk>();

        hit.point   += offset;
        blockIndex.i = (int)(append ? hit.normal.x + hit.point.x % Chunk.Width : hit.point.x % Chunk.Width);
        blockIndex.j = (int)(append ? hit.normal.y + hit.point.y % Chunk.Width : hit.point.y % Chunk.Width);
        blockIndex.k = (int)(append ? hit.normal.z + hit.point.z % Chunk.Width : hit.point.z % Chunk.Width);
        ChunkMeshGenerator.EnqueueWork(new Work(chunk, blockIndex, shape));
    }