Beispiel #1
0
    public void AttemptToApplySymmetry(ref GeneratedVoxelModel voxelModel, SymmetryConfig3D configuration,
                                       ref SymmetryOutcome3D symmetryOutcome)
    {
        symmetryOutcome = Determine3DSymmetryDirectionsToApply(configuration);

        foreach (var direction in symmetryOutcome.symmetryDirections)
        {
            ApplySymmetry(ref voxelModel.modelData, direction, symmetryOutcome);
        }
    }
Beispiel #2
0
    void SpawnVoxels(GeneratedVoxelModel voxelModel)
    {
        var tex = voxelModel.modelData;

        for (var i = 0; i < tex.depth; i++)
        {
            for (var k = 0; k < tex.height; k++)
            {
                for (var j = 0; j < tex.width; j++)
                {
                    var voxel = GameObject.Instantiate(voxelPrefab, transform);
                    voxel.transform.localPosition = new Vector3(i, j, k);
                    voxel.GetComponent <Voxel>().SetColor(tex.GetPixel(i, j, k));
                }
            }
        }
    }
Beispiel #3
0
    void SpawnVoxels(GeneratedVoxelModel voxelModel)
    {
        var tex = voxelModel.modelData;

        for (var x = 0; x < tex.width; x++)
        {
            for (var z = 0; z < tex.depth; z++)
            {
                for (var y = 0; y < tex.height; y++)
                {
                    var voxel = GameObject.Instantiate(voxelPrefab, transform);
                    voxel.transform.localPosition = new Vector3(x, y, z);
                    voxel.GetComponent <Voxel>().SetColor(tex.GetPixel(x, y, z));
                }
            }
        }
    }
Beispiel #4
0
    public ColorOutcome Recolor(
        ref GeneratedVoxelModel generatedVoxel, ColorConfig configurationColorConfig,
        BackgroundColorConfig configurationBackgroundColorConfig, OutlineConfig configurationOutlineConfig)
    {
        // generate the colors to use for the model
        var colorOutcome = new ColorOutcome();

        colorOutcome.generatedColors = GenerateColors(configurationColorConfig);

        // get the current (grayscale) colors of the model
        var colors = generatedVoxel.modelData.GetPixels();
        // determine how many different colors we will have in the final model
        var increment = 1f / configurationColorConfig.colorCountPerSprite;
        // create a new list to hold the new colors for the voxels
        var newColors = new Color[colors.Length];

        // loop through each grayscale color and re-assign it to the new color according to the grayscale range
        for (var index = 0; index < colors.Length; index++)
        {
            var color = colors[index];

            var gray = color.grayscale;

            for (var i = 0; i < configurationColorConfig.colorCountPerSprite; i++)
            {
                if (gray >= i * increment && gray <= (i + 1) * increment)
                {
                    newColors[index] = colorOutcome.generatedColors[i];
                }
            }
        }

        // set the values
        generatedVoxel.modelData.SetPixels(newColors);
        generatedVoxel.modelData.Apply();
        return(colorOutcome);
    }