Beispiel #1
0
 public static Node CreateNode(ShaderFragmentArchive.Function fn, String archiveName, HyperGraph.GraphControl graphControl, ShaderDiagram.Document doc)
 {
     var node = new Node(fn.Name);
     node.Tag = new ShaderProcedureNodeTag(archiveName);
     node.AddItem(new ShaderFragmentPreviewItem(graphControl, doc));
     foreach (var param in fn.InputParameters)
     {
         node.AddItem(new ShaderFragmentNodeItem(param.Name, param.Type, archiveName + ":" + param.Name, true, false));
     }
     foreach (var output in fn.Outputs)
     {
         node.AddItem(new ShaderFragmentNodeItem(output.Name, output.Type, archiveName + ":" + output.Name, false, true));
     }
     return node;
 }
Beispiel #2
0
        private static NodeItem FindOrCreateNodeItem(Node node, Func<NodeItem, bool> predicate, Func<NodeItem> creator)
        {
            foreach (var i in node.Items)
                if (predicate(i))
                    return i;

            var newItem = creator();
            node.AddItem(newItem);
            return newItem;
        }
Beispiel #3
0
 public static Node CreateEmptyParameterNode(ShaderFragmentArchive.Parameter.SourceType sourceType, String archiveName, String title)
 {
     var node = new Node(title);
     node.Tag = new ShaderParameterNodeTag(archiveName);
     int selectedIndex = 0;
     List<String> typeNames = new List<String>();
     foreach (var e in Enum.GetValues(typeof(ShaderFragmentArchive.Parameter.SourceType)).Cast<ShaderFragmentArchive.Parameter.SourceType>())
     {
         if (e == sourceType)
         {
             selectedIndex = typeNames.Count;
         }
         typeNames.Add(AsString(e));
     }
     var typeSelection = new HyperGraph.Items.NodeDropDownItem(typeNames.ToArray(), selectedIndex, false, false);
     node.AddItem(typeSelection);
     typeSelection.SelectionChanged += ParameterNodeTypeChanged;
     return node;
 }