Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CubemapBlendComponent.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 
4 using System.ComponentModel;
5 
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.Serialization.Converters;
8 using SiliconStudio.Paradox.Effects;
9 using SiliconStudio.Paradox.EntityModel;
10 using SiliconStudio.Paradox.Graphics;
11 
12 namespace SiliconStudio.Paradox.Engine
13 {
14  /// <summary>
15  /// Performs a blend at the location of the containing entity. When enabled, takes the up to the MaxBlendCount-most important cubemaps and blends them.
16  /// </summary>
17  [DataConverter(AutoGenerate = true)]
18  [DataContract("CubemapBlendComponent")]
19  public sealed class CubemapBlendComponent : EntityComponent
20  {
22 
23  [DataMemberIgnore]
24  private TextureCube textureCube;
25 
26  /// <summary>
27  /// Initializes a new instance of the <see cref="CubemapBlendComponent"/> class.
28  /// </summary>
30  {
31  Size = 256;
32  MaxBlendCount = 0;
33  MaxLod = 0;
34  textureCube = null;
35  RenderTargets = null;
36  TextureKey = null;
37  }
38 
39  /// <summary>
40  /// Enables the computation of the cubemap.
41  /// </summary>
42  [DataMemberConvert]
43  public bool Enabled { get; set; }
44 
45  /// <summary>
46  /// The size of the target cubemap.
47  /// </summary>
48  [DataMemberConvert]
49  [DefaultValue(256)]
50  public int Size { get; set; }
51 
52  /// <summary>
53  /// The maximum number of cubemaps that can be blended. 0 means as much as possible.
54  /// </summary>
55  [DataMemberConvert]
56  [DefaultValue(0)]
57  public int MaxBlendCount { get; set; }
58 
59  /// <summary>
60  /// The maximum lod of the texture.
61  /// </summary>
62  [DataMemberIgnore]
63  public int MaxLod { get; private set; }
64 
65  /// <summary>
66  /// The texture attached to this component.
67  /// </summary>
68  [DataMemberIgnore]
69  public TextureCube Texture
70  {
71  get
72  {
73  return textureCube;
74  }
75  set
76  {
77  textureCube = value;
78  // TODO: check previous status to dispose the rendertarget?
79  if (textureCube != null)
80  {
81  MaxLod = textureCube.Description.MipLevels - 1;
82  RenderTargets = new RenderTarget[6]
83  {
84  textureCube.ToRenderTarget(ViewType.Single, 0, 0),
85  textureCube.ToRenderTarget(ViewType.Single, 1, 0),
86  textureCube.ToRenderTarget(ViewType.Single, 2, 0),
87  textureCube.ToRenderTarget(ViewType.Single, 3, 0),
88  textureCube.ToRenderTarget(ViewType.Single, 4, 0),
89  textureCube.ToRenderTarget(ViewType.Single, 5, 0)
90  };
91  }
92  }
93  }
94 
95  /// <summary>
96  /// The parameter key the texture will be associated to.
97  /// </summary>
98  [DataMemberConvert]
99  [DefaultValue(null)]
100  public ParameterKey<Texture> TextureKey { get; set; }
101 
102  /// <summary>
103  /// The render targets of the cubemap.
104  /// </summary>
105  [DataMemberIgnore]
106  public RenderTarget[] RenderTargets { get; private set; }
107 
108  public override PropertyKey DefaultKey
109  {
110  get { return Key; }
111  }
112  }
113 }
Key of an effect parameter.
Definition: ParameterKey.cs:15
A TextureCube frontend to SharpDX.Direct3D11.Texture2D.
Definition: TextureCube.cs:37
Base class for converters to/from a data type.
CubemapBlendComponent()
Initializes a new instance of the CubemapBlendComponent class.
ViewType
Defines how a view is selected from a resource.
Definition: ViewType.cs:31
Performs a blend at the location of the containing entity. When enabled, takes the up to the MaxBlend...
A class that represents a tag propety.
Definition: PropertyKey.cs:17
Base class for texture resources.
Definition: Texture.cs:38