/// <summary> /// Apply the motion to the model. /// </summary> /// <param name="motion"></param> /// <param name="model"></param> /// <param name="meta"></param> private void SetMotion(HumanPoseTransfer motion, HumanPoseTransfer model, VRMMetaObject meta) { if (!model || !meta) { return; } var characterController = model.GetComponent <VrmCharacterBehaviour>(); // Apply the motion if AllowedUser is equal to "Everyone". if (meta.AllowedUser == AllowedUser.Everyone) { _motionMode = VrmCharacterBehaviour.MotionMode.Default; if (uiController) { _motionMode = uiController.motionMode; characterController.randomEmotion = uiController.enableRandomEmotion; } if (_motionMode != VrmCharacterBehaviour.MotionMode.Bvh) { var anim = model.GetComponent <Animator>(); if (anim && this.animator) { anim.runtimeAnimatorController = this.animator.runtimeAnimatorController; } characterController.SetAnimator(anim); } else { var anim = model.GetComponent <Animator>(); if (anim) { anim.runtimeAnimatorController = null; } characterController.SetAnimator(anim); if (motion) { model.Source = motion; model.SourceType = HumanPoseTransfer.HumanPoseTransferSourceType.HumanPoseTransfer; } } characterController.SetMotionMode(_motionMode); } else { characterController.SetMotionMode(VrmCharacterBehaviour.MotionMode.Default); characterController.randomEmotion = false; _motionMode = VrmCharacterBehaviour.MotionMode.Default; } }
/// <summary> /// Apply the motion to the model. /// </summary> /// <param name="motion"></param> /// <param name="model"></param> /// <param name="meta"></param> private void SetMotion(HumanPoseTransfer motion, HumanPoseTransfer model, VRMMetaObject meta) { if (!model || !meta) { return; } var characterController = model.GetComponent <CharacterBehaviour>(); // Apply the motion if AllowedUser is equal to "Everyone". if (meta.AllowedUser == AllowedUser.Everyone) { if (uiController && uiController.enableRandomMotion) { var anim = model.GetComponent <Animator>(); if (anim && this.animator) { anim.runtimeAnimatorController = this.animator.runtimeAnimatorController; } characterController.randomMotion = true; } else { var anim = model.GetComponent <Animator>(); if (anim) { anim.runtimeAnimatorController = null; } characterController.randomMotion = false; if (motion) { model.Source = motion; model.SourceType = HumanPoseTransfer.HumanPoseTransferSourceType.HumanPoseTransfer; } } if (uiController) { characterController.randomEmotion = uiController.enableRandomEmotion; } } else { characterController.randomMotion = false; characterController.randomEmotion = false; } }
void SetMotion(HumanPoseTransfer src) { m_src = src; src.GetComponent <Renderer>().enabled = false; EnableBvh(); }
void SetMotion(HumanPoseTransfer src) { m_src = src; src.GetComponent <Renderer>().enabled = false; if (m_loaded != null) { m_loaded.EnableBvh(src); } }
void SetMotion(HumanPoseTransfer src) { m_src = src; src.GetComponent <Renderer>().enabled = false; if (m_loaded != null) { var dst = m_loaded.AddComponent <HumanPoseTransfer>(); dst.Source = m_src; dst.SourceType = HumanPoseTransfer.HumanPoseTransferSourceType.HumanPoseTransfer; } }
/// <summary> /// Load the motion from a BVH file. /// </summary> /// <param name="path"></param> private void LoadMotion(string path) { ImporterContext context = new ImporterContext { Path = path }; BvhImporter.Import(context); motion = context.Root.GetComponent <HumanPoseTransfer>(); motion.GetComponent <Renderer>().enabled = false; SetMotion(motion, model, meta); }
private void SetMotion(HumanPoseTransfer src) { if (src.Avatar.isValid) // check whether the source is valid { _bvhSource = src; src.GetComponent <Renderer>().enabled = false; _motionControlPanel.BvhSource = _bvhSource; _bvhLoadingTrigger = false; _bvhPathSaved = _bvhPathLocal; _motionControlPanel.EnableBvh(); _toggleMotionBVH.isOn = true; _toggleMotionTPose.isOn = false; } }
/// <summary> /// Load the motion from a BVH file. /// </summary> /// <param name="path"></param> private void LoadMotion(string path) { if (!File.Exists(path)) { Debug.Log("Motion " + path + " is not exits."); return; } var characterController = model.GetComponent <VrmCharacterBehaviour>(); GameObject newMotionObject = null; try { BvhImporterContext context = new BvhImporterContext(); //Debug.Log("Loading motion : " + path); context.Parse(path); context.Load(); newMotionObject = context.Root; // Hide the motion model Renderer renderer = newMotionObject.GetComponent <Renderer>(); if (renderer) { renderer.enabled = false; } } catch (Exception ex) { if (uiController) { uiController.motionMode = VrmCharacterBehaviour.MotionMode.Default; uiController.ShowWarning("Motion load failed."); } Debug.LogError("Failed loading " + path); Debug.LogError(ex); return; } if (newMotionObject) { if (motion) { GameObject.Destroy(motion.gameObject); } motion = newMotionObject.GetComponent <HumanPoseTransfer>(); // 読み込みが成功したら、モーションの選択肢はBVHとする _motionMode = VrmCharacterBehaviour.MotionMode.Bvh; SetMotion(motion, model, meta); if (uiController) { uiController.motionMode = VrmCharacterBehaviour.MotionMode.Bvh; } // Play loaded audio if available if (audioSource && audioSource.clip && audioSource.clip.loadState == AudioDataLoadState.Loaded) { audioSource.Stop(); audioSource.Play(); } } }