Exemple #1
0
    void DetermineSymmetry(
        bool master, SymmetryConfig configuration, ref SymmetryOutcome symmetryOutcome)
    {
        if (master)
        {
            if (configuration.enforceSomeTypeOfSymmetry && (
                    configuration.horizontalSymmetryChance + configuration.verticalSymmetryChance +
                    configuration.forwardDiagonalSymmetryChance + configuration.backwardDiagonalSymmetryChance > 0))
            {
                while (!symmetryOutcome.horizontalSymmetryResult && !symmetryOutcome.verticalSymmetryResult &&
                       !symmetryOutcome.backwardDiagonalSymmetryResult &&
                       !symmetryOutcome.forwardDiagonalSymmetryResult)
                {
                    symmetryOutcome = DetermineSymmetryDirectionsToApply(configuration);
                }
            }
            else
            {
                symmetryOutcome = DetermineSymmetryDirectionsToApply(configuration);
            }

            additionalFrameCachedSymmetryOutcome = symmetryOutcome;
        }
        else
        {
            symmetryOutcome = additionalFrameCachedSymmetryOutcome;
        }
    }
Exemple #2
0
    public void AttemptToApplySymmetry(
        ref Texture2D texture, int frame, SymmetryConfig configuration, bool inheritSymmetry,
        ref SymmetryOutcome symmetryOutcome)
    {
        if (inheritSymmetry)
        {
            DetermineSymmetry(frame == 0, configuration, ref symmetryOutcome);
        }

        if (symmetryOutcome.horizontalSymmetryResult)
        {
            ApplySymmetry(ref texture, SymmetryDirection.Horizontal, symmetryOutcome);
        }
        if (ShouldApplyVerticalSymmetry(configuration.allowMultipleSymmetryTypes, symmetryOutcome))
        {
            ApplySymmetry(ref texture, SymmetryDirection.Vertical, symmetryOutcome);
        }
        if (ShouldApplyForwardDiagonalSymmetry(configuration.allowMultipleSymmetryTypes, symmetryOutcome))
        {
            ApplySymmetry(ref texture, SymmetryDirection.ForwardDiagonal, symmetryOutcome);
        }
        if (ShouldApplyBackwardDiagonalSymmetry(configuration.allowMultipleSymmetryTypes, symmetryOutcome))
        {
            ApplySymmetry(ref texture, SymmetryDirection.BackwardDiagonal, symmetryOutcome);
        }
    }
 public GeneratedTexture(Texture2D texture, Texture2D normal, Vector2 origin, SymmetryOutcome symmetryOutcome, ColorOutcome colorOutcome)
 {
     this.texture         = texture;
     this.normal          = normal;
     this.origin          = origin;
     this.symmetryOutcome = symmetryOutcome;
     this.colorOutcome    = colorOutcome;
 }
Exemple #4
0
 bool ShouldApplyVerticalSymmetry(bool multipleSymmetriesAllowed, SymmetryOutcome symmetryOutcome)
 {
     if (multipleSymmetriesAllowed || !symmetryOutcome.horizontalSymmetryResult)
     {
         return(symmetryOutcome.verticalSymmetryResult);
     }
     return(false);
 }
 public GeneratedVoxelModel(
     Texture3D modelData, Vector2 origin, SymmetryOutcome symmetryOutcome, ColorOutcome colorOutcome)
 {
     this.modelData       = modelData;
     this.origin          = origin;
     this.symmetryOutcome = symmetryOutcome;
     this.colorOutcome    = colorOutcome;
 }
Exemple #6
0
 bool ShouldApplyForwardDiagonalSymmetry(bool multipleSymmetriesAllowed, SymmetryOutcome symmetryOutcome)
 {
     if (multipleSymmetriesAllowed || (!symmetryOutcome.horizontalSymmetryResult &&
                                       !symmetryOutcome.verticalSymmetryResult))
     {
         return(symmetryOutcome.forwardDiagonalSymmetryResult);
     }
     return(false);
 }
 public InheritedSymmetryConfig(bool inherited, SymmetryOutcome outcome = null)
 {
     this.inherited = inherited;
     this.outcome   = outcome;
 }
Exemple #8
0
    void ApplySymmetry(ref Texture2D texture, SymmetryDirection direction, SymmetryOutcome symmetryOutcome)
    {
        var halfwayPoint = texture.width / 2;

        for (var rowIndex = 0; rowIndex < texture.height; rowIndex++)
        {
            for (var columnIndex = 0; columnIndex < texture.width; columnIndex++)
            {
                int referenceValue;
                switch (direction)
                {
                case SymmetryDirection.Horizontal:
                    referenceValue = symmetryOutcome.quarterHorizontalSymmetryResult ? columnIndex : rowIndex;
                    if ((symmetryOutcome.lowerIsDominant && referenceValue >= halfwayPoint - 1) ||
                        (!symmetryOutcome.lowerIsDominant && referenceValue <= halfwayPoint + 1))
                    {
                        SetSymmetricalPixel(texture, direction, columnIndex, rowIndex, halfwayPoint);
                    }
                    break;

                case SymmetryDirection.Vertical:
                    referenceValue = symmetryOutcome.quarterVerticalSymmetryResult ? rowIndex : columnIndex;
                    if ((symmetryOutcome.lowerIsDominant && referenceValue >= halfwayPoint - 1) ||
                        (!symmetryOutcome.lowerIsDominant && referenceValue <= halfwayPoint + 1))
                    {
                        SetSymmetricalPixel(texture, direction, columnIndex, rowIndex, halfwayPoint);
                    }
                    break;

                case SymmetryDirection.ForwardDiagonal:
                    if (symmetryOutcome.quarterForwardDiagonalSymmetryResult)
                    {
                        if (symmetryOutcome.lowerIsDominant && columnIndex > rowIndex || !symmetryOutcome.lowerIsDominant && columnIndex < rowIndex)
                        {
                            texture.SetPixel(columnIndex, rowIndex, texture.GetPixel(texture.width - rowIndex, texture.width - columnIndex));
                        }
                    }
                    else
                    {
                        if (symmetryOutcome.lowerIsDominant && rowIndex < texture.width - columnIndex || !symmetryOutcome.lowerIsDominant && rowIndex > texture.width - columnIndex)
                        {
                            texture.SetPixel(columnIndex, rowIndex, texture.GetPixel(texture.width - rowIndex, texture.width - columnIndex));
                        }
                    }
                    break;

                case SymmetryDirection.BackwardDiagonal:
                    if (symmetryOutcome.quarterBackwardDiagonalSymmetryResult)
                    {
                        if (symmetryOutcome.lowerIsDominant && rowIndex < texture.width - columnIndex || !symmetryOutcome.lowerIsDominant && rowIndex > texture.width - columnIndex)
                        {
                            texture.SetPixel(columnIndex, rowIndex, texture.GetPixel(rowIndex, columnIndex));
                        }
                    }
                    else
                    if (symmetryOutcome.lowerIsDominant && columnIndex > rowIndex || !symmetryOutcome.lowerIsDominant && columnIndex < rowIndex)
                    {
                        texture.SetPixel(columnIndex, rowIndex, texture.GetPixel(rowIndex, columnIndex));
                    }
                    break;
                }
            }
        }
    }