Esempio n. 1
0
        private void SendParameterRelatedCommands(AutoAdjustParameters parameters, bool onlyEyebrow)
        {
            var eyebrowCommands = new ReceivedCommand[]
            {
                new ReceivedCommand(
                    MessageCommandNames.EyebrowLeftUpKey,
                    parameters.EyebrowLeftUpKey
                    ),
                new ReceivedCommand(
                    MessageCommandNames.EyebrowLeftDownKey,
                    parameters.EyebrowLeftDownKey
                    ),
                new ReceivedCommand(
                    MessageCommandNames.UseSeparatedKeyForEyebrow,
                    $"{parameters.UseSeparatedKeyForEyebrow}"
                    ),
                new ReceivedCommand(
                    MessageCommandNames.EyebrowRightUpKey,
                    parameters.EyebrowRightUpKey
                    ),
                new ReceivedCommand(
                    MessageCommandNames.EyebrowRightDownKey,
                    parameters.EyebrowRightDownKey
                    ),
                new ReceivedCommand(
                    MessageCommandNames.EyebrowUpScale,
                    $"{parameters.EyebrowUpScale}"
                    ),
                new ReceivedCommand(
                    MessageCommandNames.EyebrowDownScale,
                    $"{parameters.EyebrowDownScale}"
                    ),
                new ReceivedCommand(
                    MessageCommandNames.LengthFromWristToPalm,
                    $"{parameters.LengthFromWristToPalm}"
                    ),
                new ReceivedCommand(
                    MessageCommandNames.LengthFromWristToTip,
                    $"{parameters.LengthFromWristToTip}"
                    ),
            };

            foreach (var cmd in eyebrowCommands)
            {
                handler.ReceiveCommand(cmd);
            }

            if (onlyEyebrow)
            {
                return;
            }

            //レイアウト調整はコレ一発でおしまいです
            handler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.ResetDeviceLayout));
        }
Esempio n. 2
0
        private async void OnVRMLoaded(VrmLoadedInfo vrm)
        {
            var lookAtHead          = vrm.vrmRoot.GetComponent <VRMLookAtHead>();
            var lookAtIk            = vrm.vrmRoot.GetComponent <LookAtIK>();
            var bodyIK              = vrm.vrmRoot.GetComponent <FullBodyBipedIK>();
            var initialHeadIkTarget = lookAtHead.Target;
            var animator            = vrm.animator;

            _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.AutoBlinkDuringFaceTracking, false.ToString()));

            //レイアウト調整
            _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.RequestAutoAdjust));
            _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.RequestAutoAdjustEyebrow));

            await Task.Delay(300);

            vrm.context.ShowMeshes();
            _isInitialized = true;

            cameraControlEnabled.onValueChanged.AddListener(value =>
            {
                _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.CameraControl, value.ToString()));
            });

            backgroundImageWidthEnabled.onValueChanged.AddListener(value =>
            {
                _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.ChangeBackgroundImageDirection, value.ToString()));
            });

            backgroundTransparentEnabled.onValueChanged.AddListener((value) =>
            {
                _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.ChangeBackground, value.ToString()));
            });

            var firstPerson = vrm.vrmRoot.GetComponent <VRMFirstPerson>();

            //アバターの目線位置に合わせる
            desktopShareEnabled.onValueChanged.AddListener((value) =>
            {
                if (!value)
                {
                    SetVideoChatMode(lookAtHead, lookAtIk, firstPerson);
                }
                else
                {
                    lookAtHead.Target      = initialHeadIkTarget;
                    lookAtIk.solver.target = lookAtHead.Target;
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.RequestAutoAdjust));
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.RequestAutoAdjustEyebrow));
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(MessageCommandNames.EnableDesktopShareMode, true.ToString()));
                }

                lookAtIk.enabled = value;
                bodyIK.enabled   = value;
                animator.SetBool(_hashWaiting, !value);
            });

            faceTrackingEnabled.onValueChanged.AddListener((value) =>
            {
                if (value)
                {
                    var device = faceTrackingDevices.options[faceTrackingDevices.value].text;
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                               MessageCommandNames.SetCameraDeviceName, device)
                                                           );
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                               MessageCommandNames.EnableFaceTracking, true.ToString())
                                                           );
                }
                else
                {
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                               MessageCommandNames.EnableFaceTracking, false.ToString())
                                                           );
                }
            });

            handTrackingEnabled.onValueChanged.AddListener((value) =>
            {
                _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                           MessageCommandNames.EnableImageBasedHandTracking, value.ToString())
                                                       );
            });

            handTrackingEnabled.onValueChanged.AddListener((value) =>
            {
                _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                           MessageCommandNames.EnableImageBasedHandTracking, value.ToString())
                                                       );
            });

            voiceLipSyncEnabled.onValueChanged.AddListener((value) =>
            {
                if (value)
                {
                    var device = microphoneDevices.options[microphoneDevices.value].text;
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                               MessageCommandNames.SetMicrophoneDeviceName, device)
                                                           );
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                               MessageCommandNames.EnableLipSync, true.ToString())
                                                           );
                }
                else
                {
                    _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                               MessageCommandNames.EnableLipSync, false.ToString())
                                                           );
                }
            });

            foreach (var device in WebCamTexture.devices)
            {
                faceTrackingDevices.options.Add(new Dropdown.OptionData(device.name));
            }

            //フェイストラッキングはデフォルトで有効
            faceTrackingDevices.value = faceTrackingDevices.options.FindIndex(c => c.text.StartsWith("FaceTime"));
            faceTrackingDevices.RefreshShownValue();
            var cameraDevice = faceTrackingDevices.options[faceTrackingDevices.value].text;

            _receivedMessageHandler.ReceiveCommand(new ReceivedCommand(
                                                       MessageCommandNames.SetCameraDeviceName, cameraDevice)
                                                   );

            foreach (var device in Microphone.devices)
            {
                microphoneDevices.options.Add(new Dropdown.OptionData(device));
            }
            microphoneDevices.value = 0;
            microphoneDevices.RefreshShownValue();

            SetVideoChatMode(lookAtHead, lookAtIk, firstPerson);
        }