Example #1
0
        public NoiseNode(Rect pos, NoiseTypes noiseType, int nDimensions)
            : base(pos, GenerateInputs(noiseType, nDimensions),
				   GetInputNames(noiseType, nDimensions), GetInputDefaultVals(noiseType, nDimensions))
        {
            NoiseType = noiseType;
            NDimensions = nDimensions;
        }
Example #2
0
        public NoiseNode(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            //"Wraps" isn't in older graph files, so give it a default value.
            Wraps = false;

            foreach (SerializationEntry entry in info)
            {
                switch (entry.Name)
                {
                case "NoiseType":
                    NoiseType = (NoiseTypes)(int)entry.Value;
                    break;

                case "NDimensions":
                    NDimensions = (int)entry.Value;
                    break;

                case "Wraps":
                    Wraps = (bool)entry.Value;
                    break;

                case "Worley_DistanceCalc":
                    Worley_DistanceCalc = (string)entry.Value;
                    break;

                case "Worley_NoiseCalc":
                    Worley_NoiseCalc = (string)entry.Value;
                    break;
                }
            }
        }
Example #3
0
        public string GetFunc(NoiseTypes type, int nDimensions, bool wraps)
        {
            switch (type)
            {
            case NoiseTypes.White: return("hashTo1");

            case NoiseTypes.Blocky: return("GridNoise");

            case NoiseTypes.Linear: return("LinearNoise");

            case NoiseTypes.Smooth: return("SmoothNoise");

            case NoiseTypes.Smoother: return("SmootherNoise");

            case NoiseTypes.Perlin: return("PerlinNoise");

            case NoiseTypes.Worley:
                if (IsWorleyDefault)
                {
                    return("WorleyNoise");
                }
                else
                {
                    return("Worley_" + UID);
                }

            default: throw new NotImplementedException(type.ToString());
            }
        }
Example #4
0
 public NoiseNode(Rect pos, NoiseTypes noiseType, int nDimensions)
     : base(pos, GenerateInputs(noiseType, nDimensions),
            GetInputNames(noiseType, nDimensions), GetInputDefaultVals(noiseType, nDimensions))
 {
     NoiseType   = noiseType;
     NDimensions = nDimensions;
 }
Example #5
0
        /// <summary>
        /// Generate default LsData with starting parameters
        /// </summary>
        /// <param name="numbX">Number of X values</param>
        /// <param name="tests">Number of experiments</param>
        /// <param name="beta">Values which have influence for Y</param>
        /// <param name="noiseX">Type of noise/error for X values</param>
        /// <param name="noiseY">Type of noise/error for Y values</param>
        /// <param name="gamma">Used in further calculations</param>
        /// <param name="theta">Used in further calculations</param>
        /// <returns>Returns LsData which ready for further calculations</returns>
        public static LsData Build(int numbX, int tests, double[] beta, NoiseTypes noiseX, NoiseTypes noiseY, double gamma = 0, double theta = 1)
        {
            LsDataBuilder.numbX = numbX;
            LsDataBuilder.tests = tests;
            Beta = Vector <double> .Build.DenseOfArray(beta);

            LsDataBuilder.noiseX = noiseX;
            LsDataBuilder.noiseY = noiseY;

            CreateData();

            return(new LsData(
                       new LsParameters()
            {
                XMtx = X,
                YVtr = Y,
                XMtxNoise = XNoise,
                YVtrNoise = YNoise,
                Beta = Beta,
                NoiseX = LsDataBuilder.noiseX,
                NoiseY = LsDataBuilder.noiseY,
                NumbOfXVal = LsDataBuilder.numbX,
                NumbOfTests = LsDataBuilder.tests,
                XValsNames = xValsNames,
                YValName = yValName,
                Gamma = gamma,
                Theta = theta
            }));
        }
Example #6
0
 private void randomiseParameters()
 {
     Segments          = Random.Range(3, 51);
     RockGradientColor = ScriptableObject.CreateInstance <ColorPalette>();
     RockGradientColor.RandomiseColors(RockSeed);
     RockBasePrimitiveShape = (BasePrimitiveShapes)Random.Range(0, 6);
     octives   = Random.Range(1, 10);
     NoiseType = (NoiseTypes)Random.Range(0, 6);
 }
Example #7
0
        protected override bool CustomGUI()
        {
            bool changed = false;

            //Edit noise type.
            NoiseTypes newType = (NoiseTypes)EditorGUILayout.EnumPopup(NoiseType);

            if (newType != NoiseType)
            {
                changed   = true;
                NoiseType = newType;
            }

            //Edit the number of dimensions.
            int newDim = EditorGUILayout.IntPopup(NDimensions,
                                                  DimensionsStrArray, DimensionsArray);

            if (newDim != NDimensions)
            {
                changed     = true;
                NDimensions = newDim;
            }

            //If using worley noise, edit the customizable aspects of it.
            if (NoiseType == NoiseTypes.Worley)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Distance Func");
                GUILayout.Space(15.0f);
                string newWorleyDist = GUILayout.TextField(Worley_DistanceCalc);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Distance Func");
                GUILayout.Space(15.0f);
                string newWorleyNoise = GUILayout.TextField(Worley_NoiseCalc);
                GUILayout.EndHorizontal();

                if (Worley_DistanceCalc != newWorleyDist || Worley_NoiseCalc != newWorleyNoise)
                {
                    Worley_DistanceCalc = newWorleyDist;
                    Worley_NoiseCalc    = newWorleyNoise;
                    changed             = true;
                }
            }


            //If anything changed, regenerate the inputs.
            if (changed)
            {
                Inputs           = GenerateInputs(NoiseType, NDimensions, Inputs);
                InputNames       = GetInputNames(NoiseType, NDimensions);
                InputDefaultVals = GetInputDefaultVals(NoiseType, NDimensions);
            }

            return(changed);
        }
 internal NoiseTexture(Color p_color, double p_scale, NoiseTypes p_noiseType, double p_multiplyStrength = 0.5, double p_distortionPower = 1.0, int p_seed = 0)
 {
     Color            = p_color;
     Scale            = p_scale;
     NoiseType        = p_noiseType;
     MultiplyStrength = p_multiplyStrength;
     DistortionPower  = p_distortionPower;
     Noise            = new Perlin(p_seed);
 }
Example #9
0
        public NoiseSettings(float strength, float strengthDecrement, float roughness, Vector3 offset, NoiseTypes noiseType)
        {
            Strength          = strength;
            StrengthDecrement = strengthDecrement;
            Roughness         = roughness;
            Offset            = offset;
            NoiseType         = noiseType;

            _noise = new Noise();
        }
Example #10
0
        private static List <string> GetInputNames(NoiseTypes t, int nDimensions)
        {
            List <string> n = new List <string>();

            //Seeds.
            n.Add("x");
            if (nDimensions > 1)
            {
                n.Add("y");
            }
            if (nDimensions > 2)
            {
                n.Add("z");
            }
            if (nDimensions > 3)
            {
                n.Add("w");
            }

            //Scale and weight.
            n.Add("Scale");
            n.Add("Weight");

            //Noise-specific extras.
            switch (t)
            {
            case NoiseTypes.White:
            case NoiseTypes.Blocky:
            case NoiseTypes.Linear:
            case NoiseTypes.Smooth:
            case NoiseTypes.Smoother:
            case NoiseTypes.Perlin:
                break;

            case NoiseTypes.Worley:
                n.Add("Cell Variance X");
                if (nDimensions > 1)
                {
                    n.Add("Cell Variance Y");
                }
                if (nDimensions > 2)
                {
                    n.Add("Cell Variance Z");
                }
                if (nDimensions > 3)
                {
                    n.Add("Cell Variance W");
                }
                break;

            default: throw new NotImplementedException(t.ToString());
            }
            return(n);
        }
Example #11
0
        /*
         * This section determines what type of noise user have selected
         * and authomatically set result to the noiseX and noiseY
         */

        private void DetermineNoiseType()
        {
            if (TgBtnWhiteNoise.IsChecked == true)
            {
                noiseX = CbxNoiseInXValues.IsChecked == true ? NoiseTypes.White : NoiseTypes.None;
                noiseY = CbxNoiseOutYValues.IsChecked == true ? NoiseTypes.White : NoiseTypes.None;
            }
            else if (TgBtnColorfulNoise.IsChecked == true)
            {
                noiseX = CbxNoiseInXValues.IsChecked == true ? NoiseTypes.Colorful : NoiseTypes.None;
                noiseY = CbxNoiseOutYValues.IsChecked == true ? NoiseTypes.Colorful : NoiseTypes.None;
            }
            else
            {
                noiseX = noiseY = NoiseTypes.None;
            }
        }
Example #12
0
        private static List <float> GetInputDefaultVals(NoiseTypes t, int nDimensions)
        {
            List <float> n = new List <float>();

            //Seeds.
            for (int i = 0; i < nDimensions; ++i)
            {
                n.Add(0.0f);
            }

            //Scale and weight.
            n.Add(1.0f);
            n.Add(1.0f);

            //Noise-specific extras.
            switch (t)
            {
            case NoiseTypes.White:
            case NoiseTypes.Blocky:
            case NoiseTypes.Linear:
            case NoiseTypes.Smooth:
            case NoiseTypes.Smoother:
            case NoiseTypes.Perlin:
                break;

            case NoiseTypes.Worley:
                n.Add(0.5f);
                if (nDimensions > 1)
                {
                    n.Add(0.5f);
                }
                if (nDimensions > 2)
                {
                    n.Add(0.5f);
                }
                if (nDimensions > 3)
                {
                    n.Add(0.5f);
                }
                break;

            default: throw new NotImplementedException(t.ToString());
            }
            return(n);
        }
Example #13
0
 public NoiseSettings[] createNoiseSettingArray(NoiseTypes noiseType, float[][] strength, float[][] frequency, float[][] octaves, float[][] lacunarity, float[][] persistence, float[][] wheight, bool dampening)
 {
     NoiseSettings[] output = new NoiseSettings[strength.Length * strength[0].Length];
     for (int x = 0; x < strength.Length; x++)
     {
         for (int y = 0; y < strength[0].Length; y++)
         {
             NoiseSettings temp = new NoiseSettings();
             temp.noiseType   = noiseType;
             temp.strength    = strength[x][y];
             temp.frequency   = frequency[x][y];
             temp.octaves     = (int)octaves[x][y];
             temp.lacunarity  = lacunarity[x][y];
             temp.persistence = persistence[x][y];
             temp.weight      = wheight[x][y];
             temp.damping     = dampening;
             output[y + x * strength[0].Length] = temp;
         }
     }
     return(output);
 }
Example #14
0
 public NoiseNode(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     NoiseType   = (NoiseTypes)info.GetInt32("NoiseType");
     NDimensions = info.GetInt32("NDimensions");
 }
Example #15
0
    public override void DrawWindow()
    {
        base.DrawWindow();
        Event e = Event.current;

        EditorGUI.BeginChangeCheck();

        noiseType      = (NoiseTypes)EditorGUILayout.EnumPopup("Noise Type : ", noiseType);
        resolution     = EditorGUILayout.Vector2Field("Resolution", resolution);
        noiseAreaScale = EditorGUILayout.Vector3Field("Noise Scale", noiseAreaScale);
        numberScale    = EditorGUILayout.Vector2Field("Number Scale", numberScale);
        if (advancedOptions)
        {
            if (extendedOptions)
            {
                GUILayout.BeginHorizontal();
                minScale = (EditorGUILayout.FloatField(minScale, GUILayout.Width(40)));
                EditorGUILayout.MinMaxSlider(ref numberScale.x, ref numberScale.y, minScale, maxScale, GUILayout.Width(100));
                maxScale = (EditorGUILayout.FloatField(maxScale, GUILayout.Width(40)));
                GUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.MinMaxSlider(ref numberScale.x, ref numberScale.y, minScale, maxScale);
            }
        }
        //if (scale.x >= scale.y - 0.1) scale.x = scale.y - 0.1f;
        if (numberScale.x < minScale)
        {
            numberScale.x = minScale;
        }
        if (numberScale.y < minScale)
        {
            numberScale.y = minScale + 0.1f;
        }
        if (inputNodes.Count > 0)
        {
            //input1Title = inputNode.GetResult();
        }
        advancedOptions = GUILayout.Toggle(advancedOptions, "AdvancedOptions");
        if (advancedOptions)
        {
            extendedOptions = GUILayout.Toggle(extendedOptions, "Extended Options");
            dampening       = GUILayout.Toggle(dampening, "Dampening");

            /*string lengthText = GUILayout.TextField((_isLengthMinus ? "" : "") + Length.ToString() + (_isLengthDecimal ? "." : ""));
             * _isLengthDecimal = lengthText.EndsWith(".");
             * _isLengthMinus = lengthText[0].Equals('-');
             *
             * float newLength;
             * if (float.TryParse(lengthText, out newLength))
             * {
             *  Length = newLength;
             * }*/

            if (extendedOptions)
            {
                windowRect = new Rect(windowRect.x, windowRect.y, 200, 700);
                for (int i = 0; i < variableNames.Length; i++)
                {
                    GUILayout.Label(variableNames[i]);
                    if (e.type == EventType.Repaint)
                    {
                        inputNodeRects[i] = GUILayoutUtility.GetLastRect();
                    }
                    GUILayout.BeginHorizontal();
                    minVal[i] = (EditorGUILayout.FloatField(minVal[i], GUILayout.Width(40)));
                    //GUILayout.Space(100);
                    hSliderVal[i] = GUILayout.HorizontalSlider(hSliderVal[i], minVal[i], maxVal[i], GUILayout.Width(100));
                    maxVal[i]     = (EditorGUILayout.FloatField(maxVal[i], GUILayout.Width(40)));
                    //float.TryParse(GUILayout.TextField(maxVal[i].ToString(), GUILayout.Width(40)), out maxVal[i]);
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(45);
                    hSliderVal[i] = (EditorGUILayout.FloatField(hSliderVal[i], GUILayout.Width(100)));
                    GUILayout.EndHorizontal();
                    if (hSliderVal[i] < minVal[i])
                    {
                        hSliderVal[i] = minVal[i];
                    }
                    else if (hSliderVal[i] > maxVal[i])
                    {
                        hSliderVal[i] = maxVal[i];
                    }
                    if (minVal[i] < minMinVal[i])
                    {
                        minVal[i] = minMinVal[i];
                    }
                }
            }
            else
            {
                windowRect = new Rect(windowRect.x, windowRect.y, 200, 550);
                //Debug.Log(variableNames.Length);
                //Debug.Log(inputNodeRects.Length);
                for (int i = 0; i < variableNames.Length; i++)
                {
                    GUILayout.Label(variableNames[i]);
                    if (e.type == EventType.Repaint)
                    {
                        inputNodeRects[i] = GUILayoutUtility.GetLastRect();
                    }
                    GUILayout.BeginHorizontal();
                    hSliderVal[i] = GUILayout.HorizontalSlider(hSliderVal[i], minVal[i], maxVal[i], GUILayout.Width(100));
                    hSliderVal[i] = EditorGUILayout.FloatField(hSliderVal[i], GUILayout.Width(50));
                    GUILayout.EndHorizontal();
                    if (hSliderVal[i] < minVal[i])
                    {
                        hSliderVal[i] = minVal[i];
                    }
                    else if (hSliderVal[i] > maxVal[i])
                    {
                        hSliderVal[i] = maxVal[i];
                    }
                }
            }
        }
        else
        {
            windowRect = new Rect(windowRect.x, windowRect.y, 200, 200);
        }
        GUILayout.Label("Result : " + result);
        if (e.type == EventType.Repaint)
        {
            outputRect = GUILayoutUtility.GetLastRect();
            inputNodeRects[inputNodeRects.Length - 1] = outputRect;
            outputRect = new Rect(windowRect.x + windowRect.width / 1.1f, windowRect.y + outputRect.y, 1, 1);
        }
        if (EditorGUI.EndChangeCheck())
        {
            outputIsCalculated = false;
            iHaveBeenRecalculated();
            EditorUtility.SetDirty(this);
        }
    }
Example #16
0
        private static List<float> GetInputDefaultVals(NoiseTypes t, int nDimensions)
        {
            List<float> n = new List<float>();

            //Seeds.
            for (int i = 0; i < nDimensions; ++i)
                n.Add(0.0f);

            //Scale and weight.
            n.Add(1.0f);
            n.Add(1.0f);

            //Noise-specific extras.
            switch (t)
            {
                case NoiseTypes.White:
                case NoiseTypes.Blocky:
                case NoiseTypes.Linear:
                case NoiseTypes.Smooth:
                case NoiseTypes.Smoother:
                case NoiseTypes.Perlin:
                    break;
                case NoiseTypes.Worley:
                    n.Add(0.5f);
                    if (nDimensions > 1)
                        n.Add(0.5f);
                    if (nDimensions > 2)
                        n.Add(0.5f);
                    break;
                default: throw new NotImplementedException(t.ToString());
            }
            return n;
        }
Example #17
0
        private static List<string> GetInputNames(NoiseTypes t, int nDimensions)
        {
            List<string> n = new List<string>();

            //Seeds.
            n.Add("x");
            if (nDimensions > 1)
                n.Add("y");
            if (nDimensions > 2)
                n.Add("z");

            //Scale and weight.
            n.Add("Scale");
            n.Add("Weight");

            //Noise-specific extras.
            switch (t)
            {
                case NoiseTypes.White:
                case NoiseTypes.Blocky:
                case NoiseTypes.Linear:
                case NoiseTypes.Smooth:
                case NoiseTypes.Smoother:
                case NoiseTypes.Perlin:
                    break;
                case NoiseTypes.Worley:
                    n.Add("Cell Variance X");
                    if (nDimensions > 1)
                        n.Add("Cell Variance Y");
                    if (nDimensions > 2)
                        n.Add("Cell Variance Z");
                    break;
                default: throw new NotImplementedException(t.ToString());
            }
            return n;
        }
Example #18
0
        private static List<NodeInput> GenerateInputs(NoiseTypes t, int nDimensions,
													  List<NodeInput> currentInputs = null)
        {
            List<NodeInput> ni = new List<NodeInput>();

            //Seed.
            for (int i = 0; i < nDimensions; ++i)
            {
                if (currentInputs != null && currentInputs.Count > i)
                    ni.Add(currentInputs[i]);
                else
                    ni.Add(new NodeInput(0.0f));
            }

            //Scale.
            if (currentInputs != null && currentInputs.Count > nDimensions)
                ni.Add(currentInputs[nDimensions]);
            else
                ni.Add(new NodeInput(1.0f));
            //Weight.
            if (currentInputs != null && currentInputs.Count > nDimensions + 1)
                ni.Add(currentInputs[nDimensions + 1]);
            else
                ni.Add(new NodeInput(1.0f));

            //Noise-specific extras.
            switch (t)
            {
                case NoiseTypes.White:
                case NoiseTypes.Blocky:
                case NoiseTypes.Linear:
                case NoiseTypes.Smooth:
                case NoiseTypes.Smoother:
                case NoiseTypes.Perlin:
                    break;
                case NoiseTypes.Worley:
                    for (int i = 0; i < nDimensions; ++i)
                    {
                        int index = nDimensions + 2 + i;
                        if (currentInputs == null || currentInputs.Count <= index)
                            ni.Add(new NodeInput(0.5f));
                        else
                            ni.Add(currentInputs[index]);
                    }
                    break;
                default: throw new NotImplementedException(t.ToString());
            }

            return ni;
        }
Example #19
0
 public NoiseNode(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     NoiseType = (NoiseTypes)info.GetInt32("NoiseType");
     NDimensions = info.GetInt32("NDimensions");
 }
Example #20
0
        private static List <NodeInput> GenerateInputs(NoiseTypes t, int nDimensions,
                                                       List <NodeInput> currentInputs = null)
        {
            List <NodeInput> ni = new List <NodeInput>();

            //Seed.
            for (int i = 0; i < nDimensions; ++i)
            {
                if (currentInputs != null && currentInputs.Count > i)
                {
                    ni.Add(currentInputs[i]);
                }
                else
                {
                    ni.Add(new NodeInput(0.0f));
                }
            }

            //Scale.
            if (currentInputs != null && currentInputs.Count > nDimensions)
            {
                ni.Add(currentInputs[nDimensions]);
            }
            else
            {
                ni.Add(new NodeInput(1.0f));
            }
            //Weight.
            if (currentInputs != null && currentInputs.Count > nDimensions + 1)
            {
                ni.Add(currentInputs[nDimensions + 1]);
            }
            else
            {
                ni.Add(new NodeInput(1.0f));
            }

            //Noise-specific extras.
            switch (t)
            {
            case NoiseTypes.White:
            case NoiseTypes.Blocky:
            case NoiseTypes.Linear:
            case NoiseTypes.Smooth:
            case NoiseTypes.Smoother:
            case NoiseTypes.Perlin:
                break;

            case NoiseTypes.Worley:
                for (int i = 0; i < nDimensions; ++i)
                {
                    int index = nDimensions + 2 + i;
                    if (currentInputs == null || currentInputs.Count <= index)
                    {
                        ni.Add(new NodeInput(0.5f));
                    }
                    else
                    {
                        ni.Add(currentInputs[index]);
                    }
                }
                break;

            default: throw new NotImplementedException(t.ToString());
            }

            return(ni);
        }
Example #21
0
        protected override bool CustomGUI()
        {
            bool changed = false;

            //Edit noise type.
            NoiseTypes newType = (NoiseTypes)EditorGUILayout.EnumPopup(NoiseType);
            if (newType != NoiseType)
            {
                changed = true;
                NoiseType = newType;
            }

            //Edit the number of dimensions.
            int newDim = EditorGUILayout.IntPopup(NDimensions,
                                                  DimensionsStrArray, DimensionsArray);
            if (newDim != NDimensions)
            {
                changed = true;
                NDimensions = newDim;
            }

            //If using worley noise, edit the customizable aspects of it.
            if (NoiseType == NoiseTypes.Worley)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Distance Func");
                GUILayout.Space(15.0f);
                string newWorleyDist = GUILayout.TextField(Worley_DistanceCalc);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Distance Func");
                GUILayout.Space(15.0f);
                string newWorleyNoise = GUILayout.TextField(Worley_NoiseCalc);
                GUILayout.EndHorizontal();

                if (Worley_DistanceCalc != newWorleyDist || Worley_NoiseCalc != newWorleyNoise)
                {
                    Worley_DistanceCalc = newWorleyDist;
                    Worley_NoiseCalc = newWorleyNoise;
                    changed = true;
                }
            }

            //If anything changed, regenerate the inputs.
            if (changed)
            {
                Inputs = GenerateInputs(NoiseType, NDimensions, Inputs);
                InputNames = GetInputNames(NoiseType, NDimensions);
                InputDefaultVals = GetInputDefaultVals(NoiseType, NDimensions);
            }

            return changed;
        }
Example #22
0
 public string GetFunc(NoiseTypes type, int nDimensions)
 {
     switch (type)
     {
         case NoiseTypes.White: return "hashValue" + nDimensions;
         case NoiseTypes.Blocky: return "GridNoise" + nDimensions;
         case NoiseTypes.Linear: return "LinearNoise" + nDimensions;
         case NoiseTypes.Smooth: return "SmoothNoise" + nDimensions;
         case NoiseTypes.Smoother: return "SmootherNoise" + nDimensions;
         case NoiseTypes.Perlin: return "PerlinNoise" + nDimensions;
         case NoiseTypes.Worley:
             if (IsWorleyDefault)
                 return "WorleyNoise" + NDimensions;
             else
                 return "Worley_" + UID;
         default: throw new NotImplementedException(type.ToString());
     }
 }
Example #23
0
        private void ThreadedProcess()
        {
            if (t_noiseType == NoiseTypes.Undefined)
            {
                t_noiseType = NoiseTypes.FastNoise;
            }

            Engine.Effects.Noise.IModule module;

            // switch block : source and info at : https://libnoisedotnet.codeplex.com/downloads/get/720936
            // and http://libnoise.sourceforge.net/tutorials/tutorial8.html

            switch (t_noiseType)
            {
            case NoiseTypes.Billow:
                module = new Engine.Effects.Noise.Billow();

                ((Billow)module).Frequency    = t_frequency;
                ((Billow)module).NoiseQuality = NoiseQuality.Standard;
                ((Billow)module).Seed         = t_seed;
                ((Billow)module).OctaveCount  = t_octaves;
                ((Billow)module).Lacunarity   = t_lacunarity;
                ((Billow)module).Persistence  = t_persistence;
                break;

            case NoiseTypes.FastBillow:
                module = new Engine.Effects.Noise.FastBillow();

                ((FastBillow)module).Frequency    = t_frequency;
                ((FastBillow)module).NoiseQuality = NoiseQuality.Standard;
                ((FastBillow)module).Seed         = t_seed;
                ((FastBillow)module).OctaveCount  = t_octaves;
                ((FastBillow)module).Lacunarity   = t_lacunarity;
                ((FastBillow)module).Persistence  = t_persistence;
                break;

            case NoiseTypes.FastNoise:
                module = new Engine.Effects.Noise.FastNoise();

                ((FastNoise)module).Frequency    = t_frequency;
                ((FastNoise)module).NoiseQuality = NoiseQuality.Standard;
                ((FastNoise)module).Seed         = t_seed;
                ((FastNoise)module).OctaveCount  = t_octaves;
                ((FastNoise)module).Lacunarity   = t_lacunarity;
                ((FastNoise)module).Persistence  = t_persistence;
                break;

            default:
                module = new Engine.Effects.Noise.Perlin();

                ((Perlin)module).Frequency    = t_frequency;
                ((Perlin)module).NoiseQuality = NoiseQuality.Standard;
                ((Perlin)module).Seed         = t_seed;
                ((Perlin)module).OctaveCount  = t_octaves;
                ((Perlin)module).Lacunarity   = t_lacunarity;
                ((Perlin)module).Persistence  = t_persistence;
                break;
            }

            t_imageProcessed = new Engine.Surface.Canvas(t_imageSource.Width, t_imageSource.Height);

            t_workflow.AllowInvalidate = true;

            Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop();

            Engine.Threading.ParamList paramList = new Threading.ParamList();
            paramList.Add(paramName_module, typeof(Engine.Effects.Noise.IModule), module);

            loop.Loop(t_imageSource.Height, Threaded_Process, paramList);
            loop.Dispose();

            base.PostProcess();
        }
Example #24
0
        /// <summary>
        /// Generates a FloorMap object, and initializes it
        /// </summary>
        /// <param name="noise">The type of Noise algorithm to use</param>
        /// <param name="noiseThreshold">The value that the noise has to be above to generate a room</param>
        /// <param name="complexity">The value that controls the parsing of rooms from the noise</param>
        /// <returns>True if the floor is generated completely</returns>
        public Boolean GenerateFloor(NoiseTypes noise, Double noiseThreshold)
        {
            // Add some default values to the parameters

            //can't call if the object is null, so don't need to check

            //Sizes were taken care of previously during creation of object, assume they are safe

            //grid value = floor(noise_value * (Complexity + 1))

            switch (noise)
            {
                case NoiseTypes.Perlin:
                    this.Initialized = this.generatePerlinNoise(noiseThreshold, complexity);
                    break;
                case NoiseTypes.Simplex:
                    this.Initialized = this.generateSimplexNoise(noiseThreshold, complexity);
                    break;
                case NoiseTypes.Gradient:
                    this.Initialized = this.generateGradientNoise(noiseThreshold, complexity);
                    break;
                case NoiseTypes.Random:
                    this.Initialized = this.generateRandomNoise(noiseThreshold);
                    break;
                default:
                    //Response with an error message
                    this.Initialized = false;
                    break;
            }

            return this.Initialized;
        }