コード例 #1
0
        public Form1()
        {
            InitializeComponent();
            /// Diffuse
            Node            Diffuse = new Node("Diffuse");
            NodeValueOutput Output  = new NodeValueOutput("Output");
            NodeValueColor  Color   = new NodeValueColor("Color");

            Color.Value = new ValueVector(1, 1, 1, 1);
            Diffuse.AddNodeValue(Output);
            Diffuse.AddNodeValue(Color);
            Editor.AddNode(Diffuse);
            /// Specular
            Node            Specular  = new Node("Specular");
            NodeValueOutput Output1   = new NodeValueOutput("Output");
            NodeValueColor  SpecularV = new NodeValueColor("Specular");

            SpecularV.Value = new ValueVector(0, 0, 0.5, 1);
            NodeValueFloat Shininess = new NodeValueFloat("Shininess");

            Specular.AddNodeValue(Output1);
            Specular.AddNodeValue(SpecularV);
            Specular.AddNodeValue(Shininess);
            Editor.AddNode(Specular);
            /// Combine Shader
            Node            CombineShader = new Node("Combine");
            NodeValueOutput Output3       = new NodeValueOutput("Combined");
            NodeValueColor  Input1        = new NodeValueColor("Input 1");
            NodeValueColor  Input2        = new NodeValueColor("Input 2");

            CombineShader.AddNodeValue(Output3);
            CombineShader.AddNodeValue(Input1);
            CombineShader.AddNodeValue(Input2);
            Editor.AddNode(CombineShader);
            /// Surface Result
            Node            SurfaceResult = new Node("Surface Result");
            NodeValueOutput Output5       = new NodeValueOutput("Result");

            SurfaceResult.AddNodeValue(Output5);
            Editor.AddNode(SurfaceResult);
            /// Posterization
            Node            Posterization = new Node("Posterization");
            NodeValueOutput Output4       = new NodeValueOutput("Processed");
            NodeValueFloat  Thickness     = new NodeValueFloat("Thickness");
            NodeValueFloat  Intensity     = new NodeValueFloat("Intensity");
            NodeValueColor  Input         = new NodeValueColor("Input");

            Posterization.AddNodeValue(Output4);
            Posterization.AddNodeValue(Thickness);
            Posterization.AddNodeValue(Intensity);
            Posterization.AddNodeValue(Input);
            Editor.AddNode(Posterization);
            /// Material Output
            Node            Output2 = new Node("Material Output");
            NodeValueVector Surface = new NodeValueVector("Surface");

            Surface.HasValue = false;
            NodeValueVector Volume = new NodeValueVector("Displacement");

            Volume.HasValue = false;
            NodeValueVector Displacement = new NodeValueVector("Post Processing");

            Displacement.HasValue = false;
            Output2.AddNodeValue(Surface);
            Output2.AddNodeValue(Volume);
            Output2.AddNodeValue(Displacement);
            //BSDF.Outputs.Add(Surface);
            //Surface.Input = BSDF;
            Editor.AddNode(Output2);
        }
コード例 #2
0
        private static NodeValue MaterialNodeValueToUI(Material Mat, MaterialNodeValue MatNodeVal, NodeEditor Editor)
        {
            NodeValue NewNodeValue;

            if (MatNodeVal.Value.Type == MaterialValueType.Input)
            {
                NewNodeValue          = new NodeValueColor(MatNodeVal.Name);
                NewNodeValue.HasValue = false;
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.Output)
            {
                NewNodeValue = new NodeValueOutput(MatNodeVal.Name);
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.Value)
            {
                NewNodeValue           = new NodeValue(MatNodeVal.Name);
                NewNodeValue.HasOutput = false;
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.BoolValue)
            {
                NewNodeValue         = new NodeValueBoolean(MatNodeVal.Name);
                NewNodeValue.Value.X = (MatNodeVal.Value.X == 1)?1:0;
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.IntValue)
            {
                NewNodeValue         = new NodeValueFloat(MatNodeVal.Name);
                NewNodeValue.Value.X = MatNodeVal.Value.X;
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.FloatValue)
            {
                NewNodeValue         = new NodeValueFloat(MatNodeVal.Name);
                NewNodeValue.Value.X = MatNodeVal.Value.X;
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.VertexValue)
            {
                NewNodeValue       = new NodeValueVector(MatNodeVal.Name);
                NewNodeValue.Value = new ValueVector(MatNodeVal.Value.X, MatNodeVal.Value.Y, MatNodeVal.Value.Z);
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.ColorValue)
            {
                NewNodeValue       = new NodeValueColor(MatNodeVal.Name);
                NewNodeValue.Value = new ValueVector(MatNodeVal.Value.X, MatNodeVal.Value.Y, MatNodeVal.Value.Z, MatNodeVal.Value.W);
            }
            else if (MatNodeVal.Value.Type == MaterialValueType.TextureValue)
            {
                NewNodeValue             = new NodeValueImage(MatNodeVal.Name);
                NewNodeValue.Value       = new ValueVector(MatNodeVal.Value.X, MatNodeVal.Value.Y, MatNodeVal.Value.Z, MatNodeVal.Value.W);
                NewNodeValue.Value.Value = MatNodeVal.Value.Value;
            }
            else
            {
                NewNodeValue           = new NodeValue(MatNodeVal.Name);
                NewNodeValue.HasInput  = false;
                NewNodeValue.HasOutput = false;
                NewNodeValue.HasValue  = false;
            }
            NewNodeValue.Source = MatNodeVal;
            if (MatNodeVal.InputTarget != null)
            {
                for (int i = 0; i < Editor.Nodes.Count; i++)
                {
                    if (Editor.Nodes[i].ID == MatNodeVal.InputTarget.Parent.ID)
                    {
                        for (int j = 0; j < Editor.Nodes[i].Values.Count; j++)
                        {
                            if (Editor.Nodes[i].Values[j].Title == MatNodeVal.InputTarget.Name)
                            {
                                NewNodeValue.Input = Editor.Nodes[i].Values[j];
                                Editor.Nodes[i].Values[j].Outputs.Add(NewNodeValue);
                            }
                        }
                    }
                }
            }
            for (int k = 0; k < MatNodeVal.OutputTargets.Count; k++)
            {
                for (int i = 0; i < Editor.Nodes.Count; i++)
                {
                    if (Editor.Nodes[i].ID == MatNodeVal.OutputTargets[k].Parent.ID)
                    {
                        for (int j = 0; j < Editor.Nodes[i].Values.Count; j++)
                        {
                            if (Editor.Nodes[i].Values[j].Title == MatNodeVal.OutputTargets[k].Name)
                            {
                                NewNodeValue.Outputs.Add(Editor.Nodes[i].Values[j]);
                                Editor.Nodes[i].Values[j].Input = NewNodeValue;
                            }
                        }
                    }
                }
            }
            return(NewNodeValue);
        }