Exemplo n.º 1
0
		public ParticleManager(Game game, Renderer renderer) {
			this.Renderer = renderer;
			Game = game;
			mParticle = new Particle[1000];
			mParticleDis = new Particle[20];
			mParticleMesh = new Particle[20];
			Modelset = new Model[100];
		}
Exemplo n.º 2
0
		private void DrawModel(ref Particle particle, Renderer renderer, bool texturepath) {
			foreach (ModelMesh mesh in particle.Model.Meshes) {
				foreach (BasicEffect effect in mesh.Effects) {
					effect.EnableDefaultLighting();

					effect.View = renderer.Camera.View;
					effect.Projection = renderer.Camera.Projection;
					effect.World = particle.World;
					effect.Alpha = particle.Alpha;
					if (texturepath) {
						effect.Texture = particle.Texture;
					}
					effect.TextureEnabled = true;
					effect.FogEnabled = true;
					effect.FogEnd = 200;
					effect.FogStart = 1;
					effect.FogColor = renderer.FogColor;
				}
				mesh.Draw();
			}

		}
Exemplo n.º 3
0
		public void DrawAdditive(GameTime gameTime, Renderer renderer) {
			renderer.GraphicsDevice.DepthStencilState = new DepthStencilState() {
				DepthBufferWriteEnable = false
			};
			for (int i = 0; i < mParticle.Length; i++) {
				if (mParticle[i].Active && mParticle[i].AdditiveRender) {
					DrawModel(ref mParticle[i], renderer, true);
				}
			}
		}
Exemplo n.º 4
0
		public void DrawMesh(GameTime gameTime, Renderer renderer) {
			for (int i = 0; i < mParticleMesh.Length; i++) {
				if (mParticleMesh[i].Active && !mParticleMesh[i].AdditiveRender) {
					DrawModel(ref mParticleMesh[i], renderer, false);
				}
			}
		}
Exemplo n.º 5
0
		public void Update(GameTime gameTime, Renderer renderer, float slowTime) {
			for (int i = 0; i < mParticle.Length; i++) {
				if (!mParticle[i].Active) {
					mParticle[i].Scale = Vector3.Zero;
					mParticle[i].World = Matrix.CreateScale(mParticle[i].Scale) * Matrix.CreateRotationZ(mParticle[i].Rotation.Z) * Matrix.CreateBillboard(mParticle[i].Position, renderer.Camera.Position, Vector3.Up, Vector3.Forward);

					continue;
				}

				mParticle[i].Position.X += mParticle[i].PowerUp1.X * slowTime;
				mParticle[i].Position.Y += mParticle[i].PowerUp1.Y * slowTime;
				mParticle[i].Position.Z += mParticle[i].PowerUp1.Z * slowTime;

				mParticle[i].Rotation.X += mParticle[i].RotationUp1.X * slowTime;
				mParticle[i].Rotation.Y += mParticle[i].RotationUp1.Y * slowTime;
				mParticle[i].Rotation.Z += mParticle[i].RotationUp1.Z * slowTime;

				mParticle[i].Scale.X += mParticle[i].ScaleUp1.X * slowTime;
				mParticle[i].Scale.Y += mParticle[i].ScaleUp1.Y * slowTime;
				mParticle[i].Scale.Z += mParticle[i].ScaleUp1.Z * slowTime;

				mParticle[i].Alpha += mParticle[i].AlphaUp1 * slowTime;

				mParticle[i].PowerUp1.X += mParticle[i].PowerUp2.X * slowTime;
				mParticle[i].PowerUp1.Y += mParticle[i].PowerUp2.Y * slowTime;
				mParticle[i].PowerUp1.Z += mParticle[i].PowerUp2.Z * slowTime;


				mParticle[i].RotationUp1.X += mParticle[i].RotationUp2.X * slowTime;
				mParticle[i].RotationUp1.Y += mParticle[i].RotationUp2.Y * slowTime;
				mParticle[i].RotationUp1.Z += mParticle[i].RotationUp2.Z * slowTime;


				mParticle[i].ScaleUp1.X += mParticle[i].ScaleUp2.X * slowTime;
				mParticle[i].ScaleUp1.Y += mParticle[i].ScaleUp2.Y * slowTime;
				mParticle[i].ScaleUp1.Z += mParticle[i].ScaleUp2.Z * slowTime;


				mParticle[i].AlphaUp1 += mParticle[i].AlphaUp2 * slowTime;

				mParticle[i].BaseColor.X += mParticle[i].BaseColorUp1.X * slowTime;
				mParticle[i].BaseColor.Y += mParticle[i].BaseColorUp1.Y * slowTime;
				mParticle[i].BaseColor.Z += mParticle[i].BaseColorUp1.Z * slowTime;

				mParticle[i].BaseColorUp1.X += mParticle[i].BaseColorUp2.X * slowTime;
				mParticle[i].BaseColorUp1.Y += mParticle[i].BaseColorUp2.Y * slowTime;
				mParticle[i].BaseColorUp1.Z += mParticle[i].BaseColorUp2.Z * slowTime;

				mParticle[i].World = Matrix.CreateScale(mParticle[i].Scale) * Matrix.CreateRotationZ(mParticle[i].Rotation.Z) * Matrix.CreateBillboard(mParticle[i].Position, renderer.Camera.Position, Vector3.Up, Vector3.Forward);
				mParticle[i].LifeTime -= 1 * slowTime;
				if (mParticle[i].LifeTime <= 0 || mParticle[i].Alpha <= 0.01f) {
					mParticle[i].Reset();
				}
			}


			for (int i = 0; i < mParticleMesh.Length; i++) {
				if (!mParticleMesh[i].Active) {
					continue;
				}

				mParticleMesh[i].Position.X += mParticleMesh[i].PowerUp1.X * slowTime;
				mParticleMesh[i].Position.Y += mParticleMesh[i].PowerUp1.Y * slowTime;
				mParticleMesh[i].Position.Z += mParticleMesh[i].PowerUp1.Z * slowTime;

				mParticleMesh[i].Rotation.X += mParticleMesh[i].RotationUp1.X * slowTime;
				mParticleMesh[i].Rotation.Y += mParticleMesh[i].RotationUp1.Y * slowTime;
				mParticleMesh[i].Rotation.Z += mParticleMesh[i].RotationUp1.Z * slowTime;

				mParticleMesh[i].Scale.X += mParticleMesh[i].ScaleUp1.X * slowTime;
				mParticleMesh[i].Scale.Y += mParticleMesh[i].ScaleUp1.Y * slowTime;
				mParticleMesh[i].Scale.Z += mParticleMesh[i].ScaleUp1.Z * slowTime;

				mParticleMesh[i].PowerUp1.X += mParticleMesh[i].PowerUp2.X * slowTime;
				mParticleMesh[i].PowerUp1.Y += mParticleMesh[i].PowerUp2.Y * slowTime;
				mParticleMesh[i].PowerUp1.Z += mParticleMesh[i].PowerUp2.Z * slowTime;


				mParticleMesh[i].RotationUp1.X += mParticleMesh[i].RotationUp2.X * slowTime;
				mParticleMesh[i].RotationUp1.Y += mParticleMesh[i].RotationUp2.Y * slowTime;
				mParticleMesh[i].RotationUp1.Z += mParticleMesh[i].RotationUp2.Z * slowTime;


				mParticleMesh[i].ScaleUp1.X += mParticleMesh[i].ScaleUp2.X * slowTime;
				mParticleMesh[i].ScaleUp1.Y += mParticleMesh[i].ScaleUp2.Y * slowTime;
				mParticleMesh[i].ScaleUp1.Z += mParticleMesh[i].ScaleUp2.Z * slowTime;

				mParticleMesh[i].World = Matrix.CreateScale(mParticleMesh[i].Scale) *Matrix.CreateRotationZ(mParticleMesh[i].Rotation.Z) *Matrix.CreateBillboard(mParticleMesh[i].Position, renderer.Camera.Position, Vector3.Up, Vector3.Forward);
				mParticleMesh[i].LifeTime -= 1 * slowTime;
				if (mParticleMesh[i].LifeTime <= 0) {
					mParticleMesh[i].Reset();
				}
			}


			for (int i = 0; i < mParticleDis.Length; i++) {
				if (!mParticleDis[i].Active) {
					continue;
				}

				mParticleDis[i].Position.X += mParticleDis[i].PowerUp1.X * slowTime;
				mParticleDis[i].Position.Y += mParticleDis[i].PowerUp1.Y * slowTime;
				mParticleDis[i].Position.Z += mParticleDis[i].PowerUp1.Z * slowTime;

				mParticleDis[i].Rotation.X += mParticleDis[i].RotationUp1.X * slowTime;
				mParticleDis[i].Rotation.Y += mParticleDis[i].RotationUp1.Y * slowTime;
				mParticleDis[i].Rotation.Z += mParticleDis[i].RotationUp1.Z * slowTime;

				mParticleDis[i].Scale.X += mParticleDis[i].ScaleUp1.X * slowTime;
				mParticleDis[i].Scale.Y += mParticleDis[i].ScaleUp1.Y * slowTime;
				mParticleDis[i].Scale.Z += mParticleDis[i].ScaleUp1.Z * slowTime;

				mParticleDis[i].Alpha += mParticleDis[i].AlphaUp1 * slowTime;

				mParticleDis[i].PowerUp1.X += mParticleDis[i].PowerUp2.X * slowTime;
				mParticleDis[i].PowerUp1.Y += mParticleDis[i].PowerUp2.Y * slowTime;
				mParticleDis[i].PowerUp1.Z += mParticleDis[i].PowerUp2.Z * slowTime;


				mParticleDis[i].RotationUp1.X += mParticleDis[i].RotationUp2.X * slowTime;
				mParticleDis[i].RotationUp1.Y += mParticleDis[i].RotationUp2.Y * slowTime;
				mParticleDis[i].RotationUp1.Z += mParticleDis[i].RotationUp2.Z * slowTime;


				mParticleDis[i].ScaleUp1.X += mParticleDis[i].ScaleUp2.X * slowTime;
				mParticleDis[i].ScaleUp1.Y += mParticleDis[i].ScaleUp2.Y * slowTime;
				mParticleDis[i].ScaleUp1.Z += mParticleDis[i].ScaleUp2.Z * slowTime;


				mParticleDis[i].AlphaUp1 += mParticleDis[i].AlphaUp2 * slowTime;

				mParticleDis[i].BaseColor.X += mParticleDis[i].BaseColorUp1.X * slowTime;
				mParticleDis[i].BaseColor.Y += mParticleDis[i].BaseColorUp1.Y * slowTime;
				mParticleDis[i].BaseColor.Z += mParticleDis[i].BaseColorUp1.Z * slowTime;

				mParticleDis[i].BaseColorUp1.X += mParticleDis[i].BaseColorUp2.X * slowTime;
				mParticleDis[i].BaseColorUp1.Y += mParticleDis[i].BaseColorUp2.Y * slowTime;
				mParticleDis[i].BaseColorUp1.Z += mParticleDis[i].BaseColorUp2.Z * slowTime;

				mParticleDis[i].World = Matrix.CreateScale(mParticleDis[i].Scale) *Matrix.CreateRotationZ(mParticleDis[i].Rotation.Z) *Matrix.CreateBillboard(mParticleDis[i].Position, renderer.Camera.Position, Vector3.Up, Vector3.Forward);
				mParticleDis[i].LifeTime -= 1 * slowTime;
				if (mParticleDis[i].LifeTime <= 0 || mParticleDis[i].Alpha <= 0.01f) {
					mParticleDis[i].Reset();
				}
			}

		}
Exemplo n.º 6
0
		public ParticlePreset(Game game, Renderer renderer)
			: base(game, renderer) {
		}
Exemplo n.º 7
0
		protected override void Initialize() {
			mRendererManager = new Renderer(this);
			mParticle = new ParticlePreset(this, mRendererManager);

			base.Initialize();
		}