예제 #1
0
        public override void ApplyStamps(ObiBrushBase brush, bool modified)
        {
            var floatProperty = (ObiBlueprintFloatProperty)property;

            float averageValue = 0;
            float totalWeight  = 0;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (!property.Masked(i) && brush.weights[i] > 0)
                {
                    averageValue += floatProperty.Get(i) * brush.weights[i];
                    totalWeight  += brush.weights[i];
                }
            }
            averageValue /= totalWeight;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (!property.Masked(i) && brush.weights[i] > 0)
                {
                    float currentValue = floatProperty.Get(i);
                    float delta        = brush.opacity * brush.speed * (Mathf.Lerp(currentValue, averageValue, brush.weights[i]) - currentValue);

                    floatProperty.Set(i, currentValue + delta * (modified ? -1 : 1));
                }
            }
        }
        public override void ApplyStamps(ObiBrushBase brush, bool modified)
        {
            var colorProperty = (ObiBlueprintColorProperty)property;

            Color averageValue = Color.black;
            float totalWeight  = 0;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (!property.Masked(i) && brush.weights[i] > 0)
                {
                    averageValue += colorProperty.Get(i) * brush.weights[i];
                    totalWeight  += brush.weights[i];
                }
            }
            averageValue /= totalWeight;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (!property.Masked(i) && brush.weights[i] > 0)
                {
                    Color currentValue = colorProperty.Get(i);
                    Color delta        = brush.opacity * brush.speed * (Color.Lerp(currentValue, averageValue, brush.weights[i]) - currentValue);

                    colorProperty.Set(i, currentValue + delta * (modified ? -1 : 1));
                }
            }
        }
 public void OnSelect(ObiBrushBase paintBrush)
 {
     // Initialize the brush:
     if (brushModes.Count > 0)
     {
         paintBrush.brushMode = brushModes[0];
     }
 }
        public override void ApplyStamps(ObiBrushBase brush, bool modified)
        {
            var intProperty = (ObiBlueprintIntProperty)property;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (!property.Masked(i) && brush.weights[i] > (1 - brush.opacity))
                {
                    intProperty.Set(i, intProperty.GetDefault());
                }
            }
        }
예제 #5
0
        public override void ApplyStamps(ObiBrushBase brush, bool modified)
        {
            var selectedProperty = (ObiBlueprintSelected)property;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (brush.weights[i] > 0 && !property.Masked(i))
                {
                    selectedProperty.Set(i, !modified);
                }
            }
        }
예제 #6
0
        public override void ApplyStamps(ObiBrushBase brush, bool modified)
        {
            var colorProperty = (ObiBlueprintColorProperty)property;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (!property.Masked(i) && brush.weights[i] > 0)
                {
                    Color currentValue = colorProperty.Get(i);
                    Color delta        = brush.weights[i] * brush.opacity * brush.speed * (colorProperty.GetDefault() - currentValue);

                    colorProperty.Set(i, currentValue + delta * (modified ? -1 : 1));
                }
            }
        }
        public void BrushModes(ObiBrushBase paintBrush)
        {
            // Initialize the brush if there's no mode set:
            if (paintBrush.brushMode == null && brushModes.Count > 0)
            {
                paintBrush.brushMode = brushModes[0];
            }

            GUIContent[] contents = new GUIContent[brushModes.Count];

            for (int i = 0; i < brushModes.Count; ++i)
            {
                contents[i] = new GUIContent(brushModes[i].name);
            }

            EditorGUI.BeginChangeCheck();
            selectedBrushMode = ObiEditorUtils.DoToolBar(selectedBrushMode, contents);
            if (EditorGUI.EndChangeCheck())
            {
                paintBrush.brushMode = brushModes[selectedBrushMode];
            }
        }
예제 #8
0
        public override void ApplyStamps(ObiBrushBase brush, bool modified)
        {
            var intProperty = (ObiBlueprintIntProperty)property;

            for (int i = 0; i < brush.weights.Length; ++i)
            {
                if (!property.Masked(i) && brush.weights[i] > (1 - brush.opacity))
                {
                    int currentValue = intProperty.Get(i);

                    if (modified)
                    {
                        currentValue &= ~(int)(1 << intProperty.GetDefault());
                    }
                    else
                    {
                        currentValue |= (int)(1 << intProperty.GetDefault());
                    }

                    intProperty.Set(i, currentValue);
                }
            }
        }
예제 #9
0
 public abstract void ApplyStamps(ObiBrushBase brush, bool modified);