Пример #1
0
        private void FillDataComplete(ref MyGPUEmitter emitter)
        {
            float time;

            m_animatedTimeValues = Velocity.GetKeysCount() > 1 ||
                                   VelocityVar.GetKeysCount() > 1 ||
                                   DirectionInnerCone.GetKeysCount() > 1 ||
                                   DirectionConeVar.GetKeysCount() > 1 ||
                                   EmitterSize.GetKeysCount() > 1 ||
                                   EmitterSizeMin.GetKeysCount() > 1 ||
                                   ParticlesPerFrame.GetKeysCount() > 0;

            MyAnimatedPropertyVector4 color;

            Color.GetKey(0, out time, out color);
            color.GetKey(0, out time, out emitter.Data.Color0);
            color.GetKey(1, out emitter.Data.ColorKey1, out emitter.Data.Color1);
            color.GetKey(2, out emitter.Data.ColorKey2, out emitter.Data.Color2);
            color.GetKey(3, out time, out emitter.Data.Color3);

            // unmultiply colors and factor by intensity
            MyAnimatedPropertyFloat colorIntensity;
            float intensity;

            ColorIntensity.GetKey(0, out time, out colorIntensity);
            colorIntensity.GetInterpolatedValue <float>(0, out intensity);
            emitter.Data.Color0.X *= intensity;
            emitter.Data.Color0.Y *= intensity;
            emitter.Data.Color0.Z *= intensity;
            colorIntensity.GetInterpolatedValue <float>(emitter.Data.ColorKey1, out intensity);
            emitter.Data.Color1.X *= intensity;
            emitter.Data.Color1.Y *= intensity;
            emitter.Data.Color1.Z *= intensity;
            colorIntensity.GetInterpolatedValue <float>(emitter.Data.ColorKey2, out intensity);
            emitter.Data.Color2.X *= intensity;
            emitter.Data.Color2.Y *= intensity;
            emitter.Data.Color2.Z *= intensity;
            colorIntensity.GetInterpolatedValue <float>(1.0f, out intensity);
            emitter.Data.Color3.X *= intensity;
            emitter.Data.Color3.Y *= intensity;
            emitter.Data.Color3.Z *= intensity;

            emitter.Data.Color0 *= m_effect.UserColorMultiplier;
            emitter.Data.Color1 *= m_effect.UserColorMultiplier;
            emitter.Data.Color2 *= m_effect.UserColorMultiplier;
            emitter.Data.Color3 *= m_effect.UserColorMultiplier;

            MyAnimatedPropertyFloat radius;

            Radius.GetKey(0, out time, out radius);
            radius.GetKey(0, out time, out emitter.Data.ParticleSize0);
            radius.GetKey(1, out emitter.Data.ParticleSizeKeys1, out emitter.Data.ParticleSize1);
            radius.GetKey(2, out emitter.Data.ParticleSizeKeys2, out emitter.Data.ParticleSize2);
            radius.GetKey(3, out time, out emitter.Data.ParticleSize3);
            emitter.Data.ParticleSize0 *= m_effect.UserRadiusMultiplier;
            emitter.Data.ParticleSize1 *= m_effect.UserRadiusMultiplier;
            emitter.Data.ParticleSize2 *= m_effect.UserRadiusMultiplier;
            emitter.Data.ParticleSize3 *= m_effect.UserRadiusMultiplier;

            MyAnimatedPropertyFloat thickness;

            Thickness.GetKey(0, out time, out thickness);
            thickness.GetKey(0, out time, out emitter.Data.ParticleThickness0);
            thickness.GetKey(1, out emitter.Data.ParticleThicknessKeys1, out emitter.Data.ParticleThickness1);
            thickness.GetKey(2, out emitter.Data.ParticleThicknessKeys2, out emitter.Data.ParticleThickness2);
            thickness.GetKey(3, out time, out emitter.Data.ParticleThickness3);

            emitter.Data.ColorVar = ColorVar;
            if (emitter.Data.ColorVar > 1.0f)
            {
                emitter.Data.ColorVar = 1.0f;
            }
            else if (emitter.Data.ColorVar < 0)
            {
                emitter.Data.ColorVar = 0;
            }
            emitter.Data.HueVar = HueVar;
            if (emitter.Data.HueVar > 1.0f)
            {
                emitter.Data.HueVar = 1.0f;
            }
            else if (emitter.Data.HueVar < 0)
            {
                emitter.Data.HueVar = 0;
            }

            emitter.Data.MotionInheritance = MotionInheritance;

            emitter.Data.Bounciness = Bounciness;

            emitter.Data.ParticleLifeSpan    = Life;
            emitter.Data.ParticleLifeSpanVar = LifeVar;

            emitter.Data.Direction = Direction;

            emitter.Data.RotationVelocity    = RotationVelocity;
            emitter.Data.RotationVelocityVar = RotationVelocityVar;

            emitter.Data.Acceleration     = Acceleration;
            emitter.Data.StreakMultiplier = StreakMultiplier;

            emitter.Data.SoftParticleDistanceScale = SoftParticleDistanceScale;
            emitter.Data.AnimationFrameTime        = AnimationFrameTime;
            emitter.Data.OITWeightFactor           = OITWeightFactor;

            emitter.AtlasTexture     = (Material.GetValue <MyTransparentMaterial>()).Texture;
            emitter.AtlasDimension   = new Vector2I((int)ArraySize.GetValue <Vector3>().X, (int)ArraySize.GetValue <Vector3>().Y);
            emitter.AtlasFrameOffset = ArrayOffset;
            emitter.AtlasFrameModulo = ArrayModulo;

            GPUEmitterFlags flags = 0;

            switch (RotationReference)
            {
            case MyRotationReference.Local:
                flags |= GPUEmitterFlags.LocalRotation;
                break;

            case MyRotationReference.LocalAndCamera:
                flags |= GPUEmitterFlags.LocalAndCameraRotation;
                break;

            default:
                flags |= Streaks ? GPUEmitterFlags.Streaks : 0;
                break;
            }
            flags |= Collide ? GPUEmitterFlags.Collide : 0;
            flags |= SleepState ? GPUEmitterFlags.SleepState : 0;
            flags |= Light ? GPUEmitterFlags.Light : 0;
            flags |= VolumetricLight ? GPUEmitterFlags.VolumetricLight : 0;
            flags |= m_effect.IsSimulationPaused || MyParticlesManager.Paused ? GPUEmitterFlags.FreezeSimulate : 0;
            flags |= MyParticlesManager.Paused ? GPUEmitterFlags.FreezeEmit : 0;
            flags |= RotationEnabled ? GPUEmitterFlags.RandomRotationEnabled : 0;

            emitter.Data.Flags = flags;

            emitter.GID = m_renderId;

            FillData(ref emitter);
        }