// Use this for initialization
    void Start()
    {
        m_voxel = gameObject.GetComponent <SimpleVoxel.Voxel> ();

        float yoff = 0f;

        for (int y = 0; y < TerrainSample.ROW; y++)
        {
            float xoff = 0.0f;
            for (int x = 0; x < TerrainSample.COL; x++)
            {
                float dx = (float)x - ((float)TerrainSample.COL * 0.5f);
                float dz = (float)y - ((float)TerrainSample.ROW * 0.5f);
                float dy = map(Mathf.PerlinNoise(xoff, yoff), 0f, 0.6f, -1f, 1f);

                if (dy < 0.3f)
                {
                    m_voxel.CreateCube(new Vector3(dx, dy, dz), new Vector3(255f, 0f, 255f), Vector3.zero, new Vector2(0, 1));
                }
                else
                {
                    m_voxel.CreateCube(new Vector3(dx, dy, dz), new Vector3(255f, 0f, 255f), Vector3.zero, new Vector2(0, 0), new Vector2(1, 1));
                }

                xoff += 0.2f;
            }
            yoff += 0.2f;
        }

        m_voxel.UpdateMesh();
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        m_voxel = gameObject.GetComponent <SimpleVoxel.Voxel> ();

        m_voxel.CreateCube(new Vector3(0f, 0f, 0f), new Vector3(255f, 0f, 255f), Vector3.zero);
        m_voxel.CreateCube(new Vector3(0f, 0f, 1f), new Vector3(255f, 0f, 255f), Vector3.zero);
        m_voxel.CreateCube(new Vector3(1f, 1f, 0f), new Vector3(255f, 255f, 0f), Vector3.zero);
        m_voxel.CreateCube(new Vector3(1f, 0f, 1f), new Vector3(255f, 255f, 0f), Vector3.zero);
        m_voxel.CreateCube(new Vector3(2f, 0f, 0.0f), new Vector3(255f, 255f, 0f), new Vector3(0f, 45f, 0f));

        m_voxel.UpdateMesh();
    }