public Vector3F GenerateValue(Random random) { switch (Type) { case Component_ParticleEmitter.AnglesProperty.TypeEnum.Constant: return(Constant); case Component_ParticleEmitter.AnglesProperty.TypeEnum.Range: return(Vector3F.Lerp(Range.Minimum, Range.Maximum, random.NextFloat())); case Component_ParticleEmitter.AnglesProperty.TypeEnum.Curve: { Vector3F result = Vector3F.Zero; if (CurveX != null) { var maxValue = CurveX.Points[CurveX.Points.Count - 1].Time; result.X = CurveX.CalculateValueByTime(random.Next(maxValue)); } if (CurveY != null) { var maxValue = CurveY.Points[CurveY.Points.Count - 1].Time; result.Y = CurveY.CalculateValueByTime(random.Next(maxValue)); } if (CurveZ != null) { var maxValue = CurveZ.Points[CurveZ.Points.Count - 1].Time; result.Z = CurveZ.CalculateValueByTime(random.Next(maxValue)); } return(result); } } return(Vector3F.Zero); }
public void Calculate(float lifetime, float time, out Vector3F result) { switch (Type) { case Component_ParticleVelocityByTime.TypeEnum.Constant: result = Constant; break; case Component_ParticleVelocityByTime.TypeEnum.Range: Vector3F.Lerp(ref Range.Minimum, ref Range.Maximum, MathEx.Saturate(time / lifetime), out result); break; case Component_ParticleVelocityByTime.TypeEnum.Curve: result.X = CurveX != null?CurveX.CalculateValueByTime(time) : 0; result.Y = CurveY != null?CurveY.CalculateValueByTime(time) : 0; result.Z = CurveZ != null?CurveZ.CalculateValueByTime(time) : 0; break; default: result = Vector3F.Zero; break; } }