Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
RenderModel.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 
6 namespace SiliconStudio.Paradox.Effects
7 {
8  /// <summary>
9  /// Instantiation of a <see cref="Model"/> through a <see cref="RenderPipeline"/>.
10  /// </summary>
11  public sealed class RenderModel
12  {
13  /// <summary>
14  /// Initializes a new instance of the <see cref="RenderModel" /> class.
15  /// </summary>
16  /// <param name="pipeline">The pipeline.</param>
17  /// <param name="modelInstance">The model instance.</param>
18  /// <exception cref="System.ArgumentNullException">pipeline</exception>
19  public RenderModel(RenderPipeline pipeline, IModelInstance modelInstance)
20  {
21  if (pipeline == null) throw new ArgumentNullException("pipeline");
22 
23  Pipeline = pipeline;
24  ModelInstance = modelInstance;
25  Model = modelInstance.Model;
26  Parameters = modelInstance.Parameters;
27 
28  var modelRendererState = Pipeline.GetOrCreateModelRendererState();
29  var slotCount = modelRendererState.ModelSlotCount;
30  RenderMeshes = new List<RenderMesh>[slotCount];
31  if (Model != null)
32  {
33  modelRendererState.PrepareRenderModel(this);
34  }
35  }
36 
37  /// <summary>
38  /// Initializes a new instance of the <see cref="RenderModel"/> class.
39  /// </summary>
40  /// <param name="pipeline">The pipeline.</param>
41  /// <param name="model">The model.</param>
42  /// <exception cref="System.ArgumentNullException">pipeline</exception>
43  [Obsolete]
44  public RenderModel(RenderPipeline pipeline, Model model)
45  {
46  if (pipeline == null) throw new ArgumentNullException("pipeline");
47  Pipeline = pipeline;
48  Model = model;
49  var slotCount = Pipeline.GetOrCreateModelRendererState().ModelSlotCount;
50  RenderMeshes = new List<RenderMesh>[slotCount];
51  }
52 
53  /// <summary>
54  /// Gets the meshes instantiated for this view.
55  /// </summary>
56  /// <value>
57  /// The meshes instantiated for this view.
58  /// </value>
59  public readonly List<RenderMesh>[] RenderMeshes;
60 
61  /// <summary>
62  /// The model instance
63  /// </summary>
64  public readonly IModelInstance ModelInstance;
65 
66  /// <summary>
67  /// Gets the underlying model.
68  /// </summary>
69  /// <value>
70  /// The underlying model.
71  /// </value>
72  public readonly Model Model;
73 
74  /// <summary>
75  /// Gets the instance parameters to this model.
76  /// </summary>
77  /// <value>
78  /// The instance parameters to this model.
79  /// </value>
81 
82  /// <summary>
83  /// Gets the render pipeline.
84  /// </summary>
85  /// <value>
86  /// The render pipeline.
87  /// </value>
88  public readonly RenderPipeline Pipeline;
89  }
90 }
RenderModel(RenderPipeline pipeline, IModelInstance modelInstance)
Initializes a new instance of the RenderModel class.
Definition: RenderModel.cs:19
readonly RenderPipeline Pipeline
Gets the render pipeline.
Definition: RenderModel.cs:88
Instance of a model with its parameters.
Instantiation of a Model through a RenderPipeline.
Definition: RenderModel.cs:11
readonly List< RenderMesh >[] RenderMeshes
Gets the meshes instantiated for this view.
Definition: RenderModel.cs:59
readonly Model Model
Gets the underlying model.
Definition: RenderModel.cs:72
readonly ParameterCollection Parameters
Gets the instance parameters to this model.
Definition: RenderModel.cs:80
RenderModel(RenderPipeline pipeline, Model model)
Initializes a new instance of the RenderModel class.
Definition: RenderModel.cs:44
readonly IModelInstance ModelInstance
The model instance
Definition: RenderModel.cs:64
Defines an entry point for mesh instantiation and recursive rendering.
Collection of Mesh, each one usually being a different LOD of the same Model. The effect system will ...
Definition: Model.cs:23
A container to handle a hierarchical collection of effect variables.