Beispiel #1
0
        public override void Calculate()
        {
            base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }

            //map.Snowflake((int)getValue("levels"), getValue("size"));
            if (Type == TYPE_FLOWER)
            {
                map.FlowerPattern((int)getValue("levels"), getValue("size"), getValue("angle"), getValue("seed"), getValue("thickness"), getValue("anglescale"));
            }
            if (Type == TYPE_GRASS)
            {
                map.GrassPattern((int)getValue("amount"), getValue("size"), getValue("angle"), getValue("seed"), getValue("thickness"), getValue("anglescale"));
            }

            map.ScaleMap(getValue("amplitude"), 0);
            GenerateHeightTexture();
            CNodeManager.Progress();
            updateTexture = true;

            changed = false;
        }
Beispiel #2
0
        public override void GenerateTexture()
        {
            foreach (CConnection ct in Inputs)
            {
                if (ct.pointer != null)
                {
                    if (ct.pointer.parent != null)
                    {
                        ((CTextureNode)ct.pointer.parent).GenerateTexture();
                    }
                }
            }
            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            CNodeManager.Progress();
            if (m1 == null)
            {
                return;
            }
            if (!updateTexture)
            {
                return;
            }
            map.CopyFrom(m1.map);
            map.Normalize(1);
            texture = NormalMap.CreateDOT3(m1.map, getValue("contrast") * 1.5f, 0);
            CNodeManager.Progress();
            updateTexture = false;
        }
Beispiel #3
0
        public override void Calculate()
        {
            base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                return;
            }
            m1.Calculate();

            float curvtype = getValue("curvtype");
            float scale    = getValue("scale");


            if (normals == null)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }
            if (normals.GetLength(0) != C2DMap.sizeX)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }

            m1.map.calculateNormals(100, normals);


            for (int i = 0; i < C2DMap.sizeX; i++)
            {
                for (int j = 0; j < C2DMap.sizeY; j++)
                {
                    map [i, j] = m1.map.getCurvature(i, j, scale, (int)curvtype, normals);
                }
            }
            //map.Smooth(1);


            map.ScaleMap(getValue("amplitude"), 0);
            GenerateHeightTexture();
            CNodeManager.Progress();
            updateTexture = true;

            changed = false;
        }
Beispiel #4
0
        public override void Calculate()
        {
            base.Calculate();
            if (!verified)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                verified = false;
                return;
            }

            m1.Calculate();

            if (!changed)
            {
                return;
            }

            float curvtype = getValue("curvtype");
            float scale    = getValue("scale");
            Color c1       = getColor("color1");

            if (normals == null)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }
            if (normals.GetLength(0) != C2DMap.sizeX)
            {
                normals = new Vector3[C2DMap.sizeX, C2DMap.sizeY];
            }

            m1.map.calculateNormals(100, normals);
            for (int i = 0; i < C2DMap.sizeX; i++)
            {
                for (int j = 0; j < C2DMap.sizeY; j++)
                {
                    colors.colors [i, j] = c1 * Mathf.Pow(m1.map.getCurvature(i, j, scale, (int)curvtype, normals), 1);
                }
            }
            colors.Smooth(1);
            updateTexture = true;
            CNodeManager.Progress();

            changed = false;
        }
Beispiel #5
0
        public override void Calculate()
        {
            base.Calculate();
            if (!verified)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                verified = false;
                return;
            }

            m1.Calculate();

            if (!changed)
            {
                return;
            }

            float scale = getValue("scale");
            float power = getValue("power");
            Color c1    = getColor("color1");
            Color c2    = getColor("color2");

            Color c = new Color(1, 1, 1);

            for (int i = 0; i < C2DMap.sizeX; i++)
            {
                for (int j = 0; j < C2DMap.sizeY; j++)
                {
                    float val = Mathf.SmoothStep(0, 1.0f, m1.map [i, j] - scale + 0.75f);
                    val = Mathf.Clamp(Mathf.Pow(val, power), 0, 1);
                    c   = c1 * val + c2 * (1 - val);
                    colors.colors [i, j] = c;
                }
            }
            updateTexture = true;
            CNodeManager.Progress();

            changed = false;
        }
Beispiel #6
0
        public void CalculateTextures()
        {
            CTextureNode Heightmap = (CTextureNode)getNode(Inputs, 0);
            CTextureNode ColorMap  = (CTextureNode)getNode(Inputs, 1);
            CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2);

            if (NormalMap == null || ColorMap == null || Heightmap == null)
            {
                return;
            }
            Heightmap.GenerateTexture();
            ColorMap.GenerateTexture();
            NormalMap.GenerateTexture();

            MaterialPreviewEditor.SetTextures(NormalMap.texture, Heightmap.texture, ColorMap.texture, MaterialPreviewEditor.currentMaterial);
            MaterialPreviewEditor.forceRepaint();
            CNodeManager.Progress();
        }
Beispiel #7
0
        public override void Calculate()
        {
            //base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }


            CTextureNode combiner   = (CTextureNode)getNode(Inputs, 0);
            CTextureNode m1         = (CTextureNode)getNode(Inputs, 1);
            CTextureNode m2         = (CTextureNode)getNode(Inputs, 2);
            C2DMap       combineMap = null;

            if (combiner != null)
            {
                combiner.Calculate();
                combineMap = combiner.map;
            }
            if (m1 == null || m2 == null)
            {
                verified = false;
                return;
            }
            m1.Calculate();
            m2.Calculate();

//			map.Combine(m1.map, m2.map, combineMap, getValue("blendval"), Type);
            colors.Combine(m1.colors, m2.colors, combineMap, getValue("blendval"), Type);
            updateTexture = true;

            colors.Scale(getValue("amplitude"));
            //map.ScaleMap(getValue("amplitude"),0);
            //GenerateHeightTexture();
            CNodeManager.Progress();
            changed = false;
        }
Beispiel #8
0
 public virtual void GenerateTexture()
 {
     foreach (CConnection ct in Inputs)
     {
         if (ct.pointer != null)
         {
             if (ct.pointer.parent != null)
             {
                 ((CTextureNode)ct.pointer.parent).GenerateTexture();
             }
         }
     }
     CNodeManager.Progress();
     if (!updateTexture)
     {
         return;
     }
     colors.toTexture(texture);
     texture.wrapMode = TextureWrapMode.Repeat;
     texture.Apply();
     updateTexture = false;
 }
Beispiel #9
0
        public override void Calculate()
        {
            base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }

            map.Snowflake((int)getValue("levels"), getValue("size"));
            //map.ScaleMap(getValue("amplitude"),0);
            GenerateHeightTexture();
            CNodeManager.Progress();
            updateTexture = true;

            changed = false;
        }
Beispiel #10
0
        public override void Calculate()
        {
            base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }

            if (Type == TYPE_GRID)
            {
                map.RenderGrid(getValue("amplitude"), getValue("thickness"), getValue("spacingx"), getValue("spacingy"), getValue("rotation"));
            }

            if (Type == TYPE_REGULARDOTS)
            {
                map.RenderDots(getValue("amplitude"), getValue("size"), getValue("spacingx"), getValue("spacingy"), getValue("filling"));
            }

            if (Type == TYPE_BRICKS)
            {
                map.RenderBricks(getValue("amplitude"), getValue("thickness"), getValue("spacingx"), getValue("spacingy"), (int)getValue("bricktype"));
            }

            //map.Normalize(getValue("amplitude"));
            map.ScaleMap(getValue("amplitude"), 0);
            GenerateHeightTexture();
            CNodeManager.Progress();
            updateTexture = true;

            changed = false;
        }
Beispiel #11
0
        // automatically builds the node window
        protected void buildGUI(string lbl)
        {
            setColor();

            if (TangyTexturesEditor.mouseUp != true)
            {
                if (Event.current.type == EventType.MouseUp)
                {
                    TangyTexturesEditor.mouseUp = true;
                }
            }

            largeFont.fontSize         = LStyle.LargeFontSize;
            largeFont.normal.textColor = color;
            //setColor ();
            largeFont.alignment = TextAnchor.UpperCenter;
            labelSize           = 65;
            remainingSize       = (int)(rightSize.x - labelSize) - 5;
            float d = 30;                                     // pos of window

            if (GUI.Button(new Rect(d, 15, rightSize.x - 1.5f * d, 32), ""))
            {
                Verify();
                if (verified)
                {
                    // only allowed to click when not active
                    if (CNodeManager.status == CNodeManager.STATUS_NONE)
                    {
                        CNodeManager.status = status_after_click;

                        calculateProgressDelta(CNodeManager.size);
                        CNodeManager.calculator = this;
                    }
                }
                else
                {
                    CNodeManager.DisplayError(clickErrorMessage);
                }
            }
            size.y = 50;
            // main label
            if (debug)
            {
                lbl = "" + ID;
            }
            GUILayout.Label(lbl, largeFont, GUILayout.Width(rightSize.x));
            GUILayout.Space(5);
            if (displayParameters == null)
            {
                displayParameters = new List <Parameter> ();
                keys = rebuildDisplayParams();
            }
            int current = 0;

            foreach (Parameter p in displayParameters)
            {
                size.y += LStyle.FontSize;
                if (p.label == "")
                {
                    continue;
                }
                if (p.label.StartsWith("Color"))
                {
                    GUILayout.BeginHorizontal();                                                      // "Button" is cool!
                    displayColor.r = p.value;
                    displayColor.g = p.min;
                    displayColor.b = p.max;
//									displayColor = (Color)EditorGUILayout.ObjectField(p.label, displayColor, typeof(Color), false);
                    GUILayout.Label(p.label.Substring(5), GUILayout.Width(labelSize));
                    Color c = GUI.backgroundColor;
                    GUI.backgroundColor = Color.white;
                    displayColor        = EditorGUILayout.ColorField(displayColor, GUILayout.Width(remainingSize));
                    GUI.backgroundColor = c;
                    if (displayColor.r != p.value || displayColor.g != p.min || displayColor.b != p.max)
                    {
                        PropagateChange();
                    }
                    p.value = displayColor.r;
                    p.min   = displayColor.g;
                    p.max   = displayColor.b;


                    GUILayout.EndHorizontal();
                }
                else
                if (p.label.StartsWith("string"))
                {
                    string s2 = p.key;
                    if (s2 == null || s2.Length == 0)
                    {
                        s2 = keys[current];
                    }
                    GUILayout.Label(s2, GUILayout.Width(remainingSize + labelSize));

                    GUILayout.BeginHorizontal();                                                      // "Button" is cool!
                    string org = p.label;
                    string s   = p.label.Substring(6);

                    p.label = "string" + GUILayout.TextField(s, GUILayout.Width(remainingSize + labelSize));
                    if (!p.label.Equals(org))
                    {
                        PropagateChange();
                    }
                    GUILayout.EndHorizontal();
                }

                else
                {
                    GUILayout.BeginHorizontal();                                                      // "Button" is cool!
                    GUILayout.Label(" " + p.label, GUILayout.Width(labelSize));
                    float f = p.value;
                    p.value = GUILayout.HorizontalSlider(p.value, p.min, p.max, GUILayout.Width(remainingSize - 28));
                    GUILayout.Label("" + p.value, GUILayout.Width(28));

                    if (p.value != f)
                    {
                        PropagateChange();
                    }

                    GUILayout.EndHorizontal();
                }
                current++;
            }
            if (types.Length > 1 && displayTypes)
            {
                int t = Type;
                size.y += LStyle.FontSize;
                Type    = EditorGUILayout.Popup(Type, types, GUILayout.Width(rightSize.x));
                if (t != Type)
                {
                    PropagateChange();
                    CNodeManager.mouseUp = true;
                    //Debug.Log (t + " and " + Type);
                }
            }

            // close and help buttons
            if (GUI.Button(new Rect(rightSize.x - 20, 15, 25, 32), "X"))
            {
                CNodeManager.deleteNode(this);
            }
            if (GUI.Button(new Rect(5, 15, 25, 32), "?"))
            {
                HelpEditor.Create(helpMessage);
            }
            window.height = size.y;
        }
Beispiel #12
0
        public override void Calculate()
        {
            base.Calculate();

            if (!verified)
            {
                return;
            }

            if (!changed)
            {
                return;
            }

            CTextureNode m1 = (CTextureNode)getNode(Inputs, 0);

            if (m1 == null)
            {
                return;
            }
            m1.Calculate();
            map.CopyFrom(m1.map);
            float ascale = 1;

            if (Type == TYPE_SMOOTH)
            {
                map.Smooth((int)(getValue("value1") * 40f), (int)(getValue("value2") * 3f));
            }
            if (Type == TYPE_SCALE)
            {
                map.ScaleMap((getValue("value1") - 0.5f) * 4, 2 * (getValue("value2") - 0.5f));
            }
            if (Type == TYPE_POWER)
            {
                map.Pow((getValue("value1") - 0.5f) * 3, 2 * (getValue("value2") - 0.5f));
            }
            if (Type == TYPE_CONTOURS)
            {
                map.Contour(getValue("value1") * 100f, 4 * (getValue("value2") - 0.5f));
            }
            if (Type == TYPE_CLAMP)
            {
                map.Clamp(getValue("value1"), (getValue("value2")));
                ascale *= 5;
            }
            if (Type == TYPE_PIXEL)
            {
                map.Pixelate(getValue("value1"));
            }


            map.ScaleMap(getValue("amplitude") * ascale, 0);
            GenerateHeightTexture();
            if (Type != TYPE_SMOOTH)
            {
                CNodeManager.Progress();
            }
            updateTexture = true;

            changed = false;
        }