コード例 #1
0
	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;
			// maximumForce *= 2f;
			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();
		// _styleAnimator = _localStyleAnimator;
		_muscleAnimator = _styleAnimator;
		_agent = GetComponent<StyleTransfer002Agent>();
		// _trainerAgent = GetComponent<StyleTransfer002TrainerAgent>();
		// _brain = FindObjectsOfType<Brain>().First(x=>x.name=="LearnFromMocapBrain");
		IsInferenceMode = !Academy.Instance.IsCommunicatorOn;
	}
コード例 #2
0
    void SetupBody()
    {
        _agent              = GetComponent <Agent>();
        _decisionRequester  = GetComponent <DecisionRequester>();
        Time.fixedDeltaTime = FixedDeltaTime;

        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;
            maximumForce *= ragDoll.MotorScale;
            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);
        }
        _startCount++;
    }
コード例 #3
0
    // Reset the animator.
    void Reset()
    {
        BodyParts = new List <BodyPart002> ();
        BodyPart002 root = null;

        if (_rigidbodies == null || _transforms == null)
        {
            _rigidbodies = GetComponentsInChildren <Rigidbody>().ToList();
            _transforms  = GetComponentsInChildren <Transform>().ToList();
        }

        foreach (var t in _transforms)
        {
            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;

        SetupSensors();

        _lastPosition      = Enumerable.Repeat(Vector3.zero, partCount).ToList();
        _lastRotation      = Enumerable.Repeat(Quaternion.identity, partCount).ToList();
        _lastPositionLocal = Enumerable.Repeat(Vector3.zero, partCount).ToList();
        _lastRotationLocal = Enumerable.Repeat(Quaternion.identity, partCount).ToList();
        _lastCenterOfMass  = transform.position;
        _initialRotations  = BodyParts
                             .Select(x => x.Transform.rotation)
                             .ToList();
        BecomeAnimated();
    }
コード例 #4
0
    // Use this for initialization
    public void OnInitializeAgent()
    {
        anim = GetComponent <Animator>();
        anim.Play("Record", 0, NormalizedTime);
        anim.Update(0f);
        // _master = FindObjectOfType<StyleTransfer002Master>();
        AnimationSteps = new List <AnimationStep>();

        if (_rigidbodies == null || _transforms == null)
        {
            _rigidbodies = GetComponentsInChildren <Rigidbody>().ToList();
            _transforms  = GetComponentsInChildren <Transform>().ToList();
        }

        _baseRotation =
            _transforms
            .First(x => BodyConfig.GetBodyPartGroup(x.name) == BodyConfig.GetRootBodyPart())
            .rotation;
        SetupSensors();
    }