コード例 #1
0
        void SetModel(RuntimeGltfInstance instance)
        {
            // cleanup
            if (m_loaded != null)
            {
                m_loaded.Dispose();
                m_loaded = null;
            }

            instance.ShowMeshes();
            instance.EnableUpdateWhenOffscreen();
            m_loaded = new Loaded(instance, m_src, m_target.transform);
        }
コード例 #2
0
        void SetModel(RuntimeGltfInstance instance)
        {
            // cleanup
            if (m_loaded != null)
            {
                m_loaded.Dispose();
                m_loaded = null;
            }

            if (m_useFastSpringBone.isOn)
            {
                FastSpringBoneReplacer.ReplaceAsync(instance.Root);
            }

            instance.EnableUpdateWhenOffscreen();
            instance.ShowMeshes();

            m_loaded = new Loaded(instance, m_src, m_target.transform);
        }
コード例 #3
0
    /// <summary>
    /// Unload the old model and load the new model from VRM file.
    /// </summary>
    /// <param name="path"></param>
    private void LoadModel(string path)
    {
        if (!File.Exists(path))
        {
            Debug.Log("Model " + path + " is not exits.");
            return;
        }

        GameObject newModelObject = null;

        try
        {
            // Load from a VRM file.
            var parser = new GlbFileParser(path);
            var data   = parser.Parse();

            context = new VRMImporterContext(data);
            //Debug.Log("Loading model : " + path);

            RuntimeGltfInstance instance = context.Load();
            instance.EnableUpdateWhenOffscreen();

            newModelObject = instance.Root;
            meta           = context.ReadMeta(true);

            instance.ShowMeshes();
        }
        catch (Exception ex)
        {
            if (uiController)
            {
                uiController.ShowWarning("Model load failed.");
            }
            Debug.LogError("Failed loading " + path);
            Debug.LogError(ex);
            return;
        }

        if (newModelObject)
        {
            if (model)
            {
                GameObject.Destroy(model.gameObject);
            }

            model = newModelObject.AddComponent <HumanPoseTransfer>();

            CreateColliders(model.gameObject);

            var characterController = model.gameObject.AddComponent <VrmCharacterBehaviour>();

            SetMotion(motion, model, meta);

            if (uiController)
            {
                uiController.Show(meta);

                if (characterController)
                {
                    uiController.enableRandomMotion  = characterController.randomMotion;
                    uiController.enableRandomEmotion = characterController.randomEmotion;
                }
            }
        }
    }