コード例 #1
0
    // Use this for initialization
    void Start()
    {
        _master            = GetComponent <StyleTransfer002Master>();
        _decisionRequester = GetComponent <DecisionRequester>();
        var spawnableEnv = GetComponentInParent <SpawnableEnv>();

        _localStyleAnimator = spawnableEnv.gameObject.GetComponentInChildren <StyleTransfer002Animator>();
        _styleAnimator      = _localStyleAnimator.GetFirstOfThisAnim();
        _startCount++;
    }
コード例 #2
0
    // Resets the agent. Initialize the style animator and master if not initialized.
    public override void AgentReset()
    {
        if (!_hasLazyInitialized)
        {
            _master            = GetComponent <StyleTransfer002Master>();
            _master.BodyConfig = MarathonManAgent.BodyConfig;
            _decisionRequester = GetComponent <DecisionRequester>();
            var spawnableEnv = GetComponentInParent <SpawnableEnv>();
            _localStyleAnimator       = spawnableEnv.gameObject.GetComponentInChildren <StyleTransfer002Animator>();
            _styleAnimator            = _localStyleAnimator.GetFirstOfThisAnim();
            _styleAnimator.BodyConfig = MarathonManAgent.BodyConfig;

            _styleAnimator.OnInitializeAgent();
            _master.OnInitializeAgent();

            _hasLazyInitialized = true;
            _localStyleAnimator.DestoryIfNotFirstAnim();
        }
        _isDone = true;
        _ignorScoreForThisFrame = true;
        _master.ResetPhase();
        _sensors = GetComponentsInChildren <SensorBehavior>()
                   .Select(x => x.gameObject)
                   .ToList();
        SensorIsInTouch = Enumerable.Range(0, _sensors.Count).Select(x => 0f).ToList();
        if (_scoreHistogramData != null)
        {
            var column = _master.StartAnimationIndex;
            if (_decisionRequester?.DecisionPeriod > 1)
            {
                column /= _decisionRequester.DecisionPeriod;
            }
            if (_ignorScoreForThisFrame)
            {
                _ignorScoreForThisFrame = false;
            }
            else
            {
                _scoreHistogramData.SetItem(column, AverageReward);
            }
        }
    }
コード例 #3
0
    // Initialize the Agent. Sets up Body Parts, Muscles.
    public void OnInitializeAgent()
    {
        Time.fixedDeltaTime  = FixedDeltaTime;
        _waitingForAnimation = true;
        _decisionRequester   = GetComponent <DecisionRequester>();

        BodyParts = new List <BodyPart002> ();
        BodyPart002 root = null;

        foreach (var t in GetComponentsInChildren <Transform>())
        {
            if (BodyConfig.GetBodyPartGroup(t.name) == BodyHelper002.BodyPartGroup.None)
            {
                continue;
            }

            var bodyPart = new BodyPart002 {
                Rigidbody = t.GetComponent <Rigidbody>(),
                Transform = t,
                Name      = t.name,
                Group     = BodyConfig.GetBodyPartGroup(t.name),
            };
            if (bodyPart.Group == BodyConfig.GetRootBodyPart())
            {
                root = bodyPart;
            }
            bodyPart.Root = root;
            bodyPart.Init();
            BodyParts.Add(bodyPart);
        }
        var partCount = BodyParts.Count;

        Muscles = new List <Muscle002> ();
        var muscles = GetComponentsInChildren <ConfigurableJoint>();
        ConfigurableJoint rootConfigurableJoint = null;
        var ragDoll = GetComponent <RagDoll002>();

        foreach (var m in muscles)
        {
            var maximumForce = ragDoll.MusclePowers.First(x => x.Muscle == m.name).PowerVector;
            var muscle       = new Muscle002 {
                Rigidbody         = m.GetComponent <Rigidbody>(),
                Transform         = m.GetComponent <Transform>(),
                ConfigurableJoint = m,
                Name         = m.name,
                Group        = BodyConfig.GetMuscleGroup(m.name),
                MaximumForce = maximumForce
            };
            if (muscle.Group == BodyConfig.GetRootMuscle())
            {
                rootConfigurableJoint = muscle.ConfigurableJoint;
            }
            muscle.RootConfigurableJoint = rootConfigurableJoint;
            muscle.Init();

            Muscles.Add(muscle);
        }
        var spawnableEnv = GetComponentInParent <SpawnableEnv>();

        _localStyleAnimator = spawnableEnv.gameObject.GetComponentInChildren <StyleTransfer002Animator>();
        _styleAnimator      = _localStyleAnimator.GetFirstOfThisAnim();
        _muscleAnimator     = _styleAnimator;
        _agent = GetComponent <StyleTransfer002Agent>();

        IsInferenceMode = !Academy.Instance.IsCommunicatorOn;
    }
コード例 #4
0
    void Start()
    {
        Time.fixedDeltaTime  = FixedDeltaTime;
        _waitingForAnimation = true;

        BodyParts = new List <BodyPart002> ();
        BodyPart002 root = null;

        foreach (var t in GetComponentsInChildren <Transform>())
        {
            if (BodyHelper002.GetBodyPartGroup(t.name) == BodyHelper002.BodyPartGroup.None)
            {
                continue;
            }

            var bodyPart = new BodyPart002 {
                Rigidbody = t.GetComponent <Rigidbody>(),
                Transform = t,
                Name      = t.name,
                Group     = BodyHelper002.GetBodyPartGroup(t.name),
            };
            if (bodyPart.Group == BodyHelper002.BodyPartGroup.Hips)
            {
                root = bodyPart;
            }
            bodyPart.Root = root;
            bodyPart.Init();
            BodyParts.Add(bodyPart);
        }
        var partCount = BodyParts.Count;

        Muscles = new List <Muscle002> ();
        var muscles = GetComponentsInChildren <ConfigurableJoint>();
        ConfigurableJoint rootConfigurableJoint = null;
        var ragDoll = GetComponent <RagDoll002>();

        foreach (var m in muscles)
        {
            var maximumForce = ragDoll.MusclePowers.First(x => x.Muscle == m.name).PowerVector;
            // maximumForce *= 2f;
            var muscle = new Muscle002 {
                Rigidbody         = m.GetComponent <Rigidbody>(),
                Transform         = m.GetComponent <Transform>(),
                ConfigurableJoint = m,
                Name         = m.name,
                Group        = BodyHelper002.GetMuscleGroup(m.name),
                MaximumForce = maximumForce
            };
            if (muscle.Group == BodyHelper002.MuscleGroup.Hips)
            {
                rootConfigurableJoint = muscle.ConfigurableJoint;
            }
            muscle.RootConfigurableJoint = rootConfigurableJoint;
            muscle.Init();

            Muscles.Add(muscle);
        }
        var spawnableEnv = GetComponentInParent <SpawnableEnv>();

        _localStyleAnimator = spawnableEnv.gameObject.GetComponentInChildren <StyleTransfer002Animator>();
        _styleAnimator      = _localStyleAnimator.GetFirstOfThisAnim();
        // _styleAnimator = _localStyleAnimator;
        _muscleAnimator = _styleAnimator;
        _agent          = GetComponent <StyleTransfer002Agent>();
        // _trainerAgent = GetComponent<StyleTransfer002TrainerAgent>();
        // _brain = FindObjectsOfType<Brain>().First(x=>x.name=="LearnFromMocapBrain");
        _academy        = FindObjectOfType <Academy>();
        IsInferenceMode = !_academy.agentSpawner.trainingMode;
    }