Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MaterialBinaryNode.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 System.Collections.Generic;
4 using SiliconStudio.Core;
5 using SiliconStudio.Core.Serialization.Contents;
6 
7 namespace SiliconStudio.Paradox.Assets.Materials.Nodes
8 {
9  /// <summary>
10  /// A node that describe a binary operation between two <see cref="IMaterialNode"/>
11  /// </summary>
12  [ContentSerializer(typeof(DataContentSerializer<MaterialBinaryNode>))]
13  [DataContract("MaterialBinaryNode")]
15  {
16  /// <summary>
17  /// Initializes a new instance of the <see cref="MaterialBinaryNode"/> class.
18  /// </summary>
20  {
21  }
22 
23  /// <summary>
24  /// Initializes a new instance of the <see cref="MaterialBinaryNode"/> class.
25  /// </summary>
26  /// <param name="leftChild">The left child.</param>
27  /// <param name="rightChild">The right child.</param>
28  /// <param name="materialBinaryOperand">The material binary operand.</param>
29  public MaterialBinaryNode(IMaterialNode leftChild, IMaterialNode rightChild, MaterialBinaryOperand materialBinaryOperand)
30  {
31  LeftChild = leftChild;
32  RightChild = rightChild;
33  Operand = materialBinaryOperand;
34  }
35 
36  /// <summary>
37  /// The operation to blend the nodes.
38  /// </summary>
39  /// <userdoc>
40  /// The operation between the background (LeftChild) and the foreground (RightChild).
41  /// </userdoc>
42  [DataMember(10)]
43  public MaterialBinaryOperand Operand { get; set; }
44 
45  /// <summary>
46  /// The left (background) child node.
47  /// </summary>
48  /// <userdoc>
49  /// The background color mapping.
50  /// </userdoc>
51  [DataMember(20)]
52  public IMaterialNode LeftChild { get; set; }
53 
54  /// <summary>
55  /// The right (foreground) child node.
56  /// </summary>
57  /// <userdoc>
58  /// The foreground color mapping.
59  /// </userdoc>
60  [DataMember(30)]
61  public IMaterialNode RightChild { get; set; }
62 
63  /// <inheritdoc/>
64  public override IEnumerable<MaterialNodeEntry> GetChildren(object context = null)
65  {
66  if (LeftChild != null)
67  yield return new MaterialNodeEntry(LeftChild, node => LeftChild = node);
68  if (RightChild != null)
69  yield return new MaterialNodeEntry(RightChild, node => RightChild = node);
70  }
71 
72  /// <inheritdoc/>
73  public override string ToString()
74  {
75  return "Binary operation";
76  }
77  }
78 }
A node that describe a binary operation between two IMaterialNode
An entry to a nested IMaterialNode
MaterialBinaryNode()
Initializes a new instance of the MaterialBinaryNode class.
MaterialBinaryNode(IMaterialNode leftChild, IMaterialNode rightChild, MaterialBinaryOperand materialBinaryOperand)
Initializes a new instance of the MaterialBinaryNode class.
MaterialBinaryOperand
Operands of the MaterialNode.
Base interface for all nodes in the material tree
override IEnumerable< MaterialNodeEntry > GetChildren(object context=null)
Gets the children. The context to get the children.The list of children.