コード例 #1
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            double controlValue = ControlModule.GetValue(x, y);
            float  alpha;

            double lowerBound  = LowerBound.GetValue(x, y);
            double upperBound  = UpperBound.GetValue(x, y);
            double edgeFalloff = EdgeFalloff.GetValue(x, y);

            if (edgeFalloff > 0.0)
            {
                if (controlValue < (lowerBound - edgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetColour(x, y));
                }
                else if (controlValue < (lowerBound + edgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (lowerBound - edgeFalloff);
                    double upperCurve = (lowerBound + edgeFalloff);
                    alpha = (float)Loonim.Math.SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Loonim.Math.LinearInterpolate(SourceModule1.GetColour(x, y),
                                                         SourceModule2.GetColour(x, y), alpha));
                }
                else if (controlValue < (upperBound - edgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetColour(x, y));
                }
                else if (controlValue < (upperBound + edgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (upperBound - edgeFalloff);
                    double upperCurve = (upperBound + edgeFalloff);
                    alpha = (float)Loonim.Math.SCurve3(
                        (controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Loonim.Math.LinearInterpolate(SourceModule2.GetColour(x, y),
                                                         SourceModule1.GetColour(x, y),
                                                         alpha));
                }
                else
                {
                    // Output value from the control module is above the selector threshold;
                    // return the output value from the first source module.
                    return(SourceModule1.GetColour(x, y));
                }
            }
            else
            {
                if (controlValue < lowerBound || controlValue > upperBound)
                {
                    return(SourceModule1.GetColour(x, y));
                }
                else
                {
                    return(SourceModule2.GetColour(x, y));
                }
            }
        }
コード例 #2
0
        public override double GetValue(double x, double y, double z)
        {
            //   var result = base.GetValue(x, y, z);


            double del = Div * 150.0f;
            double xx  = (x * del);
            double yy  = (z * del);
            var    col = Bitmap.GetPixel((int)xx, (int)(yy));

            float height = col.R / 255.0f;

            if (col.A == 0)
            {
                return(0);
            }
            if (height > 0.7f)
            {
            }
            height -= 0.5f;
            height *= 2.0f;

            double controlValue = ControlModule.GetValue(x, y, z);
            double alpha;

            controlValue = height + (controlValue * 1.2f * Randomness);

            if (EdgeFalloff > 0.0)
            {
                if (controlValue < (LowerBound - EdgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
                else if (controlValue < (LowerBound + EdgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (LowerBound - EdgeFalloff);
                    double upperCurve = (LowerBound + EdgeFalloff);
                    alpha = SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule1.GetValue(x, y, z),
                                             SourceModule2.GetValue(x, y, z), alpha));
                }
                else if (controlValue < (UpperBound - EdgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetValue(x, y, z));
                }
                else if (controlValue < (UpperBound + EdgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (UpperBound - EdgeFalloff);
                    double upperCurve = (UpperBound + EdgeFalloff);
                    alpha = SCurve3(
                        (controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule2.GetValue(x, y, z),
                                             SourceModule1.GetValue(x, y, z),
                                             alpha));
                }
                else
                {
                    // Output value from the control module is above the selector threshold;
                    // return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
            }
            else
            {
                if (controlValue < LowerBound || controlValue > UpperBound)
                {
                    return(SourceModule1.GetValue(x, y, z));
                }
                else
                {
                    return(SourceModule2.GetValue(x, y, z));
                }
            }
        }
コード例 #3
0
ファイル: Select.cs プロジェクト: park66665/ck2gen
        public virtual double GetValue(double x, double y, double z)
        {
            if (ControlModule == null || SourceModule1 == null || SourceModule2 == null)
            {
                throw new NullReferenceException("Control and source modules must be provided.");
            }

            double controlValue = ControlModule.GetValue(x, y, z);
            double alpha;

            if (EdgeFalloff > 0.0)
            {
                if (controlValue < (LowerBound - EdgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
                else if (controlValue < (LowerBound + EdgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (LowerBound - EdgeFalloff);
                    double upperCurve = (LowerBound + EdgeFalloff);
                    alpha = SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule1.GetValue(x, y, z),
                                             SourceModule2.GetValue(x, y, z), alpha));
                }
                else if (controlValue < (UpperBound - EdgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetValue(x, y, z));
                }
                else if (controlValue < (UpperBound + EdgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (UpperBound - EdgeFalloff);
                    double upperCurve = (UpperBound + EdgeFalloff);
                    alpha = SCurve3(
                        (controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule2.GetValue(x, y, z),
                                             SourceModule1.GetValue(x, y, z),
                                             alpha));
                }
                else
                {
                    // Output value from the control module is above the selector threshold;
                    // return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
            }
            else
            {
                if (controlValue < LowerBound || controlValue > UpperBound)
                {
                    return(SourceModule1.GetValue(x, y, z));
                }
                else
                {
                    return(SourceModule2.GetValue(x, y, z));
                }
            }
        }