private static void SetParticleParam(PartSysEmitter emitter, int particleIdx, PartSysParamId id,
                                         float atLifetime, ParticleStateField stateField, float defaultValue)
    {
        var value = GetParticleValue(emitter, particleIdx, id, atLifetime, defaultValue);

        emitter.GetParticleState().SetState(stateField, particleIdx, value);
    }
Beispiel #2
0
    private static byte GetParticleColorComponent(ParticleStateField stateField,
                                                  PartSysParamId paramId,
                                                  PartSysEmitter emitter,
                                                  int particleIdx)
    {
        var  colorParam = emitter.GetParamState(paramId);
        byte value;

        if (colorParam != null)
        {
            var partAge   = emitter.GetParticleAge(particleIdx);
            var partColor = colorParam.GetValue(emitter, particleIdx, partAge);
            partColor += emitter.GetParticleState().GetState(stateField, particleIdx);
            if (partColor >= 255)
            {
                value = 255;
            }
            else if (partColor < 0)
            {
                value = 0;
            }
            else
            {
                value = (byte)partColor;
            }
        }
        else
        {
            value =
                (byte)emitter.GetParticleState().GetState(stateField, particleIdx);
        }

        return(value);
    }
    private static float GetParticleValue(PartSysEmitter emitter, int particleIdx, PartSysParamId paramId,
                                          float atLifetime, float defaultValue = 0.0f)
    {
        var state = emitter.GetParamState(paramId);

        return(state?.GetValue(emitter, particleIdx, atLifetime) ?? defaultValue);
    }
 public void SetParam(PartSysParamId id, IPartSysParam param)
 {
     if ((int)id < mParams.Length)
     {
         mParams[(int)id] = param;
     }
     else
     {
         throw new ArgumentOutOfRangeException("Parameter index out of range: " + id);
     }
 }
 public IPartSysParam GetParam(PartSysParamId id)
 {
     if ((int)id < mParams.Length)
     {
         return(mParams[(int)id]);
     }
     else
     {
         return(null);
     }
 }
Beispiel #6
0
    public static IPartSysParam Parse(PartSysParamId id, ReadOnlySpan <byte> value, float emitterLifespan,
                                      float particleLifespan, out bool success)
    {
        // Look up the default value
        var defaultValue = PartSysParamDefaultValues.GetDefaultValue(id);

        // Do we have to use the particle or emitter lifespan as reference for keyframes?
        var lifespan = (id >= PartSysParamId.part_accel_X) ? particleLifespan : emitterLifespan;

        return(Parse(value, defaultValue, lifespan, out success));
    }
    private void ApplyAcceleration(PartSysParamId paramId, float timeToSimulateSecs,
                                   ref float position, ref float velocity)
    {
        var paramState = _paramState[(int)paramId];

        if (paramState != null)
        {
            var accel = GetParamValue(paramState); // Get value from param state
            position += timeToSimulateSecs * timeToSimulateSecs * accel * 0.5f;
            velocity += timeToSimulateSecs * accel;
        }
    }
    public float GetParamValue(PartSysParamId paramId, int particleIdx, float lifetime,
                               float defaultValue = 0.0f)
    {
        var state = GetParamState(paramId);

        if (state != null)
        {
            return(state.GetValue(this, particleIdx, lifetime));
        }

        return(defaultValue);
    }
        public bool GetValue(PartSysParamId paramId, out float value)
        {
            var state = emitter.GetParamState(paramId);

            if (state != null)
            {
                value = state.GetValue(emitter, particleIdx, particleAge);
                return(true);
            }

            value = float.NaN;
            return(false);
        }
Beispiel #10
0
 /// <summary>
 /// Returns the value a parameter shall have if it is undefined.
 /// </summary>
 public static float GetDefaultValue(PartSysParamId id)
 {
     return(DefaultValues[(int)id]);
 }
 public PartSysParamState GetParamState(PartSysParamId paramId)
 {
     return(_paramState[(int)paramId]);
 }