Ejemplo n.º 1
0
    void Construct()
    {
        Vector3 center = new Vector3(width / 2.0f, height / 2.0f, depth / 2.0f);

        int [, ,] volume = new int[width, height, depth];

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < depth; z++)
                {
                    Vector3 pos = new Vector3(x, y, z) - center;

                    bool isCore = (pos.magnitude < coreRadius);

                    volume[x, y, z] = (isCore) ? 1 :
                                      (rng.Next(0, 100) < orbitalFillPercentage) ? 1 : 0;
                }
            }
        }

        voxelRender.Render(volume);
        MeshCollider meshc = gameObject.AddComponent(typeof(MeshCollider)) as MeshCollider;

        meshc.enabled = true;
        meshc.convex  = true;
    }
Ejemplo n.º 2
0
    void SpawnSurface()
    {
        int[, ,] surface = new int[(int)width, (int)height, (int)depth];

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < depth; z++)
                {
                    bool isFloor = (y == 0);
                    bool isWall  = (x == 0 || x == width - 1);
                    bool fill    = (isFloor || isWall);

                    surface[x, y, z] = (fill) ? 1 : 0;
                }
            }
        }

        voxelRender.Render(surface);
    }