Ejemplo n.º 1
0
    public void StartLipSync()
    {
        if (lipsyncOn)
        {
            lipsync = ParentAvatar.AddComponent <LipSync>();

            lipsync.realtimeMoCap = false;
            lipsync.StartAfterConfig(audioClip, RootPosition);

            // lipsync.avatar_scale = ParentAvatar.transform.localScale.x;
        }
    }
    public void StartAfterConfig()
    {
        configOn   = false;
        configured = true;

        if (ParentAvatar.TryGetComponent <MoveBoxPlayback>(out PlayBack))
        {
            PlayBack.standalone = false;
            PlayBack.enabled    = false;
        }


        // START AVATAR
        RootPosition = ParentAvatar.transform.Find("Bip01").Find("Bip01 Pelvis").gameObject;

        originalAvatarAbsoluteRotations = new Dictionary <string, Quaternion>();
        Retrieve_OriginalAvatarRotations(RootPosition);

        GameObject rockethead = GetRocketboxBone(JointId.Head, RootPosition);
        GameObject rocketfoot = GetRocketboxBone(JointId.FootLeft, RootPosition);

        rocketboxHeight = rockethead.transform.position.y - rocketfoot.transform.position.y;

        Offset = RootPosition.transform.position;



        // START MOCAP

        StartMoCap();


        // Start Playback
        PlayBack              = gameObject.AddComponent <MoveBoxPlayback>();
        PlayBack.standalone   = false;
        PlayBack.ParentAvatar = ParentAvatar;
        PlayBack.RootPosition = RootPosition;
        PlayBack.animationOn  = animationOn;
        PlayBack.eyeBlinkOn   = eyeBlinkOn;
        PlayBack.lipsyncOn    = lipsyncOn;

        //START EYEBLINK

        if (eyeBlinkOn)
        {
            PlayBack.StartEyeBlinks();
        }


        // START LIPSYNC

        if (lipsyncOn)
        {
            if (lipsyncMicOn)
            {
                PlayBack.lipsyncOn = false;
                if (!ParentAvatar.TryGetComponent <LipSync>(out lipsync))
                {
                    lipsync = ParentAvatar.AddComponent <LipSync>();
                }
                lipsync.nameOfMicrophone = nameMic;
                lipsync.realtimeMoCap    = true;
                lipsync.StartAfterConfig(null, RootPosition);
            }
            else
            {
                PlayBack.audioClip = audioClip;
                PlayBack.StartLipSync();
            }
        }


        // ANIMATION PLAYBACK
        if (animationOn & !isRealTime)
        {
            PlayBack.animationClip = animationClip;
            PlayBack.loopingOn     = loopingOn;
            PlayBack.StartAnimationPlayback();
        }
        else
        {
            PlayBack.animationOn = false;
        }
    }