示例#1
0
 public MaterialValueHolder(int R, int G, int B, int A)
 {
     this._X    = (R * 1.0 + 1) / 256;
     this._Y    = (G * 1.0 + 1) / 256;
     this._Z    = (B * 1.0 + 1) / 256;
     this._W    = (A * 1.0 + 1) / 256;
     this._Type = MaterialValueType.ColorValue;
 }
示例#2
0
 public MaterialValueHolder(double X, double Y, double Z, double W)
 {
     _X         = X;
     _Y         = Y;
     _Z         = Z;
     _W         = W;
     this._Type = MaterialValueType.ColorValue;
 }
示例#3
0
 public MaterialValueHolder(double X, double Y, double Z)
 {
     _X         = X;
     _Y         = Y;
     _Z         = Z;
     _W         = 1;
     this._Type = MaterialValueType.VertexValue;
 }
示例#4
0
 public MaterialValueHolder()
 {
     _X         = 0;
     _Y         = 0;
     _Z         = 0;
     _W         = 1;
     this._Type = MaterialValueType.VertexValue;
 }
示例#5
0
 public MaterialValueHolder(string Value)
 {
     this._X     = 0;
     this._Y     = 0;
     this._Z     = 0;
     this._W     = 0;
     this._Value = Value;
     this._Type  = MaterialValueType.TextureValue;
 }
 public ShaderMaterialTranslatorEntryInput()
 {
     this._Name         = "";
     this._Type         = MaterialValueType.VertexValue;
     this._DefaultValue = null;
 }
        public static MaterialNodeValue FindConnection(MaterialNode Parent, string ID, string ValueName, MaterialValueType Type)
        {
            Material HolderMaterial = Parent.Holder;

            for (int i = 0; i < HolderMaterial.Nodes.Count; i++)
            {
                if (HolderMaterial.Nodes[i].ID == ID)
                {
                    if (Type == MaterialValueType.Input)
                    {
                        for (int j = 0; j < HolderMaterial.Nodes[i].Inputs.Count; j++)
                        {
                            if (HolderMaterial.Nodes[i].Inputs[j].Name == ValueName)
                            {
                                return(HolderMaterial.Nodes[i].Inputs[j]);
                            }
                        }
                    }
                    else if (Type == MaterialValueType.Output)
                    {
                        for (int j = 0; j < HolderMaterial.Nodes[i].Outputs.Count; j++)
                        {
                            if (HolderMaterial.Nodes[i].Outputs[j].Name == ValueName)
                            {
                                return(HolderMaterial.Nodes[i].Outputs[j]);
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public MaterialNodeValue(MaterialNode Parent, XmlNode XNode, MaterialValueType Type)
        {
            this._Name          = "Unnamed";
            this._Value         = new MaterialValueHolder();
            this._InputTarget   = null;
            this.Parent         = Parent;
            this._OutputTargets = new List <MaterialNodeValue>();
            if (Type == MaterialValueType.Output)
            {
                this._Value.Type = MaterialValueType.Output;
            }
            else if (Type == MaterialValueType.Input)
            {
                this._Value.Type = MaterialValueType.Input;
            }
            XmlNode XValue = null;

            for (int i = 0; i < XNode.ChildNodes.Count; i++)
            {
                if (XNode.ChildNodes[i].Name == "Name")
                {
                    this._Name = XNode.ChildNodes[i].InnerText;
                }
                if (XNode.ChildNodes[i].Name == "Type")
                {
                    if (XNode.ChildNodes[i].InnerText == "Input")
                    {
                        this._Value.Type = MaterialValueType.Input;
                    }
                    else if (XNode.ChildNodes[i].InnerText == "Output")
                    {
                        this._Value.Type = MaterialValueType.Output;
                    }
                    else if (XNode.ChildNodes[i].InnerText == "Bool")
                    {
                        this._Value.Type = MaterialValueType.BoolValue;
                    }
                    else if (XNode.ChildNodes[i].InnerText == "Int")
                    {
                        this._Value.Type = MaterialValueType.IntValue;
                    }
                    else if (XNode.ChildNodes[i].InnerText == "Float")
                    {
                        this._Value.Type = MaterialValueType.FloatValue;
                    }
                    else if (XNode.ChildNodes[i].InnerText == "Vertex")
                    {
                        this._Value.Type = MaterialValueType.VertexValue;
                    }
                    else if (XNode.ChildNodes[i].InnerText == "Color")
                    {
                        this._Value.Type = MaterialValueType.ColorValue;
                    }
                    else if (XNode.ChildNodes[i].InnerText == "Image")
                    {
                        this._Value.Type = MaterialValueType.TextureValue;
                    }
                }
                if (XNode.ChildNodes[i].Name == "Value")
                {
                    XValue = XNode.ChildNodes[i];
                }
                if (XNode.ChildNodes[i].Name == "Connect")
                {
                    string TargetID        = XNode.ChildNodes[i].ChildNodes[0].InnerText;
                    string TragetNodeValue = XNode.ChildNodes[i].ChildNodes[1].InnerText;
                    if (Type == MaterialValueType.Input)
                    {
                        MaterialNodeValue Connection = FindConnection(Parent, TargetID, TragetNodeValue, MaterialValueType.Output);
                        if (Connection != null)
                        {
                            this._InputTarget = Connection;
                            Connection.OutputTargets.Add(this);
                        }
                    }
                    else if (Type == MaterialValueType.Output)
                    {
                        MaterialNodeValue Connection = FindConnection(Parent, TargetID, TragetNodeValue, MaterialValueType.Input);
                        if (Connection != null)
                        {
                            Connection._InputTarget = this;
                            this.OutputTargets.Add(Connection);
                        }
                    }
                }
            }
            SetValue(XValue);
        }