浏览代码

Merge remote-tracking branch 'origin/keypoints' into keypoints

/main
Steven Borkman 4 年前
当前提交
778df27c
共有 2 个文件被更改,包括 8 次插入8 次删除
  1. 7
      com.unity.perception/Runtime/GroundTruth/Labelers/AnimationPoseLabel.cs
  2. 9
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/AnimationRandomizer.cs

7
com.unity.perception/Runtime/GroundTruth/Labelers/AnimationPoseLabel.cs


public class PoseTimestampRecord
{
/// <summary>
/// The point in the clip that the pose starts, a value from 0 (beginning) to 1 (end)
/// The percentage within the clip that the pose starts, a value from 0 (beginning) to 1 (end)
public float startOffset;
[Tooltip("The percentage within the clip that the pose starts, a value from 0 (beginning) to 1 (end)")]
public float startOffsetPercent;
/// <summary>
/// The label to use for any captures inside of this time period
/// </summary>

var i = 1;
for (i = 1; i < timestamps.Count; i++)
{
if (timestamps[i].startOffset > time) break;
if (timestamps[i].startOffsetPercent > time) break;
}
return timestamps[i - 1].poseLabel;

9
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/AnimationRandomizer.cs


using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Perception.Randomization.Parameters;
using UnityEngine.Experimental.Perception.Randomization.Randomizers.SampleRandomizers.Tags;

{
FloatParameter m_FloatParameter = new FloatParameter{ value = new UniformSampler(0, 1) };
const string clipName = "PlayerIdle";
const string stateName = "Base Layer.RandomState";
const string k_ClipName = "PlayerIdle";
const string k_StateName = "Base Layer.RandomState";
void RandomizeAnimation(AnimationRandomizerTag tag)
{

var overrider = tag.animatorOverrideController;
if (overrider != null && tag.animationClips.GetCategoryCount() > 0)
{
overrider[clipName] = tag.animationClips.Sample();
animator.Play(stateName, 0, m_FloatParameter.Sample());
overrider[k_ClipName] = tag.animationClips.Sample();
animator.Play(k_StateName, 0, m_FloatParameter.Sample());
}
}

正在加载...
取消
保存