Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MaterialParametersVisitor.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using SiliconStudio.Paradox.Assets.Materials.Nodes;
4 using SiliconStudio.Paradox.Effects.Data;
5 
6 namespace SiliconStudio.Paradox.Assets.Materials.Processor.Visitors
7 {
9  {
11  : base(mat)
12  {
13  }
14 
16  {
17  var parameters = new ParameterCollectionData();
18  foreach (var startNodeName in Material.ColorNodes)
19  {
20  var startNode = Material.FindNode(startNodeName.Value);
21  if (startNode != null)
22  {
23  GetParametersFromNode(startNode, parameters);
24  }
25  }
26  return parameters;
27  }
28 
29  /// <summary>
30  /// Gather all the parameters in the node hierarchy.
31  /// </summary>
32  /// <param name="node">The node to look into.</param>
33  /// <param name="parameters">The parameter collection to fill.</param>
34  private void GetParametersFromNode(IMaterialNode node, ParameterCollectionData parameters)
35  {
36  if (node == null)
37  return;
38 
39  node.VisitNodes((context, nodeEntry) =>
40  {
41  var shaderNode = nodeEntry.Node as MaterialShaderClassNode;
42  if (shaderNode != null)
43  {
44  //foreach (var member in shaderNode.Members)
45  foreach (var member in shaderNode.GetParameters(context))
46  parameters.Set(member.Key, member.Value);
47  }
48  }, new MaterialContext { Material = Material, ExploreGenerics = false });
49  }
50  }
51 }
Data type for SiliconStudio.Paradox.Effects.ParameterCollection.
Definition: ParadoxData.cs:31
Base interface for all nodes in the material tree