Пример #1
0
    public void AlterVoxelSphere(int x, int y, int z, int radius, float coreVolume, byte voxelType, bool writeType)
    {
        int x1 = x - radius;
        int y1 = y - radius;
        int z1 = z - radius;
        int x2 = x + radius;
        int y2 = y + radius;
        int z2 = z + radius;

        float radiusf = (float)radius;

        for (int px = x1; px < x2; ++px)
        {
            for (int py = y1; py < y2; ++py)
            {
                for (int pz = z1; pz < z2; ++pz)
                {
                    Vector3 v    = new Vector3(px - x, py - y, pz - z);
                    float   bpos = radiusf - v.magnitude;
                    if (bpos > 0)
                    {
                        VFVoxel voxel = new VFVoxel(VFVoxel.ToNormByte((bpos >= coreVolume) ? coreVolume : (bpos % coreVolume)), voxelType);
                        AlterVoxel(px, py, pz, voxel, writeType, true);
                    }
                }
            }
        }
    }
Пример #2
0
    public void AlterVoxelBox(int x, int y, int z, int width, int height, int depth, float volume, byte voxelType, bool writeType)
    {
        int x1 = x - width / 2;
        int y1 = y - height / 2;
        int z1 = z - depth / 2;
        int x2 = x + width / 2;
        int y2 = y + height / 2;
        int z2 = z + depth / 2;

        for (int px = x1; px < x2; ++px)
        {
            for (int py = y1; py < y2; ++py)
            {
                for (int pz = z1; pz < z2; ++pz)
                {
                    VFVoxel voxel = new VFVoxel(VFVoxel.ToNormByte(volume), voxelType);
                    AlterVoxel(px, py, pz, voxel, writeType, true);
                }
            }
        }
    }