Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CameraProcessor.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using System.Collections.Specialized;
3 using System.Linq;
4 using System.Threading.Tasks;
5 using Paradox.DataModel;
6 using Paradox.Effects;
7 using Paradox.EntityModel;
8 using Paradox.Framework;
9 using Paradox.Framework.Extensions;
10 using Paradox.Framework.Serialization.Assets;
11 using Paradox.Framework.Serialization.Contents;
12 
13 namespace Paradox.Engine
14 {
15  /*
16  public class CameraProcessor : EntityProcessor<CameraComponent>
17  {
18  private RenderSystem renderSystem;
19  private EffectSystem effectSystem;
20 
21  public CameraProcessor()
22  : base(new PropertyKey[] { MeshComponent.Key })
23  {
24  }
25 
26  protected internal override void OnSystemAdd()
27  {
28  renderSystem = (RenderSystem) Services.GetSafeServiceAs<IRenderSystem>();
29  effectSystem = (EffectSystem)Services.GetSafeServiceAs<IEffectSystem>();
30  }
31 
32  protected override CameraComponent GenerateAssociatedData(Entity entity)
33  {
34  return entity.Get(CameraComponent.Key);
35  }
36 
37  protected override void OnEntityAdded(Entity entity, CameraComponent cameraComponent)
38  {
39  var instantiatedSubMeshes = cameraComponent.InstantiatedSubMeshes;
40  cameraComponent.MeshComponent.InstantiatedSubMeshes = instantiatedSubMeshes;
41 
42  if (instantiatedSubMeshes != null)
43  {
44  foreach (var effectMesh in instantiatedSubMeshes)
45  {
46  renderSystem.GlobalMeshes.AddMesh(effectMesh.Value);
47  }
48  }
49  }
50 
51  protected override void OnEntityRemoved(Entity entity, CameraComponent associatedData)
52  {
53  var instantiatedSubMeshes = associatedData.InstantiatedSubMeshes;
54 
55  if (instantiatedSubMeshes != null)
56  {
57  foreach (var effectMesh in instantiatedSubMeshes)
58  {
59  renderSystem.GlobalMeshes.RemoveMesh(effectMesh.Value);
60  }
61  }
62  }
63 
64 
65  public override void Update()
66  {
67  //renderSystem.DataContext.RenderPassPlugins.
68 
69 
70 
71 
72  foreach (var entity in matchingEntities)
73  {
74  UpdateCamera(entity.Key, entity.Value);
75  }
76  }
77 
78  private EffectMesh GenerateEffectMesh(MeshComponent meshComponent, EffectMeshData effectMeshData)
79  {
80  var effect = effectSystem.CreateEffect(effectMeshData);
81  var effectMesh = new EffectMesh(effect, effectMeshData);
82 
83  // TODO: Copy of parameters? (depending on prefab/clone processor)
84  //effectMesh.Parameters.AddSources(effectMeshData.Parameters);
85  effectMesh.Parameters.AddSources(meshComponent.MeshParameters);
86 
87  if (effectMesh.Permutations != null)
88  effectMesh.Permutations.AddSources(meshComponent.Permutations);
89 
90  return effectMesh;
91  }
92 
93  void instantiatedSubMeshes_CollectionChanged(object sender, Framework.Collections.TrackingCollectionChangedEventArgs e)
94  {
95  var effectMesh = (EffectMesh)e.Item;
96  switch (e.Action)
97  {
98  case NotifyCollectionChangedAction.Add:
99  renderSystem.GlobalMeshes.AddMesh(effectMesh);
100  break;
101  case NotifyCollectionChangedAction.Remove:
102  renderSystem.GlobalMeshes.RemoveMesh(effectMesh);
103  break;
104  }
105  }
106  }
107  */
108 }