Exemplo n.º 1
0
 protected override void emitParticles(int particleCount, ReceiverHandler particleReceiver)
 {
     SSParticle newParticle = new SSParticle();
     BodiesFieldGenerator.NewBodyDelegate bodyReceiver = (id, scale, pos, orient) => {
         configureNewParticle(newParticle);
         newParticle.pos = pos;
         newParticle.masterScale *= scale;
         newParticle.orientation += OpenTKHelper.QuaternionToEuler(ref orient);
         particleReceiver(newParticle);
         return true;
     };
     _bodiesGenerator.Generate(particleCount, bodyReceiver);
 }
Exemplo n.º 2
0
            protected override void effectParticle(SSParticle particle, float deltaT)
            {
                Vector3 dir = particle.vel;

                // orient to look right
                float x     = dir.X;
                float y     = dir.Y;
                float z     = dir.Z;
                float xy    = dir.Xy.Length;
                float phi   = (float)Math.Atan(z / xy);
                float theta = (float)Math.Atan2(y, x);

                particle.orientation.Y = -phi;
                particle.orientation.Z = theta;
                particle.orientation.X = -_orientationX;
            }
 protected void _releaseFlashParticle(SSParticle particle)
 {
     particle.life = 0.1f;
 }
 protected void _releaseSmokeParticle(SSParticle particle)
 {
     particle.effectorMask = 1; // mark to be controlled by the global smoke dimming effector
     particle.life         = Math.Min(particle.life, 1.5f);
 }
            protected override void effectParticle(SSParticle particle, float deltaT)
            {
                Vector3 dir = particle.vel;

                // orient to look right
                float x = dir.X;
                float y = dir.Y;
                float z = dir.Z;
                float xy = dir.Xy.Length;
                float phi = (float)Math.Atan (z / xy);
                float theta = (float)Math.Atan2 (y, x);

                particle.orientation.Y = phi;
                particle.orientation.Z = -theta;
                particle.orientation.X = _orientationX;
            }
Exemplo n.º 6
0
 protected override void configureNewParticle(SSParticle p)
 {
     base.configureNewParticle (p);
     p.pos = position;
 }
Exemplo n.º 7
0
        protected override void configureNewParticle(SSParticle p)
        {
            base.configureNewParticle (p);
            float r = Interpolate.Lerp (radiusOffsetMin, radiusOffsetMax, nextFloat());
            float theta = Interpolate.Lerp (thetaMin, thetaMax, nextFloat ());
            float phi = Interpolate.Lerp (phiMin, phiMax, nextFloat ());
            float xy = (float)Math.Cos (phi);
            float x = xy * (float)Math.Cos (theta);
            float y = xy * (float)Math.Sin (theta);
            float z = (float)Math.Sin (phi);
            Vector3 xyz = new Vector3 (x, y, z);
            p.pos = center + r * xyz;
            float velocityMag = Interpolate.Lerp (velocityMagnitudeMin, velocityMagnitudeMax, nextFloat ());
            p.vel = velocityMag * xyz;

            if (orientAwayFromCenter) {
                p.orientation.Z = -theta;
                p.orientation.Y = phi;
            }
        }
Exemplo n.º 8
0
 protected override void emitParticles(int particleCount, ReceiverHandler particleReceiver)
 {
     SSParticle newParticle = new SSParticle();
     ParticlesFieldGenerator.NewParticleDelegate fieldReceiver = (id, pos) => {
         configureNewParticle(newParticle);
         newParticle.pos = pos;
         particleReceiver(newParticle);
         return true;
     };
     m_fieldGenerator.Generate(particleCount, fieldReceiver);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Override by the derived classes to describe how new particles are emitted
 /// </summary>
 /// <param name="particleCount">Particle count.</param>
 /// <param name="receiver">Receiver.</param>
 protected virtual void emitParticles(int particleCount, ReceiverHandler receiver)
 {
     SSParticle newParticle = new SSParticle();
     for (int i = 0; i < particleCount; ++i) {
         configureNewParticle (newParticle);
         receiver (newParticle);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// To be used by derived classes for shared particle setup
        /// </summary>
        /// <param name="p">particle to setup</param>
        protected virtual void configureNewParticle(SSParticle p)
        {
            p.life = Interpolate.Lerp(lifeMin, lifeMax, nextFloat());

            p.componentScale.X = Interpolate.Lerp(componentScaleMin.X, componentScaleMax.X, nextFloat());
            p.componentScale.Y = Interpolate.Lerp(componentScaleMin.Y, componentScaleMax.Y, nextFloat());
            p.componentScale.Z = Interpolate.Lerp(componentScaleMin.Z, componentScaleMax.Z, nextFloat());

            if (billboardXY) {
                p.billboardXY = true;
            } else {
                p.orientation.X = Interpolate.Lerp (_orientationMin.X, _orientationMax.X, nextFloat ());
                p.orientation.Y = Interpolate.Lerp (_orientationMin.Y, _orientationMax.Y, nextFloat ());
            }
            p.orientation.Z = Interpolate.Lerp(_orientationMin.Z, _orientationMax.Z, nextFloat());

            p.angularVelocity.X = Interpolate.Lerp(angularVelocityMin.X, angularVelocityMax.X, nextFloat());
            p.angularVelocity.Y = Interpolate.Lerp(angularVelocityMin.Y, angularVelocityMax.Y, nextFloat());
            p.angularVelocity.Z = Interpolate.Lerp(angularVelocityMin.Z, angularVelocityMax.Z, nextFloat());

            p.vel.X = Interpolate.Lerp(velocityComponentMin.X, velocityComponentMax.X, nextFloat());
            p.vel.Y = Interpolate.Lerp(velocityComponentMin.Y, velocityComponentMax.Y, nextFloat());
            p.vel.Z = Interpolate.Lerp(velocityComponentMin.Z, velocityComponentMax.Z, nextFloat());

            p.masterScale = Interpolate.Lerp(masterScaleMin, masterScaleMax, nextFloat());

            p.mass = Interpolate.Lerp (massMin, massMax, nextFloat ());
            p.rotationalInnertia = Interpolate.Lerp (rotationalInnertiaMin, rotationalInnertiaMax, nextFloat ());
            p.drag = Interpolate.Lerp (dragMin, dragMax, nextFloat ());
            p.rotationalDrag = Interpolate.Lerp (rotationalDragMin, rotationalDragMax, nextFloat ());

            // color presets
            Color4 randPreset;
            if (colorPresets != null && colorPresets.Length > 0) {
                randPreset = colorPresets [_rand.Next (0, colorPresets.Length)];
            } else {
                randPreset = new Color4(0f, 0f, 0f, 0f);
            }

            // color offsets
            Color4 randOffset;
            randOffset.R = Interpolate.Lerp(colorOffsetComponentMin.R, colorOffsetComponentMax.R, nextFloat());
            randOffset.G = Interpolate.Lerp(colorOffsetComponentMin.G, colorOffsetComponentMax.G, nextFloat());
            randOffset.B = Interpolate.Lerp(colorOffsetComponentMin.B, colorOffsetComponentMax.B, nextFloat());
            randOffset.A = Interpolate.Lerp(colorOffsetComponentMin.A, colorOffsetComponentMax.A, nextFloat());

            // color presets + offsets
            p.color = Color4Helper.Add(ref randPreset, ref randOffset);

            //p.SpriteIndex = SpriteIndices [s_rand.Next(0, SpriteIndices.Length)];
            p.spriteRect = spriteRectangles [_rand.Next(0, spriteRectangles.Length)];

            p.effectorMask = effectorMasks [_rand.Next (0, effectorMasks.Length)];
        }
Exemplo n.º 11
0
 protected void _releaseSmokeParticle(SSParticle particle)
 {
     particle.effectorMask = 1; // mark to be controlled by the global smoke dimming effector
     particle.life = Math.Min(particle.life, 1.5f);
 }
Exemplo n.º 12
0
 protected void _releaseFlashParticle(SSParticle particle)
 {
     particle.life = 0.1f;
 }
Exemplo n.º 13
0
        protected override void configureNewParticle(SSParticle p)
        {
            base.configureNewParticle (p);
            float r = Interpolate.Lerp (radiusOffsetMin, radiusOffsetMax, nextFloat());
            float theta = Interpolate.Lerp (thetaMin, thetaMax, nextFloat ());
            float phi = Interpolate.Lerp (phiMin, phiMax, nextFloat ());
            float xy = (float)Math.Cos (phi);
            float x = xy * (float)Math.Cos (theta);
            float y = xy * (float)Math.Sin (theta);
            float z = (float)Math.Sin (phi);

            Vector3 xAxis, yAxis;
            OpenTKHelper.TwoPerpAxes(up, out xAxis, out yAxis);
            Vector3 xyz = x * xAxis + y * yAxis + z * up;

            p.pos = center + r * xyz;
            float velocityMag = Interpolate.Lerp (velocityFromCenterMagnitudeMin, velocityFromCenterMagnitudeMax, nextFloat ());
            p.vel += velocityMag * xyz;

            if (orientAwayFromCenter) {
                p.orientation.Z = -theta;
                p.orientation.Y = phi;
            }
        }