Beispiel #1
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varA = new Variable("A");
            varA.Type = Variable.VariableType.Input;
            varA.Text = "A";
            variables.Add(varA);

            varB = new Variable("B");
            varB.Type = Variable.VariableType.Input;
            varB.Text = "B";
            variables.Add(varB);

            varC = new Variable("C");
            varC.Type = Variable.VariableType.Input;
            varC.Text = "C";
            variables.Add(varC);

            varAPlusBTimesC = new Variable("Result");
            varAPlusBTimesC.Type = Variable.VariableType.Output;
            varAPlusBTimesC.Text = "(A + B) * C";
            variables.Add(varAPlusBTimesC);

            return variables;
        }
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varInput = new Variable("Input");
            varInput.Type = Variable.VariableType.Input;
            varInput.Text = "Input";
            variables.Add(varInput);

            varX = new Variable("X");
            varX.Type = Variable.VariableType.Output;
            varX.Text = "X";
            variables.Add(varX);

            varY = new Variable("Y");
            varY.Type = Variable.VariableType.Output;
            varY.Text = "Y";
            variables.Add(varY);

            varZ = new Variable("Z");
            varZ.Type = Variable.VariableType.Output;
            varZ.Text = "Z";
            variables.Add(varZ);

            varW = new Variable("W");
            varW.Type = Variable.VariableType.Output;
            varW.Text = "W";
            variables.Add(varW);

            return variables;
        }
Beispiel #3
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varDensity = new Variable("Density");
            varDensity.Type = Variable.VariableType.Input;
            varDensity.Text = "Density";
            variables.Add(varDensity);

            varFogColor = new Variable("Color");
            varFogColor.Type = Variable.VariableType.Input;
            varFogColor.Text = "Color";
            variables.Add(varFogColor);

            varInputColor = new Variable("Input");
            varInputColor.Type = Variable.VariableType.Input;
            varInputColor.Text = "Input";
            variables.Add(varInputColor);

            varFinal = new Variable("Output");
            varFinal.Type = Variable.VariableType.Output;
            varFinal.Text = "Output";
            variables.Add(varFinal);

            return variables;
        }
Beispiel #4
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varSelect = new Variable("Value");
            varSelect.Type = Variable.VariableType.Input;
            varSelect.Text = "Value";
            variables.Add(varSelect);

            varA = new Variable("A");
            varA.Type = Variable.VariableType.Input;
            varA.Text = "A";
            variables.Add(varA);

            varB = new Variable("B");
            varB.Type = Variable.VariableType.Input;
            varB.Text = "B";
            variables.Add(varB);

            varAOrB = new Variable("AOrB");
            varAOrB.Type = Variable.VariableType.Output;
            varAOrB.Text = "A | B";
            variables.Add(varAOrB);

            return variables;
        }
Beispiel #5
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varPosition = new Variable("Normal");
            varPosition.Type = Variable.VariableType.Output;
            varPosition.Text = "Normal";
            variables.Add(varPosition);

            return variables;
        }
Beispiel #6
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varFinalOutput = new Variable("output");
            varFinalOutput.Type = Variable.VariableType.Input;
            varFinalOutput.Text = "Final output";
            variables.Add(varFinalOutput);
            
            return variables;
        }
 // Determine the variable type
 private string determineTypeIdentifier(Variable variable)
 {
     if (variable.IsFloat4())
         return "float4";
     else if (variable.IsFloat3())
         return "float3";
     else if (variable.IsFloat2())
         return "float2";
     else if (variable.IsFloat1())
         return "float";
     else
         return "float4";
 }
Beispiel #8
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varUV = new Variable("uv");
            varUV.Type = Variable.VariableType.Input;
            varUV.Text = "UV";
            variables.Add(varUV);

            varColor = new Variable("color");
            varColor.Type = Variable.VariableType.Output;
            varColor.Text = "Color";
            variables.Add(varColor);

            return variables;
        }
Beispiel #9
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varInput = new Variable("unsaturized");
            varInput.Type = Variable.VariableType.Input;
            varInput.Text = "Unnsaturized value";
            variables.Add(varInput);

            varOutput = new Variable("saturized");
            varOutput.Type = Variable.VariableType.Output;
            varOutput.Text = "Saturized value";
            variables.Add(varOutput);

            return variables;
        }
        // Copy the variable
        public Variable(Variable variable)
        {
            InitializeComponent();

            Type = variable.Type;
            InputType = variable.InputType;

            Text = variable.Text;

            inputFloat1.Text = variable.inputFloat1.Text;
            inputFloat2.Text = variable.inputFloat2.Text;
            inputFloat3.Text = variable.inputFloat3.Text;
            inputFloat4.Text = variable.inputFloat4.Text;
            inputColor.SelectedColor = variable.inputColor.SelectedColor;
            inputBoolean.SelectedIndex = variable.inputBoolean.SelectedIndex;
            inputVarying.SelectedIndex = variable.inputVarying.SelectedIndex;
        }
        // Determine the variable type
        private string determineTypeIdentifier(Variable variable)
        {
            if (variable.Node.inode.IsOutputNode() && variable.InputType == Variable.InputTypes.Link && variable.GetLinks().Count == 1)
            {
                return determineTypeIdentifier(variable.GetLinks()[0].OutputVariable);
            }

            if (variable.IsFloat4())
                return "float4";
            else if (variable.IsFloat3())
                return "float3";
            else if (variable.IsFloat2())
                return "float2";
            else if (variable.IsFloat1())
                return "float";
            else
                return "float4";
        }
Beispiel #12
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varA = new Variable("A");
            varA.Type = Variable.VariableType.Input;
            varA.Text = "A";
            variables.Add(varA);

            varB = new Variable("B");
            varB.Type = Variable.VariableType.Input;
            varB.Text = "B";
            variables.Add(varB);

            varARaisedToB = new Variable("AraisedB");
            varARaisedToB.Type = Variable.VariableType.Output;
            varARaisedToB.Text = "A raised to B";
            variables.Add(varARaisedToB);

            return variables;
        }
Beispiel #13
0
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varA = new Variable("A");
            varA.Type = Variable.VariableType.Input;
            varA.Text = "A";
            variables.Add(varA);

            varB = new Variable("B");
            varB.Type = Variable.VariableType.Input;
            varB.Text = "B";
            variables.Add(varB);

            varAPlusB = new Variable("AminusB");
            varAPlusB.Type = Variable.VariableType.Output;
            varAPlusB.Text = "A - B";
            variables.Add(varAPlusB);

            return variables;
        }
        public VariableStruct(Node node, Variable.VariableType variableType)
        {
            this.node = node;

            // Create the identifier
            Identifier = "s" + getUniqueID();

            // Create the hlsl description
            HLSLDescription = "struct " + Identifier + " {\n";

            foreach (Variable variable in node.Variables)
            {
                if (variable.Type == variableType)
                {
                    string variableIdentifier = "v" + getUniqueID();

                    dictonaryVariableIdentifiers[variable] = variableIdentifier;

                    HLSLDescription += "\t" + determineTypeIdentifier(variable) + " " + variableIdentifier + ";\n";
                }
            }

            HLSLDescription += "};\n\n"; 
        }
        public List<Variable> GetVariables()
        {
            List<Variable> variables = new List<Variable>();

            varA = new Variable("A");
            varA.Type = Variable.VariableType.Input;
            varA.Text = "A";
            variables.Add(varA);

            varB = new Variable("B");
            varB.Type = Variable.VariableType.Input;
            varB.Text = "B";
            variables.Add(varB);

            varInput = new Variable("Input");
            varInput.Type = Variable.VariableType.Input;
            varInput.Text = "Input";
            variables.Add(varInput);

            varTreshold = new Variable("Treshold");
            varTreshold.Type = Variable.VariableType.Input;
            varTreshold.Text = "Treshold";
            variables.Add(varTreshold);

            varBlend = new Variable("Blend");
            varBlend.Type = Variable.VariableType.Input;
            varBlend.Text = "Blend";
            variables.Add(varBlend);

            varResult = new Variable("Result");
            varResult.Type = Variable.VariableType.Output;
            varResult.Text = "Result";
            variables.Add(varResult);

            return variables;
        }
Beispiel #16
0
        public void AddVariable(Variable variable)
        {
            StackPanel.Children.Add(variable);

            Variables.Add(variable);

            variable.Node = this;
        }
        public static void startCreation(Variable outputVariable)
        {
            DesignArea designArea = outputVariable.DesignArea;

            Connection newConnection = new Connection();
            newConnection.DesignArea = designArea;
            newConnection.OutputVariable = outputVariable;

            designArea.AddConnection(newConnection);

            DynamicCanvas.SetZIndex(newConnection, designArea.getHighestZIndex());

            // Update curve position when the mouse is moved
            newConnection.creationMouseMoveListener = new MouseEventHandler((x, y) => dragCreation(newConnection, y));
            newConnection.creationMouseUpListener = new MouseButtonEventHandler((x, y) => dragCreation(newConnection, y));
            designArea.MouseMove += newConnection.creationMouseMoveListener;
            designArea.MouseUp += newConnection.creationMouseUpListener;
        }
        private static HitTestResultBehavior finalizeCreation(HitTestResult hitTestResult, Connection newConnection)
        {
            // Try to find the variable parent
            Variable inputVariable = null;

            if (hitTestResult.VisualHit is Ellipse)
            {
                Ellipse ellipse = hitTestResult.VisualHit as Ellipse;

                DependencyObject parent = VisualTreeHelper.GetParent(ellipse);

                while(!(parent is DesignArea))
                {
                    if (parent is Variable) 
                    {
                        Variable variable = parent as Variable;

                        if (variable.Type == Variable.VariableType.Input && variable.GetLinks().Count == 0)
                        {
                            inputVariable = variable;
                        }

                        break;
                    }

                    parent = VisualTreeHelper.GetParent(parent);
                }
            }

            if (inputVariable != null)
            {
                // Finalize the connection
                newConnection.InputVariable = inputVariable;
            }
            else
            {
                // Destroy the connection
                newConnection.OutputVariable = null;

                newConnection.DesignArea.RemoveConnection(newConnection);
            }

            return HitTestResultBehavior.Stop;
        }
        private void updatePreview()
        {
            Image img = PreviewImage;

            if (ir0 != null)
            {
                ir0.Destroy();
                img.Source = null;
                ir0 = null;
            }

            //
            if (!FilesManager.Instance.ActiveFile.ActiveState.IsComplete)
                return;

            FileState altState = new FileState(FilesManager.Instance.ActiveFile.ActiveState, false);

            // Find output
            Node outputNode = null;

            foreach (Node node in altState.Nodes)
            {
                if (node.inode.IsOutputNode())
                {
                    outputNode = node;
                    break;
                }
            }

            // Find selected node
            oldSelectedVariable = parent.InputVariable;
            Node selectedNode = altState.dictionaryOldToNew[oldSelectedVariable.Node];

            int oldIndex = oldSelectedVariable.Node.Variables.IndexOf(oldSelectedVariable);
            Variable selectedVariable = selectedNode.Variables[oldIndex];

            // Remove output input if it was linked
            if (outputNode.Variables[0].InputType == Variable.InputTypes.Link)
            {
                outputNode.Variables[0].GetLinks()[0].removeConnection();
            }

            // Find var output if it was linked
            if (selectedVariable.GetLinks().Count > 0 && FilesManager.Instance.ActiveFile.ActiveState.Renderer != null)
            {
                Variable outputVariable = selectedVariable.GetLinks()[0].OutputVariable;

                // Create a new connection
                Connection c = new Connection();
                c.OutputVariable = outputVariable;
                c.InputVariable = outputNode.Variables[0];

                // Compile source
                HLSLCompiler comp = new HLSLCompiler(altState);
                comp.Compile();

                ir0 = FilesManager.Instance.ActiveFile.ActiveState.Renderer.Create();
                ImageSource images = ir0.Initialize();
                ir0.SetSourceCode(comp.SourceCode);

                img.Source = images;
            }
        }