Пример #1
0
        public PointLight(Vector3 position, Vector3 diffuse, float radius)
            : base()
        {
            Position = position;
            Diffuse  = diffuse;
            Radius   = radius;

            // [-1..1]
            velocity = new Vector3(-1 + 2 * (float)UniversalRandom.GetInstance().NextDouble(),
                                   -1 + 2 * (float)UniversalRandom.GetInstance().NextDouble(),
                                   -1 + 2 * (float)UniversalRandom.GetInstance().NextDouble());
            velocity.Normalize();
        }
Пример #2
0
        public virtual void Update(GameTime gameTime)
        {
            shake *= .9f;

            if (shake > 0.01)
            {
                ShakeTransfomation *= Matrix.CreateTranslation(
                    20 * shake * (float)(UniversalRandom.GetInstance().NextDouble() - .5),
                    20 * shake * (float)(UniversalRandom.GetInstance().NextDouble() - .5), 0);
            }
            else
            {
                ShakeTransfomation = Matrix.Identity;
            }

            View *= ShakeTransfomation;
        }
Пример #3
0
        /// <summary>
        /// Spawns particles on the surface of the box.
        /// </summary>
        /// <param name="b"></param>
        /// <param name="yellowSystem"></param>
        public static void IlluminateBoundingBox(this BoundingBox b, ParticleSystem yellowSystem)
        {
            for (int i = 0; i < 20; i++)
            {
                int   face = UniversalRandom.GetInstance().Next(6);
                float u    = (float)UniversalRandom.GetInstance().NextDouble(),
                      v    = (float)UniversalRandom.GetInstance().NextDouble();
                var diff   = b.Max - b.Min;
                switch (face)
                {
                case 0:
                    yellowSystem.AddParticle(b.Min + new Vector3(u * diff.X, v * diff.Y, 0), Vector3.Zero);
                    break;

                case 1:
                    yellowSystem.AddParticle(b.Min + new Vector3(0, v * diff.Y, u * diff.Z), Vector3.Zero);
                    break;

                case 2:
                    yellowSystem.AddParticle(b.Min + new Vector3(diff.X, v * diff.Y, u * diff.Z), Vector3.Zero);
                    break;

                case 3:
                    yellowSystem.AddParticle(b.Min + new Vector3(u * diff.X, v * diff.Y, diff.Z), Vector3.Zero);
                    break;

                case 4:
                    yellowSystem.AddParticle(b.Min + new Vector3(u * diff.X, 0, v * diff.Z), Vector3.Zero);
                    break;

                case 5:
                    yellowSystem.AddParticle(b.Min + new Vector3(u * diff.X, diff.Y, v * diff.Z), Vector3.Zero);
                    break;
                }
            }
        }