Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ModelRendererState.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;
4 using System.Collections.Generic;
5 using SiliconStudio.Core;
6 
7 namespace SiliconStudio.Paradox.Effects
8 {
9  /// <summary>
10  /// State stored in a <see cref="RenderPipeline"/> by a <see cref="ModelRenderer"/>
11  /// </summary>
12  internal class ModelRendererState
13  {
14  #region Constants and Fields
15 
16  public static PropertyKey<ModelRendererState> Key = new PropertyKey<ModelRendererState>("ModelRendererState", typeof(ModelRendererState));
17 
18  private readonly Dictionary<RenderPass, int> modelSlotMapping = new Dictionary<RenderPass, int>();
19 
20  #endregion
21 
22  /// <summary>
23  /// Initializes a new instance of the <see cref="ModelRendererState"/> class.
24  /// </summary>
25  public ModelRendererState()
26  {
27  RenderModels = new List<RenderModel>();
28  }
29 
30  /// <summary>
31  /// Gets the mesh pass slot count.
32  /// </summary>
33  /// <value>The mesh pass slot count.</value>
34  public int ModelSlotCount
35  {
36  get
37  {
38  return modelSlotMapping.Count;
39  }
40  }
41 
42  /// <summary>
43  /// Gets a value indicating whether this instance is valid.
44  /// </summary>
45  /// <value><c>true</c> if this instance is valid; otherwise, <c>false</c>.</value>
46  public bool IsValid
47  {
48  get
49  {
50  return AcceptModel != null && PrepareRenderModel != null && AcceptRenderModel != null;
51  }
52  }
53 
54  /// <summary>
55  /// The action that will be applied on every model to test whether to add it to the render pipeline.
56  /// </summary>
57  public Func<IModelInstance, bool> AcceptModel { get; set; }
58 
59  /// <summary>
60  /// Gets or sets the prepare render model.
61  /// </summary>
62  /// <value>The prepare render model.</value>
63  public Action<RenderModel> PrepareRenderModel { get; set; }
64 
65  /// <summary>
66  /// The action that will be applied on every render model to check
67  /// </summary>
68  /// <value>The process mesh.</value>
69  public Func<RenderModel, bool> AcceptRenderModel { get; set; }
70 
71  /// <summary>
72  /// Gets the current list of models to render.
73  /// </summary>
74  /// <value>The render models.</value>
75  public List<RenderModel> RenderModels { get; private set; }
76 
77  /// <summary>
78  /// Gets or creates a mesh pass slot for this pass inside its <see cref="RenderPipeline" />.
79  /// </summary>
80  /// <param name="renderPass">The render pass.</param>
81  /// <returns>A mesh pass slot.</returns>
82  public int GetModelSlot(RenderPass renderPass)
83  {
84  int meshPassSlot;
85  if (!modelSlotMapping.TryGetValue(renderPass, out meshPassSlot))
86  {
87  modelSlotMapping[renderPass] = meshPassSlot = modelSlotMapping.Count;
88  }
89  return meshPassSlot;
90  }
91  }
92 }
_Use_decl_annotations_ bool IsValid(DXGI_FORMAT fmt)
Definition: DirectXTex.inl:25
A class that represents a tag propety.
Definition: PropertyKey.cs:17