Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CubemapBlendProcessor.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.Collections.Generic;
5 
6 using SiliconStudio.Core;
7 using SiliconStudio.Paradox.Engine;
8 using SiliconStudio.Paradox.EntityModel;
9 using SiliconStudio.Paradox.Graphics;
10 
11 namespace SiliconStudio.Paradox.Effects.Modules.Processors
12 {
13  /// <summary>
14  /// Keeps track of active cubemap blending locations.
15  /// </summary>
16  public class CubemapBlendProcessor : EntityProcessor<CubemapBlendComponent>
17  {
18  #region Private members
19 
20  private readonly GraphicsDevice graphicsDevice;
21 
22  #endregion
23 
24  #region Public properties
25 
26  /// <summary>
27  /// The enabled cubemap blends
28  /// </summary>
29  public Dictionary<Entity, CubemapBlendComponent> Cubemaps
30  {
31  get
32  {
33  return this.enabledEntities;
34  }
35  }
36 
37  #endregion
38 
39  #region Constructor
40 
42  : base(new PropertyKey[] { CubemapBlendComponent.Key })
43  {
44  graphicsDevice = device;
45  }
46 
47  #endregion
48 
49  #region Protected methods
50 
51  /// <inheritdoc/>
52  protected override void OnEntityAdding(Entity entity, CubemapBlendComponent data)
53  {
54  base.OnEntityAdding(entity, data);
55  data.Texture = TextureCube.New(graphicsDevice, data.Size, 1, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
56 
57  // add parameter to model
58  var model = entity.Get<ModelComponent>();
59  if (model != null)
60  model.Parameters.Set(data.TextureKey ?? TexturingKeys.TextureCube0, data.Texture);
61  }
62 
63  /// <inheritdoc/>
64  protected override void OnEntityRemoved(Entity entity, CubemapBlendComponent data)
65  {
66  base.OnEntityRemoved(entity, data);
67  // TODO: remove texture?
68  }
69 
70  /// <inheritdoc/>
72  {
73  return entity.Get<CubemapBlendComponent>();
74  }
75 
76  #endregion
77  }
78 }
override void OnEntityRemoved(Entity entity, CubemapBlendComponent data)
Game entity. It usually aggregates multiple EntityComponent
Definition: Entity.cs:28
Entity processor, triggered on various EntitySystem events such as Entity and Component additions and...
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
Add a Model to an Entity, that will be used during rendering.
Performs a blend at the location of the containing entity. When enabled, takes the up to the MaxBlend...
override void OnEntityAdding(Entity entity, CubemapBlendComponent data)
A class that represents a tag propety.
Definition: PropertyKey.cs:17
override CubemapBlendComponent GenerateAssociatedData(Entity entity)