Exemple #1
0
 public void ToData(Data data)
 {
     if (distances != null && distances.Length == data.RawData.Length)
     {
         NativeArray <float> .Copy(distances, data.RawData);
     }
 }
Exemple #2
0
 public void FromData(Data data)
 {
     colNum    = data.ColNum;
     rowNum    = data.RowNum;
     distances = new float[colNum * rowNum];
     NativeArray <float> .Copy(data.RawData, distances);
 }
    void Start()
    {
        data = new Data(50, 50);
        data.InitHeights();

        marchingMesher.InitWithData(data);

        DrawAt(new Vector3(5, 0, 5), data);

        marchingMesher.Regenerate();

        buttonLabel.text = ModeLabels[modeIndex];
        brushRoot.SetActive(false);
    }
    private void DrawAt(Vector3 pos, Data data)
    {
        switch ((Mode)modeIndex)
        {
        case Mode.Subtract:
        {
            data.RemoveCircle(pos.x, pos.z, radius, CellSize);
            break;
        }

        case Mode.Add:
        {
            data.ApplyCircle(pos.x, pos.z, radius, CellSize);
            data.RemoveBorder();
            break;
        }

        case Mode.IncreaseHeight:
        {
            if (brushIndex == 0)
            {
                data.ChangeHeightCircleFlat(pos.x, pos.z, radius, HeightChangeValue, CellSize, 0, maxHeight);
            }
            else
            {
                data.ChangeHeightCircleSmooth(pos.x, pos.z, radius, HeightChangeValue, CellSize, 0, maxHeight);
            }
            break;
        }

        case Mode.DecreaseHeight:
        {
            if (brushIndex == 0)
            {
                data.ChangeHeightCircleFlat(pos.x, pos.z, radius, -HeightChangeValue, CellSize, 0, maxHeight);
            }
            else
            {
                data.ChangeHeightCircleSmooth(pos.x, pos.z, radius, -HeightChangeValue, CellSize, 0, maxHeight);
            }
            break;
        }
        }
    }