public MaterialNodeValue(string Name, MaterialNode Parent) { this._Name = Name; this._Value = new MaterialValueHolder(); this._InputTarget = null; this.Parent = Parent; this._OutputTargets = new List <MaterialNodeValue>(); }
public MaterialNodeValue() { this._Name = Guid.NewGuid().ToString(); this._Value = new MaterialValueHolder(); this._InputTarget = null; this.Parent = null; this._OutputTargets = new List <MaterialNodeValue>(); }
public MaterialNodeValue(MaterialNodeValue Value, MaterialNode Parent) { this._Name = Value.Name; this._Value = new MaterialValueHolder(Value._Value.X, Value._Value.Y, Value._Value.Z, Value._Value.W); this._Value.Type = Value._Value.Type; this._Value.Value = Value._Value.Value; this._Parent = Parent; this._InputTarget = null; this._OutputTargets = new List <MaterialNodeValue>(); if (Value.InputTarget != null) { int InputTargetNodeIndex = Value.InputTarget.Parent.Index; if (Parent.Holder.Nodes.Count > InputTargetNodeIndex) { MaterialNode Target = Parent.Holder.Nodes[InputTargetNodeIndex]; int Index = -1; for (int i = 0; i < Target.Outputs.Count; i++) { if (Target.Outputs[i].Name == Value.InputTarget.Name) { Index = i; } if (Index != -1) { this._InputTarget = Target.Outputs[Index]; } } } } for (int i = 0; i < Value.OutputTargets.Count; i++) { int OutputtTargetNodeIndex = Value.OutputTargets[i].Parent.Index; if (Parent.Holder.Nodes.Count > OutputtTargetNodeIndex) { MaterialNode Target = Parent.Holder.Nodes[OutputtTargetNodeIndex]; int Index = -1; for (int j = 0; j < Target.Inputs.Count; j++) { if (Target.Inputs[j].Name == Value.OutputTargets[i].Name) { Index = j; } if (Index != -1) { this._OutputTargets.Add(Target.Inputs[Index]); } } } } }
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); }