//------------------------------------------------------------------------------------------------------------

    IMorph IAnimModel.GetMorph(string name)
    {
        // Memo: Redirect to MMD4MecanimModel
        if (_model != null)
        {
            return(_model.GetMorph(name));
        }
        return(null);
    }
Example #2
0
    void Start()
    {
        EyesPosX       = 20;
        EyesPosY       = 7;
        BodyPosYOffset = Body.transform.position.y;

        Init();

        // 初期表情
        Model = GetComponent <MMD4MecanimModel>();
        Model.GetMorph("じと目").weight  = 0.7f;
        Model.GetMorph("眼球縮小").weight = 0.2f;
    }
    void _UpdateModelMorph()
    {
        if (_modelMorph != null)
        {
            if (string.IsNullOrEmpty(this.morphName) || _modelMorph.name != this.morphName)
            {
                if (_modelMorph.weight != 0.0f || _modelMorph.weight2 != 0.0f)
                {
                    _inactiveModelMorphSet.Add(_modelMorph);
                }
                _modelMorph = null;
            }
        }

        if (_modelMorph == null)
        {
            if (_model != null)
            {
                _modelMorph = _model.GetMorph(this.morphName);
                if (_modelMorph != null && _inactiveModelMorphSet != null)
                {
                    _inactiveModelMorphSet.Remove(_modelMorph);
                }
            }
        }
    }
Example #4
0
    void _UpdateMorph(string morphName)
    {
        if (_validateMorphBits == 0)            // Collect enable morph.
        {
            MMD4MecanimModel model = GetComponent <MMD4MecanimModel>();
            if (model != null && hiraMorphNameList != null)
            {
                for (int i = 0; i < hiraMorphNameList.Count; ++i)
                {
                    if (model.GetMorph(hiraMorphNameList[i]) != null)
                    {
                        _validateMorphBits |= 1 << i;
                    }
                }
            }
            if (_validateMorphBits == 0)
            {
                _validateMorphBits = 0x1f;
            }
        }

        float morphWeight = 0.0f;

        if (!string.IsNullOrEmpty(morphName))              // Emulation morph using 'a'
        {
            morphWeight = 1.0f;
            if (hiraMorphNameList != null)
            {
                if (morphName == hiraMorphNameList[1] && ((_validateMorphBits & 0x2) == 0))
                {
                    morphName   = hiraMorphNameList[0];
                    morphWeight = 0.5f;
                }
                else if (morphName == hiraMorphNameList[2] && ((_validateMorphBits & 0x4) == 0))
                {
                    morphName   = hiraMorphNameList[0];
                    morphWeight = 0.3f;
                }
                else if (morphName == hiraMorphNameList[3] && ((_validateMorphBits & 0x8) == 0))
                {
                    morphName   = hiraMorphNameList[0];
                    morphWeight = 0.5f;
                }
                else if (morphName == hiraMorphNameList[4] && ((_validateMorphBits & 0x10) == 0))
                {
                    morphName   = hiraMorphNameList[0];
                    morphWeight = 0.8f;
                }
            }
        }

        base.morphName   = morphName;
        base.morphWeight = morphWeight;
    }
Example #5
0
    void UpdatePreferredMorphs()
    {
        foreach (string morphName in preferredMorphs)
        {
            if (preferredModelMorphDict_.ContainsKey(morphName))
            {
                continue;
            }                                                                              // already included

            MMD4MecanimModel.Morph modelMorph = model_.GetMorph(morphName);
            if (modelMorph == null)
            {
                continue;
            }                                                 // not found

            preferredModelMorphDict_.Add(morphName, modelMorph);
        }
    }
Example #6
0
    void Update()
    {
        // 値が揃ってから参照
        if (!Ready)
        {
            return;
        }

        // 各パラメータ表示
        UpdateParamText();

        // 体移動
        Body.transform.position = BodyPos;

        // 頭向き
        Head.transform.localEulerAngles = new Vector3(-HeadAng.z, -HeadAng.x, HeadAng.y);

        // 視線
        Vector3 eyesAng = new Vector3(EyesPos.y, EyesPos.x, 0);

        EyeL.GetComponent <MMD4MecanimBone>().userEulerAngles = eyesAng;
        EyeR.GetComponent <MMD4MecanimBone>().userEulerAngles = eyesAng;

        // 目パチ
        Model.GetMorph("まばたき").weight = EyesClose / 100;

        // 眉上
        Model.GetMorph("上").weight = BrowRai / 100;

        // 眉下
        Model.GetMorph("下").weight     = BrowLow / 100;
        Model.GetMorph("困る").weight    = BrowLow / 100;
        Model.GetMorph("上まぶた閉").weight = BrowLow / 100;

        // 笑顔
        Model.GetMorph("まばたき3").weight = Smile / 100;
        Model.GetMorph("笑い").weight    = Smile / 100;

        // キス
        Model.GetMorph("眼球縮小").weight = Kiss * 0.02f + 0.2f;

        // 表情競合対策
        if (Smile > 10 || BrowLow > 10)
        {
            Model.GetMorph("まばたき").weight = 0;
        }
        if (Smile > BrowLow / 2 || Kiss > BrowLow / 2)
        {
            Model.GetMorph("下").weight     = 0;
            Model.GetMorph("上まぶた閉").weight = 0;
        }
        float ret = Mathf.Max(EyesClose, Mathf.Max(Smile, Mathf.Max(BrowRai, BrowLow)));

        Model.GetMorph("じと目").weight = 0.7f - (ret * 0.007f);
    }