浏览代码

added AnimationCurveSampler constructors

/main
Steven Leal 4 年前
当前提交
84bc7e8e
共有 1 个文件被更改,包括 24 次插入2 次删除
  1. 26
      com.unity.perception/Runtime/Randomization/Samplers/SamplerTypes/AnimationCurveSampler.cs

26
com.unity.perception/Runtime/Randomization/Samplers/SamplerTypes/AnimationCurveSampler.cs


/// The Animation Curve associated with this sampler
/// </summary>
[Tooltip("Probability distribution curve used for this sampler. The X axis corresponds to the values this sampler will pick from, and the Y axis corresponds to the relative probability of the values. The relative probabilities (Y axis) do not need to max out at 1 as only the shape of the curve matters. The Y values cannot however be negative.")]
public AnimationCurve distributionCurve = new AnimationCurve(
new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
public AnimationCurve distributionCurve;
/// <summary>
/// Number of samples used for integrating over the provided AnimationCurve.

float m_Interval;
/// <summary>
/// Constructs a default AnimationCurveSampler
/// </summary>
public AnimationCurveSampler()
{
distributionCurve = new AnimationCurve(
new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
}
/// <summary>
/// Constructs an AnimationCurveSampler with a given animation curve
/// </summary>
/// <param name="curve">The animation curve to sample from</param>
/// <param name="numberOfSamples">Number of samples used for integrating over the provided AnimationCurve</param>
public AnimationCurveSampler(AnimationCurve curve, int numberOfSamples=500)
{
distributionCurve = curve;
numOfSamplesForIntegration = numberOfSamples;
}
/// <summary>
/// Generates one sample
/// </summary>
/// <returns>The generated sample</returns>

{
if (distributionCurve.length == 0)
throw new SamplerValidationException("The distribution curve provided is empty");
if (numOfSamplesForIntegration < 2)
throw new SamplerValidationException("Insufficient number of integration samples");
}
void Initialize()

正在加载...
取消
保存