Esempio n. 1
0
        public void initialize()
        {
            timeStep = 0;
            offset = numberOfParticles;

            random = new Random();

            particles = new Particle[2*numberOfParticles];
            for (int i = 0; i < particles.Length; i+=2)
            {
                particles[i] = new Particle();
                particles[i].position = position;

                particles[i].velocity = initialVelocity;

                if (initialVelocity != Vector3.Zero)
                {
                    particles[i].velocity.X += (float)random.NextDouble() * (float)random.NextDouble() * chaosity;
                    particles[i].velocity.Y += (float)random.NextDouble() * (float)random.NextDouble() * chaosity;
                    particles[i].velocity.Z += (float)random.NextDouble() * (float)random.NextDouble() * chaosity;
                }

                if (random.NextDouble() < 0.5)
                    particles[i].velocity.X = -particles[i].velocity.X;
                if (random.NextDouble() < 0.5)
                    particles[i].velocity.Y = -particles[i].velocity.Y;

                particles[i].gravity = gravity;

                particles[i].lifeTime = lifeTime;

                particles[i].colour = colour;

                particles[i].size = 1000;

                particles[i].startTime = -1;

                particles[i].id = i;

                particles[i + 1] = particles[i];
                particles[i + 1].id = i + 1;
            }
        }
        public void initialize()
        {
            timeStep = 0;
            offset = numberOfParticles;

            random = new Random();

            particles = new Particle[2*numberOfParticles];
            for (int i = 0; i < particles.Length; i+=2)
            {
                particles[i] = new Particle();
                particles[i].position.X = (position.X - width / 2) + width * (float)random.NextDouble();
                particles[i].position.Y = (position.Y - height / 2) + height * (float)random.NextDouble();
                particles[i].position.Z = position.Z;

                particles[i].velocity = initialVelocity;

                particles[i].gravity = gravity;

                particles[i].lifeTime = lifeTime;

                particles[i].colour = colour;
                particles[i].colour.W = 0.5f * (1.0f + (float)random.NextDouble());

                particles[i].size = 10;

                particles[i].startTime = -1;

                particles[i].id = i;

                particles[i + 1] = particles[i];
                particles[i + 1].id = i + 1;
            }
        }