Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ParticleEmitterComponent.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.Runtime.InteropServices;
5 using SiliconStudio.Core.Serialization.Converters;
6 using SiliconStudio.Paradox.Effects;
7 using SiliconStudio.Paradox.EntityModel;
8 using SiliconStudio.Paradox.Games;
9 using SiliconStudio.Core;
10 using SiliconStudio.Core.Collections;
11 using SiliconStudio.Core.Mathematics;
12 using SiliconStudio.Paradox.Shaders;
13 
14 namespace SiliconStudio.Paradox.Engine
15 {
16  [Display("Particle Emitter")]
18  {
20 
21  /// <summary>
22  /// Initializes a new instance of the <see cref="ParticleEmitterComponent" /> class.
23  /// </summary>
25  {
26  Parameters = new ParameterCollection();
27  }
28 
29  /// <summary>
30  /// Gets or sets the particle count.
31  /// </summary>
32  /// <value>The particle count.</value>
33  [DataMemberConvert]
34  [Display]
35  public int Count { get; set; }
36 
37  /// <summary>
38  /// Gets or sets the type of this emitter..
39  /// </summary>
40  /// <value>The type.</value>
41  [DataMemberConvert]
42  [Display]
43  public ParticleEmitterType Type { get; set; }
44 
45  /// <summary>
46  /// Gets or sets the shader.
47  /// </summary>
48  /// <value>The shader.</value>
49  [DataMemberConvert]
50  public ShaderClassSource Shader { get; set; }
51 
52  /// <summary>
53  /// Gets or sets the parameters.
54  /// </summary>
55  /// <value>The parameters.</value>
56  public ParameterCollection Parameters { get; set; }
57 
58  /// <summary>
59  /// Gets or sets the size of the particle element.
60  /// </summary>
61  /// <value>The size of the particle element.</value>
62  public int ParticleElementSize { get; set; }
63 
64  /// <summary>
65  /// Gets or sets the particle data.
66  /// </summary>
67  /// <value>The particle data.</value>
68  public Array ParticleData { get; set; }
69 
70  /// <summary>
71  /// Gets or sets a value indicating whether [update next buffer].
72  /// </summary>
73  /// <value><c>true</c> if [update next buffer]; otherwise, <c>false</c>.</value>
74  public bool UpdateNextBuffer { get; set; }
75 
76  /// <summary>
77  /// Gets a value indicating whether this instance is a dynamic emitter.
78  /// </summary>
79  /// <value><c>true</c> if this instance is a dynamic emitter; otherwise, <c>false</c>.</value>
80  public bool IsDynamicEmitter
81  {
82  get
83  {
84  return Type == ParticleEmitterType.CpuDynamic || Type == ParticleEmitterType.GpuDynamic;
85  }
86  }
87 
88  public event Action<ParticleEmitterComponent> UpdateData;
89 
90  public void OnUpdateData()
91  {
92  var updateData = UpdateData;
93  if (updateData != null) updateData(this);
94  }
95 
96  public event Action<ParticleEmitterComponent> UpdateSystem;
97 
98  public void OnUpdateSystem()
99  {
100  var updateSystem = UpdateSystem;
101  if (updateSystem != null) updateSystem(this);
102  }
103 
104  /// <summary>
105  /// A callback called whenever the component is updated by the ParticleSystem.
106  /// </summary>
107  public event Action<ParticleEmitterComponent, Entity, TrackingCollectionChangedEventArgs> MeshUpdate;
108 
109  public virtual void OnAddToSystem(IServiceRegistry registry)
110  {
111 
112  }
113 
115  {
116  var update = MeshUpdate;
117  if (update != null) update(this, Entity, updateArgs);
118  }
119 
120  public static int CalculateMaximumPowerOf2Count(int value)
121  {
122  return (int)Math.Pow(2.0, Math.Ceiling(Math.Log(value, 2)));
123  }
124 
125  public override PropertyKey DefaultKey
126  {
127  get { return Key; }
128  }
129  }
130 }
Game entity. It usually aggregates multiple EntityComponent
Definition: Entity.cs:28
A service registry is a IServiceProvider that provides methods to register and unregister services...
Action< ParticleEmitterComponent, Entity, TrackingCollectionChangedEventArgs > MeshUpdate
A callback called whenever the component is updated by the ParticleSystem.
void OnMeshUpdate(Entity entity, TrackingCollectionChangedEventArgs updateArgs)
A class that represents a tag propety.
Definition: PropertyKey.cs:17
ParticleEmitterComponent()
Initializes a new instance of the ParticleEmitterComponent class.
A container to handle a hierarchical collection of effect variables.