void Process() { if (input.Input.Data == null) { return; } bool v = (bool)input.Input.Data; output.Data = !v; if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { if (input2.Input.Data == null && input3.Input.Data == null) { return; } if (input2.Input.Type != input3.Input.Type) { 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; if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { if (input.Input.Data == null || input2.Input.Data == null) { return; } float theta = Convert.ToSingle(input.Input.Data); float radius = Convert.ToSingle(input2.Input.Data); theta = (float)(Math.PI / 180.0f) * (theta - 90); output.Data = radius * (float)Math.Cos(theta); output2.Data = radius * (float)Math.Sin(theta); result = $"{output.Data.ToString()},{output2.Data.ToString()}"; if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public override void AssignParentGraph(Graph g) { if (parentGraph != null) { if (parentGraph is FunctionGraph) { FunctionGraph fg = parentGraph as FunctionGraph; fg.OnParentGraphSet -= Fg_OnParentGraphSet; fg.OnParentNodeSet -= Fg_OnParentNodeSet; } } if (g != null) { if (g is FunctionGraph) { FunctionGraph fg = g as FunctionGraph; fg.OnParentGraphSet += Fg_OnParentGraphSet; fg.OnParentNodeSet += Fg_OnParentNodeSet; } } base.AssignParentGraph(g); OnParentSet(); }
void Process() { if (input.Input.Data == null) { return; } object o = input.Input.Data; if (o is float || o is int || o is double || o is long) { float v = Convert.ToSingle(o); output.Data = (float)Math.Log(v, 2); } else { output.Data = 0; } result = output.Data.ToString(); if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public override void TryAndProcess() { if (!string.IsNullOrEmpty(inputName)) { if (ParentGraph != null && ParentGraph is FunctionGraph) { FunctionGraph g = ParentGraph as FunctionGraph; object temp = 0; if (inputType == NodeType.Float) { temp = 0; } else if (inputType == NodeType.Bool) { temp = false; } else if (inputType == NodeType.Matrix) { temp = Math3D.Matrix4.Identity; } else { temp = new MathHelpers.MVector(); } g.SetVar(inputName, temp, inputType); } } }
void Process() { if (input.Input.Data == null || input2.Input.Data == null) { return; } float x = Convert.ToSingle(input.Input.Data); float y = Convert.ToSingle(input2.Input.Data); float radius = (float)Math.Sqrt(x * x + y * y); float theta = (float)Math.Tan(y / x) + (float)Math.PI; output.Data = radius; output2.Data = theta; result = $"{radius},{theta}"; if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public void Dispose() { if (Graph.Graph is FunctionGraph) { FunctionGraph f = Graph.Graph as FunctionGraph; f.OnOutputSet -= F_OnOutputSet; } //register remove node first //for undo Graph.RemoveNode(this); foreach (UINodePoint p in OutputStack.Children) { p.Dispose(); } foreach (UINodePoint p in InputStack.Children) { p.Dispose(); } if (UI3DPreview.Instance != null) { UI3DPreview.Instance.TryAndRemovePreviewNode(this); } if (UIPreviewPane.Instance != null) { UIPreviewPane.Instance.TryAndRemovePreviewNode(this); } }
public UserFunctionStub(FunctionGraph graph, Value[] topArguments, Value[] bottomArguments, IFunctionResolver linker) { Name = graph.Name; int takeTop = ArgumentsToTake(graph.TopArguments); int takeBottom = ArgumentsToTake(graph.BottomArguments); makeNewFunction = () => { topEllipsis = topArguments.Any(x => x.Equals(ellipses)); bottomEllipsis = bottomArguments.Any(x => x.Equals(ellipses)); if (takeTop > 0) { if (!BufferArguments(takeTop, topArgumentBuffer, topArguments, TopInput)) { return(null); } } if (takeBottom > 0) { if (!BufferArguments(takeBottom, bottomArgumentBuffer, bottomArguments, BottomInput)) { return(null); } } return(new UserDefinedFunction(graph, topArguments, bottomArguments, linker)); }; }
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); output2.Data = radius * (float)Math.Sin(theta); if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public void DisposeNoRemove() { if (Graph.Graph is FunctionGraph) { FunctionGraph f = Graph.Graph as FunctionGraph; f.OnOutputSet -= F_OnOutputSet; } foreach (UINodePoint p in OutputStack.Children) { p.DisposeNoRemove(); } foreach (UINodePoint p in InputStack.Children) { p.DisposeNoRemove(); } /*if (UI3DPreview.Instance != null) * { * UI3DPreview.Instance.TryAndRemovePreviewNode(this); * } * * if (UIPreviewPane.Instance != null) * { * UIPreviewPane.Instance.TryAndRemovePreviewNode(this); * }*/ }
void Process() { if (input.Input.Data == null || input2.Input.Data == null) { return; } if (!Helpers.Utils.IsNumber(input.Input.Data)) { return; } if (!Helpers.Utils.IsNumber(input2.Input.Data)) { return; } float x = Convert.ToSingle(input.Input.Data); float y = Convert.ToSingle(input2.Input.Data); vec.X = x; vec.Y = y; output.Data = vec; result = output.Data.ToString(); if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public PixelProcessorNode(int w, int h, GraphPixelType p = GraphPixelType.RGBA) : base() { Name = "Pixel Processor"; Id = Guid.NewGuid().ToString(); width = w; height = h; tileX = tileY = 1; function = new FunctionGraph("Pixel Processor Function", w, h); function.AssignParentNode(this); function.ExpectedOutput = NodeType.Float4 | NodeType.Float; previewProcessor = new BasicImageRenderer(); processor = new PixelShaderProcessor(); internalPixelType = p; for (int i = 0; i < 4; ++i) { var input = new NodeInput(NodeType.Gray | NodeType.Color, this, "Input " + Inputs.Count); Inputs.Add(input); } output = new NodeOutput(NodeType.Color | NodeType.Gray, this); Outputs.Add(output); }
void Process() { if (input.Input.Data == null || input2.Input.Data == null) { return; } output.Data = input.Input.Data.Equals(input2.Input.Data); //output 0 should always be an executor pin if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
protected virtual void Process() { if (input.Input.Data == null) { return; } object o = input.Input.Data; CalculateMatrix(o); output.Data = matrix; if (output.Data != null) { result = output.Data.ToString(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { if (input.Input.Data == null || input2.Input.Data == null) { return; } float x = (float)input.Input.Data; float y = (float)input2.Input.Data; float radius = (float)Math.Sqrt(x * x + y * y); float theta = (float)Math.Tan(y / x) + (float)Math.PI; output.Data = radius; output2.Data = theta; if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
/// <summary> /// This is used for Custom Functions /// And is used in CustomFunctionEditor /// </summary> /// <param name="g"></param> public FunctionView(FunctionGraph g) { InitializeComponent(); isPromotedFunc = false; graph = g; InitNameEdit(); }
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; } } }
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; } } }
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; } } }
public PixelProcessorNode(int w, int h, GraphPixelType p = GraphPixelType.RGBA) { Name = "Pixel Processor"; Id = Guid.NewGuid().ToString(); width = w; height = h; tileX = tileY = 1; function = new FunctionGraph("Pixel Processor Function"); function.ParentNode = this; function.ExpectedOutput = NodeType.Float4; function.OnGraphUpdated += Function_OnGraphUpdated; previewProcessor = new BasicImageRenderer(); processor = new PixelShaderProcessor(); internalPixelType = p; Inputs = new List <NodeInput>(); AddPlaceholderInput(); AddPlaceholderInput(); Outputs = new List <NodeOutput>(); output = new NodeOutput(NodeType.Color | NodeType.Gray, this); Outputs.Add(output); }
void Process() { if (input.Input.Data == null || input2.Input.Data == null || input3.Input.Data == null || input4.Input.Data == null) { return; } float x = (float)input.Input.Data; float y = (float)input2.Input.Data; float z = (float)input3.Input.Data; float w = (float)input4.Input.Data; vec.X = x; vec.Y = y; vec.Z = z; vec.W = w; output.Data = vec; if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { if (input.Input.Data == null) { return; } object o = input.Input.Data; if (o is MVector) { MVector v = (MVector)o; MVector d = v.Normalized; output.Data = d; } else { output.Data = 0; } result = output.Data.ToString(); if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { if (input.Input.Data == null || input2.Input.Data == null) { return; } float x = (float)input.Input.Data; float y = (float)input2.Input.Data; output.Data = x <= y; if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
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; } } }
void Process() { if (string.IsNullOrEmpty(varName)) { return; } if (ParentGraph != null) { ParentGraph.SetVar(varName, input.Input.Data); } output.Data = input.Input.Data; if (Outputs.Count > 0) { Outputs[0].Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
protected virtual void Process() { object d = null; if (ParentGraph != null) { d = ParentGraph.GetVar(varName); } output.Data = d; if (output.Data != null) { result = output.Data.ToString(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { if (string.IsNullOrEmpty(varName)) { return; } if (ParentGraph != null) { ParentGraph.SetVar(varName, input.Input.Data, output.Type); } output.Data = input.Input.Data; if (output.Data != null) { result = output.Data.ToString(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public FunctionGraph CreateGraph(PostfixFunction baseFunction) { FunctionGraph graph = new FunctionGraph(baseFunction, Color.Red, 1); AddGraph(graph); return(graph); }
void Process() { object o = input.Input.Data; if (o is float || o is int) { float v = (float)o; output.Data = (float)Math.Tan(v); if (Outputs.Count > 0) { Outputs[0].Changed(); } } else { output.Data = 0; if (Outputs.Count > 0) { Outputs[0].Changed(); } } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }