Esempio n. 1
0
 public void SetValues(
     SizingConfig sizingConfig,
     NoiseConfig noiseConfig,
     FalloffConfig falloffConfig,
     ColorConfig colorConfig,
     BackgroundColorConfig backgroundColorConfig,
     OutlineConfig outlineConfig,
     SymmetryConfig symmetryConfig,
     SymmetryConfig3D symmetryConfig3D,
     ScalingConfig scalingConfig,
     AnimationConfig animationConfig,
     ShadingConfig shadingConfig,
     CleanupConfig cleanupConfig,
     NormalsConfig normalsConfig
     )
 {
     this.sizingConfig          = sizingConfig;
     this.noiseConfig           = noiseConfig;
     this.falloffConfig         = falloffConfig;
     this.colorConfig           = colorConfig;
     this.backgroundColorConfig = backgroundColorConfig;
     this.outlineConfig         = outlineConfig;
     this.symmetryConfig        = symmetryConfig;
     this.symmetryConfig3D      = symmetryConfig3D;
     this.scalingConfig         = scalingConfig;
     this.animationConfig       = animationConfig;
     this.shadingConfig         = shadingConfig;
     this.cleanupConfig         = cleanupConfig;
     this.normalsConfig         = normalsConfig;
 }
Esempio n. 2
0
    public ColorOutcome Recolor(
        ref Texture2D tex, int frame, ColorConfig colorConfig, BackgroundColorConfig backgroundColorConfig,
        OutlineConfig outlineConfig, ColorOutcome colorOutcome)
    {
        if (colorOutcome == ColorOutcome.None || colorOutcome == null)
        {
            colorOutcome = new ColorOutcome();
            if (frame == 0)
            {
                colorOutcome.generatedColors = cachedGeneratedColors = GenerateColors(colorConfig, backgroundColorConfig);
            }
            else
            {
                colorOutcome.generatedColors = cachedGeneratedColors;
            }
            colorOutcome.backgroundColor = SetBackgroundColor();
            colorOutcome.outlineColor    = OutlineColor(outlineConfig, frame, colorOutcome.generatedColors);
        }

        var colors    = tex.GetPixels();
        var increment = 1f / colorConfig.colorCountPerSprite;
        var newColors = new Color[colors.Length];

        for (var index = 0; index < colors.Length; index++)
        {
            var gray = colors[index].grayscale;
            for (var i = 0; i < colorConfig.colorCountPerSprite; i++)
            {
                if (gray >= i * increment && gray <= (i + 1) * increment)
                {
                    newColors[index] = colorOutcome.generatedColors[i];
                }
            }
        }
        tex.SetPixels(newColors);
        return(colorOutcome);

        Color SetBackgroundColor()
        {
            if (!cam)
            {
                cam = Camera.main;
            }
            var backgroundColor =
                BackgroundColor(backgroundColorConfig, colorConfig, frame, colorOutcome.generatedColors);

            cam.backgroundColor = backgroundColor;
            return(backgroundColor);
        }
    }
Esempio n. 3
0
 public void Copy(ConfigurationAsset source)
 {
     sizingConfig          = source.sizingConfig;
     noiseConfig           = source.noiseConfig;
     falloffConfig         = source.falloffConfig;
     colorConfig           = source.colorConfig;
     backgroundColorConfig = source.backgroundColorConfig;
     outlineConfig         = source.outlineConfig;
     symmetryConfig        = source.symmetryConfig;
     symmetryConfig3D      = source.symmetryConfig3D;
     scalingConfig         = source.scalingConfig;
     animationConfig       = source.animationConfig;
     shadingConfig         = source.shadingConfig;
     cleanupConfig         = source.cleanupConfig;
     normalsConfig         = source.normalsConfig;
 }
Esempio n. 4
0
 Color BackgroundColor(BackgroundColorConfig backgroundColorConfig, ColorConfig colorConfig, int frame, Color[] generatedColors)
 {
     if (!colorConfig.usePaletteColors)
     {
         return(Color.black);
     }
     if (backgroundColorConfig.overrideBackgroundColor)
     {
         return(backgroundColorConfig.backgroundColorOverride);
     }
     if (backgroundColorConfig.randomPaletteColorForBackground && frame == 0)
     {
         return(generatedColors[Random.Range(0, generatedColors.Length - 1)]);
     }
     return(generatedColors[backgroundColorConfig.paletteColorIndexForBackground]);
 }
Esempio n. 5
0
    Color[] GenerateColors(ColorConfig colorConfig, BackgroundColorConfig backgroundColorConfig)
    {
        var generatedColors = new Color[colorConfig.colorCountPerSprite];

        if (colorConfig.usePaletteColors)
        {
            if (backgroundColorConfig.overrideBackgroundColor)
            {
                generatedColors[0] = backgroundColorConfig.backgroundColorOverride;
            }
            else if (backgroundColorConfig.randomPaletteColorForBackground)
            {
                generatedColors[0] = uniqueColorsInTextures[colorConfig.paletteIndex][
                    Random.Range(0, uniqueColorsInTextures[colorConfig.paletteIndex].Count - 1)];
            }
            else
            {
                generatedColors[0] =
                    uniqueColorsInTextures[colorConfig.paletteIndex][
                        backgroundColorConfig.paletteColorIndexForBackground];
            }

            for (var index = 1; index < generatedColors.Length; index++)
            {
                generatedColors[index] = uniqueColorsInTextures[colorConfig.paletteIndex][Random.Range(0, uniqueColorsInTextures[colorConfig.paletteIndex].Count)];
                //uniqueColorsInTextures.Remove(generatedColors[index]);
            }
        }
        else
        {
            generatedColors[0] = Color.black;
            for (var index = 1; index < generatedColors.Length; index++)
            {
                generatedColors[index] = Random.ColorHSV(0f, 1f, 1f, 1f);
            }
        }

        return(generatedColors);
    }
Esempio n. 6
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);
    }