Пример #1
0
        private void SetModel(GameObject go)
        {
            ReleaseCurrentVrm();

            if (go == null)
            {
                return;
            }

            var lookAt = go.GetComponent <VRMLookAtHead>();

            _humanPoseTransferTarget            = go.AddComponent <HumanPoseTransfer>();
            _humanPoseTransferTarget.SourceType = HumanPoseTransfer.HumanPoseTransferSourceType.None;
            lookAt.UpdateType = UpdateType.LateUpdate;

            //セットアップのうちFinalIKに思い切り依存した所が別スクリプトになってます
            VRMLoadControllerHelper.SetupVrm(go, loadSetting);

            var animator = go.GetComponent <Animator>();

            animator.runtimeAnimatorController = animatorController;

            var blendShapeProxy = go.GetComponent <VRMBlendShapeProxy>();

            var renderers = go.GetComponentsInChildren <Renderer>();

            foreach (var r in renderers)
            {
                //セルフシャドウは明示的に切る: ちょっとでも軽量化したい
                r.receiveShadows = false;
            }
            windowStyleController.InitializeModelRenderers(renderers);
            settingAdjuster.AssignModelRoot(go.transform);

            var info = new VrmLoadedInfo()
            {
                vrmRoot    = go.transform,
                animator   = animator,
                blendShape = blendShapeProxy,
            };

            PreVrmLoaded?.Invoke(info);
            VrmLoaded?.Invoke(info);
        }
Пример #2
0
        void SetModel(GameObject go)
        {
            // cleanup
            var loaded = m_loaded;

            m_loaded = null;

            if (loaded != null)
            {
                Debug.LogFormat("destroy {0}", loaded);
                GameObject.Destroy(loaded.gameObject);
            }

            if (go != null)
            {
                var lookAt = go.GetComponent <VRMLookAtHead>();
                if (lookAt != null)
                {
                    m_loaded            = go.AddComponent <HumanPoseTransfer>();
                    m_loaded.Source     = m_src;
                    m_loaded.SourceType = HumanPoseTransfer.HumanPoseTransferSourceType.HumanPoseTransfer;
                }

                var animation = go.GetComponent <Animation>();
                if (animation && animation.clip != null)
                {
                    animation.Play(animation.clip.name);
                }

                //セットアップの過程でFinalIKに少し触るので(規約クリアになるよう)ファイルを分離
                VRMLoadControllerHelper.SetupVrm(go, new VRMLoadControllerHelper.VrmLoadSetting()
                {
                    runtimeAnimatorController = runtimeController,
                    leftHandTarget            = leftHand,
                    rightHandTarget           = rightHand,
                    headTarget    = head,
                    inputToMotion = _inputToMotion,
                });

                _inputToMotion.fingerAnimator = go.GetComponent <FingerAnimator>();
                //_inputToMotion.head = go.GetComponent<Animator>().GetBoneTransform(HumanBodyBones.Neck);
            }
        }
Пример #3
0
        void SetModel(GameObject go)
        {
            ReleaseCurrentVrm();

            if (go == null)
            {
                return;
            }

            var lookAt = go.GetComponent <VRMLookAtHead>();

            if (lookAt != null)
            {
                m_loaded            = go.AddComponent <HumanPoseTransfer>();
                m_loaded.Source     = m_src;
                m_loaded.SourceType = HumanPoseTransfer.HumanPoseTransferSourceType.HumanPoseTransfer;
            }

            var animation = go.GetComponent <Animation>();

            if (animation && animation.clip != null)
            {
                animation.Play(animation.clip.name);
            }

            //セットアップの過程でFinalIKに少し触るので(規約クリアになるよう)ファイルを分離
            VRMLoadControllerHelper.SetupVrm(go, new VRMLoadControllerHelper.VrmLoadSetting()
            {
                runtimeAnimatorController = runtimeController,
                bodyTarget      = bodyTarget,
                leftHandTarget  = leftHandTarget,
                rightHandTarget = rightHandTarget,
                headTarget      = headTarget,
                inputToMotion   = _inputToMotion,
            });

            _inputToMotion.fingerAnimator        = go.GetComponent <FingerAnimator>();
            animMorphEasedTarget.blendShapeProxy = go.GetComponent <VRMBlendShapeProxy>();
        }