示例#1
0
        void Process()
        {
            if (input.Input.Data == null)
            {
                return;
            }

            object o = input.Input.Data;

            if (o is float || o is int)
            {
                float v = (float)o;
                output.Data = (float)Math.Log(v);
                output.Changed();
            }
            else
            {
                output.Data = 0;
                output.Changed();
            }

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#2
0
 private void Input_OnInputRemoved(NodeInput n)
 {
     if (Output != null)
     {
         Output.Data = null;
         Output.Changed();
     }
 }
示例#3
0
        private void Input_OnInputRemoved(NodeInput n)
        {
            if (ParentGraph != null)
            {
                ParentGraph.SetVar(varName, null);
            }

            output.Data = null;
            output.Changed();
        }
示例#4
0
        void Process()
        {
            if (input.Input.Data == null || input2.Input.Data == null || input3.Input.Data == null)
            {
                return;
            }

            object from  = input.Input.Data;
            object to    = input.Input.Data;
            float  delta = (float)input.Input.Data;


            if (from is float && to is MVector)
            {
                MVector f = new MVector((float)from, (float)from, (float)from, (float)from);
                MVector r = MVector.Lerp(f, (MVector)to, delta);
                output.Data = r;
                output.Changed();
            }
            else if (from is float && to is float)
            {
                float r = Utils.Lerp((float)from, (float)to, delta);
                output.Data = r;
                output.Changed();
            }
            else if (from is MVector && to is float)
            {
                MVector f = new MVector((float)from, (float)from, (float)from, (float)from);
                MVector r = MVector.Lerp((MVector)from, f, delta);
                output.Data = r;
                output.Changed();
            }
            else if (from is MVector && to is MVector)
            {
                output.Data = MVector.Lerp((MVector)from, (MVector)to, delta);
                output.Changed();
            }
            else
            {
                output.Data = 0;
                output.Changed();
            }

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#5
0
        void Process()
        {
            if (input.Input.Data == null || input2.Input.Data == null)
            {
                return;
            }

            float theta  = (float)input.Input.Data;
            float radius = (float)input2.Input.Data;

            theta = (float)(Math.PI / 180.0f) * (theta - 90);


            output.Data = radius * (float)Math.Cos(theta);
            output.Changed();
            output2.Data = radius * (float)Math.Sin(theta);
            output2.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#6
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)input.Input.Data;

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            if (processor == null)
            {
                return;
            }

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.Intensity = pintensity;

            processor.Process(width, height, i1, buffer);
            processor.Complete();

            Output.Data = buffer;
            Output.Changed();
            Updated();
        }
示例#7
0
        void Process()
        {
            CreateBufferIfNeeded();

            processor.TileX   = 1;
            processor.TileY   = 1;
            processor.Radius  = pradius;
            processor.Outline = poutline;

            processor.Process(width, height, null, buffer);
            processor.Complete();

            //have to do this to tile properly
            previewProcessor.TileX = tileX;
            previewProcessor.TileY = tileY;

            previewProcessor.Process(width, height, buffer, buffer);
            previewProcessor.Complete();

            previewProcessor.TileX = 1;
            previewProcessor.TileY = 1;

            Updated();
            Output.Data = buffer;
            Output.Changed();
        }
示例#8
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)input.Input.Data;

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            if (processor == null)
            {
                return;
            }

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.Hue        = h * 6.0f;
            processor.Saturation = s;
            processor.Lightness  = l;

            processor.Process(width, height, i1, buffer);
            processor.Complete();

            Output.Data = buffer;
            Output.Changed();
            Updated();
        }
示例#9
0
        void Process()
        {
            if (input2.Input.Data == null && input3.Input.Data == null)
            {
                return;
            }

            bool c = false;

            if (input.Input.Data != null && input.Input.Data is bool)
            {
                c = (bool)input.Input.Data;
            }

            output.Data = c ? input2.Input.Data : input3.Input.Data;
            output.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#10
0
        void Process()
        {
            if (input.Input.Data == null || input2.Input.Data == null)
            {
                return;
            }

            float v = 0;

            object o1 = input.Input.Data;
            object o2 = input2.Input.Data;

            if (o1 is MVector && o2 is MVector)
            {
                v = MVector.Dot((MVector)o1, (MVector)o2);
            }

            output.Data = v;
            output.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#11
0
        void Process()
        {
            CreateBufferIfNeeded();

            Vector4 pcolor = new Vector4(color.X, color.Y, color.Z, color.W);

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Color"))
            {
                object obj = ParentGraph.GetParameterValue(Id, "Color");

                if (obj is MVector)
                {
                    MVector m = (MVector)obj;

                    pcolor.X = m.X;
                    pcolor.Y = m.Y;
                    pcolor.Z = m.Z;
                    pcolor.W = m.W;
                }
                else if (obj is Vector4)
                {
                    pcolor = (Vector4)obj;
                }
            }

            processor.Color = pcolor;
            processor.Process(width, height, null, buffer);
            processor.Complete();

            Updated();
            output.Data = buffer;
            output.Changed();
        }
示例#12
0
        void Process()
        {
            if (brush == null)
            {
                return;
            }

            CreateBufferIfNeeded();

            buffer.Bind();
            GLInterfaces.PixelFormat format = GLInterfaces.PixelFormat.Bgra;

            if (brush.BPP == 24)
            {
                format = GLInterfaces.PixelFormat.Bgr;
            }
            else if (brush.BPP == 16)
            {
                format = GLInterfaces.PixelFormat.Rg;
            }
            else if (brush.BPP == 8)
            {
                format = GLInterfaces.PixelFormat.Red;
            }

            buffer.SetData(brush.Image, format, width, height);
            GLTextuer2D.Unbind();

            brush = null;

            Updated();
            Output.Data = buffer;
            Output.Changed();
        }
示例#13
0
        void Process()
        {
            float v = 0;

            foreach (NodeInput inp in Inputs)
            {
                if (inp.HasInput)
                {
                    object o = inp.Input.Data;
                    if (o == null)
                    {
                        continue;
                    }

                    if (o is float || o is int)
                    {
                        float f = (float)o;
                        v = Math.Max(f, v);
                    }
                }
            }

            output.Data = v;
            output.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#14
0
        void Process()
        {
            float px = x;
            float py = y;

            var p = TopGraph();

            if (p != null && p.HasParameterValue(Id, "X"))
            {
                px = Convert.ToSingle(p.GetParameterValue(Id, "X"));
            }
            if (p != null && p.HasParameterValue(Id, "Y"))
            {
                py = Convert.ToSingle(p.GetParameterValue(Id, "Y"));
            }

            vec.X       = px;
            vec.Y       = py;
            output.Data = vec;
            output.Changed();
            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#15
0
        void Process()
        {
            if (input.Input.Data == null || input2.Input.Data == null)
            {
                return;
            }

            float x = (float)input.Input.Data;
            float y = (float)input2.Input.Data;

            vec.X       = x;
            vec.Y       = y;
            output.Data = vec;
            output.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#16
0
        void Process()
        {
            GLTextuer2D i1 = null;
            GLTextuer2D i2 = null;

            if (Inputs[0].HasInput)
            {
                i1 = (GLTextuer2D)Inputs[0].Input.Data;
            }

            if (Inputs[1].HasInput)
            {
                i2 = (GLTextuer2D)Inputs[1].Input.Data;
            }

            if (!function.BuildShader())
            {
                return;
            }

            CreateBufferIfNeeded();

            processor.Shader = function.Shader;
            processor.Process(width, height, i1, i2, buffer);
            processor.Complete();

            output.Data = buffer;
            output.Changed();
            Updated();
        }
示例#17
0
        void Process()
        {
            if (input.Input.Data == null)
            {
                return;
            }

            object o = input.Input.Data;

            if (o is float || o is int)
            {
                float v = (float)o;

                output.Data = Math.Abs(v);
                output.Changed();
            }
            else if (o is MVector)
            {
                MVector v = (MVector)o;
                MVector d = new MVector();
                d.X = Math.Abs(v.X);
                d.Y = Math.Abs(v.Y);
                d.Z = Math.Abs(v.Z);
                d.W = Math.Abs(v.W);

                output.Data = d;
                output.Changed();
            }
            else
            {
                output.Data = 0;
                output.Changed();
            }

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#18
0
        void Process()
        {
            if (r == null)
            {
                if (ParentGraph != null)
                {
                    r = new Random(ParentGraph.RandomSeed);
                }
                else
                {
                    r = new Random();
                }
            }

            if (input.Input.Data == null)
            {
                return;
            }

            object o = input.Input.Data;

            if (o is float || o is int)
            {
                float v = (float)o;
                output.Data = (float)r.NextDouble() * v;
                output.Changed();
            }
            else
            {
                output.Data = 0;
                output.Changed();
            }

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#19
0
        void Process()
        {
            CreateBufferIfNeeded();

            processor.Color = color;
            processor.Process(width, height, null, buffer);
            processor.Complete();

            Updated();
            output.Data = buffer;
            output.Changed();
        }
示例#20
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)input.Input.Data;
            GLTextuer2D i2 = null;

            if (input2.HasInput)
            {
                if (input2.Input.Data != null)
                {
                    i2 = (GLTextuer2D)input2.Input.Data;
                }
            }

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }

            if (colorLUT == null || colorLUT.Id == 0)
            {
                colorLUT = new GLTextuer2D(PixelInternalFormat.Rgba8);
            }
            if (LUT == null)
            {
                LUT = new FloatBitmap(256, 2);
            }

            //generate gradient
            Utils.CreateGradient(LUT, gradient.positions, gradient.colors);

            colorLUT.Bind();
            colorLUT.SetData(LUT.Image, PixelFormat.Rgba, 256, 2);
            colorLUT.SetFilter((int)TextureMinFilter.Linear, (int)TextureMagFilter.Linear);
            GLTextuer2D.Unbind();

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.ColorLUT = colorLUT;
            processor.Mask     = i2;
            processor.Process(width, height, i1, buffer);
            processor.Complete();

            Output.Data = buffer;
            Output.Changed();
            Updated();
        }
示例#21
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)input.Input.Data;
            GLTextuer2D i2 = (GLTextuer2D)input2.Input.Data;
            GLTextuer2D i3 = null;

            if (input3.HasInput)
            {
                if (input3.Input.Data != null)
                {
                    i3 = (GLTextuer2D)input3.Input.Data;
                }
            }

            if (i1 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }
            if (i2 == null)
            {
                return;
            }
            if (i2.Id == 0)
            {
                return;
            }

            if (processor == null)
            {
                return;
            }

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;

            processor.Horizontal = horiz;

            processor.ColorLUT = i2;
            processor.Mask     = i3;
            processor.Process(width, height, i1, buffer);
            processor.Complete();

            Output.Data = buffer;
            Output.Changed();
            Updated();
        }
示例#22
0
        void FinalProcess()
        {
            App.Current.Dispatcher.Invoke(() =>
            {
                if (mesh == null)
                {
                    return;
                }

                CreateBufferIfNeeded();

                mesh.Mat = mat;

                float rx = (float)rotationX * ((float)Math.PI / 180.0f);
                float ry = (float)rotationY * ((float)Math.PI / 180.0f);
                float rz = (float)rotationZ * ((float)Math.PI / 180.0f);

                Quaternion rot      = Quaternion.FromEulerAngles(rx, ry, rz);
                Matrix4 rotation    = Matrix4.CreateFromQuaternion(rot);
                Matrix4 translation = Matrix4.CreateTranslation(xOffset, yOffset, zOffset);
                Matrix4 scale       = Matrix4.CreateScale(scaleX, scaleY, scaleZ);

                Matrix4 view = rotation * Matrix4.CreateTranslation(0, 0, -cameraZoom);
                Vector3 pos  = Vector3.Normalize((view * new Vector4(0, 0, 1, 1)).Xyz) * cameraZoom;


                mesh.View           = view;
                mesh.CameraPosition = pos;
                mesh.Projection     = Proj;

                //TRS
                mesh.Model = scale * translation;

                //light position currently doesn't do anything
                //just setting values to a default
                mesh.LightPosition = new Vector3(0, 0, 0);
                mesh.LightColor    = new Vector3(1, 1, 1);

                processor.TileX = tileX;
                processor.TileY = tileY;
                processor.Mesh  = mesh;
                processor.Process(width, height, buffer);
                processor.Complete();

                Updated();
                Output.Data = buffer;
                Output.Changed();
            });
        }
示例#23
0
        void Process()
        {
            GLTextuer2D i1 = (GLTextuer2D)first.Input.Data;
            GLTextuer2D i2 = (GLTextuer2D)second.Input.Data;
            GLTextuer2D i3 = null;

            if (mask.HasInput)
            {
                i3 = (GLTextuer2D)mask.Input.Data;
            }

            if (i1 == null || i2 == null)
            {
                return;
            }
            if (i1.Id == 0)
            {
                return;
            }
            if (i2.Id == 0)
            {
                return;
            }

            CreateBufferIfNeeded();

            int   pmode  = (int)mode;
            float palpha = alpha;

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Mode"))
            {
                pmode = Convert.ToInt32(ParentGraph.GetParameterValue(Id, "Mode"));
            }
            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Alpha"))
            {
                palpha = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "Alpha"));
            }

            processor.TileX     = tileX;
            processor.TileY     = tileY;
            processor.Alpha     = palpha;
            processor.BlendMode = pmode;
            processor.Process(width, height, i1, i2, i3, buffer);
            processor.Complete();

            Updated();
            Output.Data = buffer;
            Output.Changed();
        }
示例#24
0
        void Process()
        {
            if (initialInput.Input.Data == null || startInput.Input.Data == null ||
                endInput.Input.Data == null ||
                incrementInput.Input.Data == null || ParentGraph == null)
            {
                return;
            }

            object d    = initialInput.Input.Data;
            float  s    = (float)startInput.Input.Data;
            float  e    = (float)endInput.Input.Data;
            float  incr = (float)incrementInput.Input.Data;


            //handle forwards or backwards loops
            if (s <= e)
            {
                for (float i = s; i < e; i += incr)
                {
                    //we do not throw the incrementOutput changed
                    //as we throw the executor instead
                    incrementOutput.Data = i;
                    loopOutput.Data      = d;

                    //output 0 is the loop executor
                    if (Outputs.Count > 0)
                    {
                        Outputs[0].Changed();
                    }
                }
            }
            else
            {
                for (float i = s; i >= e; i -= incr)
                {
                    incrementOutput.Data = i;
                    loopOutput.Data      = d;

                    if (Outputs.Count > 0)
                    {
                        Outputs[0].Changed();
                    }
                }
            }

            //we have to call the complete executor last
            completeOutput.Changed();
        }
示例#25
0
        void Process()
        {
            if (input.Input.Data == null)
            {
                return;
            }

            MVector v = (MVector)input.Input.Data;

            output.Data  = v.X;
            output2.Data = v.Y;

            output.Changed();
            output2.Changed();
        }
示例#26
0
        void Process()
        {
            output.Data = val;
            output.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#27
0
        void Process()
        {
            vec.X       = x;
            vec.Y       = y;
            vec.Z       = z;
            output.Data = vec;
            output.Changed();
            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#28
0
        void Process()
        {
            if (input.Input.Data == null || input2.Input.Data == null)
            {
                return;
            }

            output.Data = input.Input.Data.Equals(input2.Input.Data);
            output.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }
示例#29
0
        void Process()
        {
            //we release the previous buffer if there is one
            //as we have to make sure we have a clean buffer
            //for the iteration cycles
            //and quadrant transforms
            if (buffer != null)
            {
                buffer.Release();
                buffer = null;
            }

            if (processor == null)
            {
                return;
            }

            if (quadsConnected == 0 || pmaxIter == 0)
            {
                return;
            }

            CreateBufferIfNeeded();

            processor.TileX = tileX;
            processor.TileY = tileY;
            processor.Prepare(width, height, null, buffer);

            foreach (FXQuadData d in quads)
            {
                ProcessQuad(d, quadsConnected);
            }

            processor.Complete();

            quads.Clear();

            Updated();
            Output.Data = buffer;
            Output.Changed();
        }
示例#30
0
        protected virtual void Process()
        {
            object d = null;

            if (ParentGraph != null)
            {
                d = ParentGraph.GetVar <object>(varName);
            }

            output.Data = d;
            output.Changed();

            if (ParentGraph != null)
            {
                FunctionGraph g = (FunctionGraph)ParentGraph;

                if (g != null && g.OutputNode == this)
                {
                    g.Result = output.Data;
                }
            }
        }