Example #1
0
        public BodyMotionManagerReceiver(IMessageReceiver receiver, BodyMotionManager bodyMotionManager)
        {
            _bodyMotionManager = bodyMotionManager;

            receiver.AssignCommandHandler(
                VmmCommands.EnableWaitMotion,
                message => EnableWaitMotion(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.WaitMotionScale,
                message => SetWaitMotionScale(message.ParseAsPercentage())
                );
            receiver.AssignCommandHandler(
                VmmCommands.WaitMotionPeriod,
                message => SetWaitMotionDuration(message.ToInt())
                );
            receiver.AssignCommandHandler(
                VmmCommands.EnableBodyLeanZ,
                message => bodyMotionManager.EnableImageBaseBodyLeanZ(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.EnableNoHandTrackMode,
                message => bodyMotionManager.SetNoHandTrackMode(message.ToBoolean())
                );
            _waitingMotionSize = _bodyMotionManager.WaitingBodyMotion.MotionSize;
            SetWaitMotionScale(1.25f);
        }
 public VirtualCamReceiver(IMessageReceiver receiver, VirtualCamCapture capture)
 {
     receiver.AssignCommandHandler(
         VmmCommands.SetVirtualCamEnable,
         c => capture.EnableCapture = c.ToBoolean()
         );
     receiver.AssignCommandHandler(
         VmmCommands.SetVirtualCamWidth,
         c =>
     {
         //NOTE: 4の倍数だけ通すのはストライドとかそういうアレです
         int width = c.ToInt();
         if (width >= 80 && width <= 1920 && width % 4 == 0)
         {
             capture.Width = width;
         }
     });
     receiver.AssignCommandHandler(
         VmmCommands.SetVirtualCamHeight,
         c => {
         int height = c.ToInt();
         if (height >= 80 && height < 1920 && height % 4 == 0)
         {
             capture.Height = height;
         }
     });
 }
Example #3
0
        public FaceControlConfigurationReceiver(IMessageReceiver receiver, FaceControlConfiguration config)
        {
            receiver.AssignCommandHandler(
                VmmCommands.EnableFaceTracking,
                message =>
            {
                _enableWebCamTracking = message.ToBoolean();
                SetFaceControlMode();
            });
            receiver.AssignCommandHandler(
                VmmCommands.ExTrackerEnable,
                message =>
            {
                _enableExTracker = message.ToBoolean();
                SetFaceControlMode();
            });

            void SetFaceControlMode()
            {
                config.ControlMode =
                    _enableExTracker ? FaceControlModes.ExternalTracker :
                    _enableWebCamTracking ? FaceControlModes.WebCam :
                    FaceControlModes.None;
            }
        }
        public void Initialize(
            IMessageReceiver receiver,
            KeyboardProvider keyboard,
            TouchPadProvider touchPad,
            MidiControllerProvider midiController,
            ParticleStore particleStore
            )
        {
            _keyboard                 = keyboard;
            _touchPad                 = touchPad;
            _midiController           = midiController;
            _particleStore            = particleStore;
            _keyboardVisibility       = keyboard.GetComponent <KeyboardVisibility>();
            _touchPadVisibility       = touchPad.GetComponent <TouchpadVisibility>();
            _midiControllerVisibility = midiController.GetComponent <MidiControllerVisibility>();

            receiver.AssignCommandHandler(
                VmmCommands.HidVisibility,
                message => SetHidVisibility(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.MidiControllerVisibility,
                message => SetMidiVisibility(message.ToBoolean())
                );
        }
Example #5
0
        public void Initialize(IMessageReceiver receiver)
        {
            receiver.AssignCommandHandler(
                VmmCommands.EnableLipSync,
                message => SetLipSyncEnable(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.SetMicrophoneDeviceName,
                message => SetMicrophoneDeviceName(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.ExTrackerEnable,
                message => SetExTrackerEnable(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.ExTrackerEnableLipSync,
                message => SetExTrackerLipSyncEnable(message.ToBoolean())
                );

            receiver.AssignQueryHandler(
                VmmQueries.CurrentMicrophoneDeviceName,
                query => query.Result = _lipSyncContext.DeviceName
                );
            receiver.AssignQueryHandler(
                VmmQueries.MicrophoneDeviceNames,
                query => query.Result = string.Join("\t", Microphone.devices)
                );
        }
Example #6
0
        public void Initialize(
            IMessageSender sender,
            IMessageReceiver receiver,
            VRMPreviewCanvas previewCanvas,
            IKTargetTransforms ikTargets,
            ErrorIndicateSender errorSender,
            ErrorInfoFactory errorInfoFactory
            )
        {
            _sender        = sender;
            _previewCanvas = previewCanvas;
            _ikTargets     = ikTargets;

            _errorSender      = errorSender;
            _errorInfoFactory = errorInfoFactory;

            receiver.AssignCommandHandler(
                VmmCommands.OpenVrmPreview,
                message => LoadModelForPreview(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.OpenVrm,
                message =>
            {
                previewCanvas.Hide();
                LoadModel(message.Content);
            });
            receiver.AssignCommandHandler(
                VmmCommands.CancelLoadVrm,
                _ => previewCanvas.Hide()
                );
        }
Example #7
0
        public void Initialize(IMessageReceiver receiver, IMessageSender sender)
        {
            receiver.AssignCommandHandler(
                VmmCommands.EnableFpsAssumedRightHand,
                c => EnableFpsAssumedRightHand = c.ToBoolean()
                );
            receiver.AssignCommandHandler(
                VmmCommands.EnableHidRandomTyping,
                c =>
            {
                _randomizeKey = c.ToBoolean();
                //値が変わる時点で残ってるキュー(普通ないけど)を消しておく
                _randomizedDownKeyQueue.Clear();
            });

            //NOTE: ここ2つは「VRoid SDKを使ってる間はキーボード監視について余計な操作をやめろ」的な意味
            receiver.AssignCommandHandler(
                VmmCommands.OpenVRoidSdkUi,
                _ => UnregisterKeyboard()
                );

            sender.SendingMessage += message =>
            {
                if (message.Command == nameof(MessageFactory.VRoidModelLoadCanceled) ||
                    message.Command == nameof(MessageFactory.VRoidModelLoadCompleted))
                {
                    RegisterKeyboard();
                }
            };
        }
Example #8
0
        public FaceControlManagerMessageIo(IMessageReceiver receiver, IMessageSender sender, FaceControlManager faceControlManager)
        {
            receiver.AssignCommandHandler(
                VmmCommands.AutoBlinkDuringFaceTracking,
                message =>
                faceControlManager.PreferAutoBlinkOnWebCamTracking = message.ToBoolean()
                );

            receiver.AssignCommandHandler(
                VmmCommands.FaceDefaultFun,
                message =>
                faceControlManager.DefaultBlendShape.FaceDefaultFunValue = message.ParseAsPercentage()
                );

            receiver.AssignQueryHandler(
                VmmQueries.GetBlendShapeNames,
                query => query.Result = string.Join("\t", faceControlManager.BlendShapeStore.GetBlendShapeNames())
                );

            faceControlManager.VrmInitialized += () =>
            {
                sender.SendCommand(MessageFactory.Instance.SetBlendShapeNames(
                                       string.Join("\t", faceControlManager.BlendShapeStore.GetBlendShapeNames())
                                       ));
            };

            //特に眉まわりのブレンドシェイプ割り当てだけは別途やる
            var _ = new BlendShapeAssignReceiver(receiver, faceControlManager);
        }
Example #9
0
        public WordToMotionManagerReceiver(IMessageReceiver receiver, WordToMotionManager manager)
        {
            _manager = manager;
            receiver.AssignCommandHandler(
                VmmCommands.ReloadMotionRequests,
                message => ReloadMotionRequests(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.PlayWordToMotionItem,
                message => PlayWordToMotionItem(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.EnableWordToMotionPreview,
                message => _manager.EnablePreview = message.ToBoolean()
                );
            receiver.AssignCommandHandler(
                VmmCommands.SendWordToMotionPreviewInfo,
                message => ReceiveWordToMotionPreviewInfo(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.SetDeviceTypeToStartWordToMotion,
                message => SetWordToMotionInputType(message.ToInt())
                );

            //NOTE: 残骸コードを残しときます。ビルトインモーション後の手の動きがちょっと心配ではあるよね、という話

            //NOTE: キーボード/マウスだけ消し、ゲームパッドや画像ハンドトラッキングがある、というケースでは多分無理にいじらないでも大丈夫です。
            // case MessageCommandNames.EnableHidArmMotion:
            //     //腕アニメーションが無効なとき、アニメーションの終了処理をちょっと切り替える
            //     manager.ShouldSetDefaultClipAfterMotion = !message.ToBoolean();
            //     break;
        }
        public SettingAutoAdjuster(
            IVRMLoadable vrmLoadable,
            IMessageReceiver receiver,
            IMessageSender sender,
            IMessageDispatcher dispatcher,
            VRMBlendShapeStore blendShapeStore,
            Camera mainCam
            )
        {
            _mainCam         = mainCam.transform;
            _blendShapeStore = blendShapeStore;

            _sender     = sender;
            _dispatcher = dispatcher;

            receiver.AssignCommandHandler(
                VmmCommands.RequestAutoAdjust,
                _ => AutoAdjust()
                );
            receiver.AssignCommandHandler(
                VmmCommands.RequestAutoAdjustEyebrow,
                _ => AutoAdjustOnlyEyebrow()
                );


            vrmLoadable.PreVrmLoaded += info => _vrmRoot = info.vrmRoot;
            vrmLoadable.VrmDisposing += () => _vrmRoot = null;
        }
 public ElbowMotionModifyReceiver(IMessageReceiver receiver, ElbowMotionModifier modifier)
 {
     receiver.AssignCommandHandler(
         VmmCommands.SetWaistWidth,
         message => modifier.SetWaistWidth(message.ParseAsCentimeter())
         );
     receiver.AssignCommandHandler(
         VmmCommands.SetElbowCloseStrength,
         message => modifier.SetElbowCloseStrength(message.ParseAsPercentage())
         );
 }
Example #12
0
 public void Initialize(IMessageReceiver receiver, IMessageSender sender)
 {
     _sender = sender;
     receiver.AssignCommandHandler(
         VmmCommands.OpenVRoidSdkUi,
         _ => _sender?.SendCommand(MessageFactory.Instance.VRoidModelLoadCanceled())
         );
     receiver.AssignCommandHandler(
         VmmCommands.RequestLoadVRoidWithId,
         _ => _sender?.SendCommand(MessageFactory.Instance.VRoidModelLoadCanceled())
         );
 }
 public void Initialize(IMessageReceiver receiver, ScreenshotCountDownCanvasRoot countDownCanvas)
 {
     _countDownCanvas = countDownCanvas;
     receiver.AssignCommandHandler(
         VmmCommands.TakeScreenshot,
         _ => StartScreenshotCountDown()
         );
     receiver.AssignCommandHandler(
         VmmCommands.OpenScreenshotFolder,
         _ => OpenScreenshotFolder()
         );
 }
Example #14
0
 public BehaviorBasedBlinkReceiver(IMessageReceiver receiver, BehaviorBasedAutoBlinkAdjust autoBlinkAdjust)
 {
     receiver.AssignCommandHandler(
         VmmCommands.EnableHeadRotationBasedBlinkAdjust,
         message
         => autoBlinkAdjust.EnableHeadRotationBasedBlinkAdjust = message.ToBoolean()
         );
     receiver.AssignCommandHandler(
         VmmCommands.EnableLipSyncBasedBlinkAdjust,
         message =>
         autoBlinkAdjust.EnableLipSyncBasedBlinkAdjust = message.ToBoolean()
         );
 }
        public void Initialize(IVRMLoadable vrmLoadable, IMessageReceiver receiver, IKeyMouseEventSource keyboardEventSource)
        {
            receiver.AssignCommandHandler(
                VmmCommands.Chromakey,
                message =>
            {
                var argb = message.ToColorFloats();
                SetWindowTransparency(argb[0] == 0);
            });
            receiver.AssignCommandHandler(
                VmmCommands.WindowFrameVisibility,
                message => SetWindowFrameVisibility(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.IgnoreMouse,
                message => SetIgnoreMouseInput(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.TopMost,
                message => SetTopMost(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.WindowDraggable,
                message => SetWindowDraggable(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.MoveWindow,
                message =>
            {
                int[] xy = message.ToIntArray();
                MoveWindow(xy[0], xy[1]);
            });
            receiver.AssignCommandHandler(
                VmmCommands.ResetWindowSize,
                _ => ResetWindowSize()
                );
            receiver.AssignCommandHandler(
                VmmCommands.SetWholeWindowTransparencyLevel,
                message => SetTransparencyLevel(message.ToInt())
                );
            receiver.AssignCommandHandler(
                VmmCommands.SetAlphaValueOnTransparent,
                message => SetAlphaOnTransparent(message.ToInt())
                );

            _mouseObserve = keyboardEventSource.MouseButton.Subscribe(info =>
            {
                if (info == "LDown")
                {
                    ReserveHitTestJudgeOnNextFrame();
                }
            });

            vrmLoadable.PreVrmLoaded += info => _renderers = info.renderers;
            vrmLoadable.VrmDisposing += () => _renderers = new Renderer[0];
        }
        public void Initialize(IVRMLoadable vrmLoadable, IMessageReceiver receiver)
        {
            vrmLoadable.VrmLoaded    += OnVrmLoaded;
            vrmLoadable.VrmDisposing += OnVrmDisposing;

            receiver.AssignCommandHandler(
                VmmCommands.EnableShoulderMotionModify,
                command => EnableRotationModification = command.ToBoolean()
                );

            receiver.AssignCommandHandler(
                VmmCommands.EnableWaitMotion,
                command => EnableWaitMotion = command.ToBoolean()
                );
        }
 public void Initialize(IMessageReceiver receiver)
 {
     receiver.AssignCommandHandler(
         VmmCommands.EnableHidRandomTyping,
         c => _randomizeKey = c.ToBoolean()
         );
 }
 public ParticleControlReceiver(IMessageReceiver receiver, ParticleStore particleStore)
 {
     _particleStore = particleStore;
     receiver.AssignCommandHandler(
         VmmCommands.SetKeyboardTypingEffectType,
         message => SetParticleType(message.ToInt())
         );
     receiver.AssignCommandHandler(
         VmmCommands.HidVisibility,
         message => SetKeyboardVisibility(message.ToBoolean())
         );
     receiver.AssignCommandHandler(
         VmmCommands.MidiControllerVisibility,
         message => SetMidiVisibility(message.ToBoolean())
         );
 }
Example #19
0
 public void Initialize(IMessageReceiver receiver)
 {
     receiver.AssignCommandHandler(
         VmmCommands.EnableMidiRead,
         command => SetMidiReadEnable(command.ToBoolean())
         );
 }
        public void Initialize(FaceTracker faceTracker, IVRMLoadable vrmLoadable, IMessageReceiver receiver)
        {
            _faceTracker = faceTracker;
            //_faceRotToEuler = new FaceRotToEulerByOpenCVPose(openCvFacePose);
            _faceRotToEuler = new FaceRotToEulerByFaceParts(_faceTracker.FaceParts);

            vrmLoadable.VrmLoaded += info =>
            {
                var animator = info.animator;
                _neck     = animator.GetBoneTransform(HumanBodyBones.Neck);
                _head     = animator.GetBoneTransform(HumanBodyBones.Head);
                _hasNeck  = (_neck != null);
                _hasModel = true;
            };

            vrmLoadable.VrmDisposing += () =>
            {
                _hasModel = false;
                _hasNeck  = false;
                _neck     = null;
                _head     = null;
            };

            receiver.AssignCommandHandler(
                VmmCommands.EnableWebCamHighPowerMode,
                message => _isHighPowerMode = message.ToBoolean()
                );
        }
 public void Initialize(IMessageReceiver receiver)
 {
     receiver.AssignCommandHandler(
         VmmCommands.EnableFpsAssumedRightHand,
         c => EnableFpsAssumedRightHand = c.ToBoolean()
         );
 }
 public VRMPreviewLanguage(IMessageReceiver receiver)
 {
     receiver.AssignCommandHandler(
         VmmCommands.Language,
         message => Language = message.Content
         );
 }
Example #23
0
 public HandTrackerReceiver(IMessageReceiver receiver, HandTracker handTracker)
 {
     receiver.AssignCommandHandler(
         VmmCommands.EnableImageBasedHandTracking,
         c => handTracker.ImageProcessEnabled = c.ToBoolean()
         );
 }
Example #24
0
        public ImageQualitySettingReceiver(IMessageReceiver receiver, string defaultQualityName)
        {
            receiver.AssignCommandHandler(VmmCommands.SetImageQuality,
                                          c => SetImageQuality(c.Content)
                                          );

            receiver.AssignQueryHandler(
                VmmQueries.GetQualitySettingsInfo,
                q =>
            {
                q.Result = JsonUtility.ToJson(new ImageQualityInfo()
                {
                    ImageQualityNames   = QualitySettings.names,
                    CurrentQualityIndex = QualitySettings.GetQualityLevel(),
                });
            });

            receiver.AssignQueryHandler(
                VmmQueries.ApplyDefaultImageQuality,
                q => {
                SetImageQuality(defaultQualityName);
                q.Result = defaultQualityName;
            });

            SetFrameRateWithQuality(QualitySettings.GetQualityLevel());
        }
 public void Initialize(IMessageReceiver receiver, DeformableCounter deformableCounter)
 {
     _deformableCounter = deformableCounter;
     receiver.AssignCommandHandler(
         VmmCommands.GamepadVisibility,
         message => SetGamepadVisibility(message.ToBoolean())
         );
 }
        public BlendShapeAssignReceiver(IMessageReceiver receiver, FaceControlManager faceControlManager)
        {
            _faceControlManager = faceControlManager;

            receiver.AssignCommandHandler(
                VmmCommands.EyebrowLeftUpKey,
                message =>
            {
                EyebrowBlendShape.LeftUpKey = message.Content;
                RefreshTarget();
            });
            receiver.AssignCommandHandler(
                VmmCommands.EyebrowLeftDownKey,
                message =>
            {
                EyebrowBlendShape.LeftDownKey = message.Content;
                RefreshTarget();
            });
            receiver.AssignCommandHandler(
                VmmCommands.EyebrowLeftDownKey,
                message =>
            {
                EyebrowBlendShape.LeftDownKey = message.Content;
                RefreshTarget();
            });
            receiver.AssignCommandHandler(
                VmmCommands.UseSeparatedKeyForEyebrow,
                message =>
            {
                EyebrowBlendShape.UseSeparatedTarget = message.ToBoolean();
                RefreshTarget();
            });
            receiver.AssignCommandHandler(
                VmmCommands.EyebrowRightUpKey,
                message =>
            {
                EyebrowBlendShape.RightUpKey = message.Content;
                RefreshTarget();
            });
            receiver.AssignCommandHandler(
                VmmCommands.EyebrowRightDownKey,
                message =>
            {
                EyebrowBlendShape.RightDownKey = message.Content;
                RefreshTarget();
            });
            receiver.AssignCommandHandler(
                VmmCommands.EyebrowUpScale,
                message => EyebrowBlendShape.UpScale = message.ParseAsPercentage()
                );
            receiver.AssignCommandHandler(
                VmmCommands.EyebrowDownScale,
                message => EyebrowBlendShape.DownScale = message.ParseAsPercentage()
                );
        }
Example #27
0
 public VRMPreviewLanguage(IMessageReceiver receiver)
 {
     receiver.AssignCommandHandler(
         VmmCommands.Language,
         message =>
         //NOTE: WPF側が第3言語に対応する可能性があるが、Unity側は日英のみで通す
         Language = message.Content == "Japanese" ? "Japanese" : "English"
         );
 }
 public WindSettingReceiver(IMessageReceiver receiver, VRMWind wind)
 {
     receiver.AssignCommandHandler(
         VmmCommands.WindEnable,
         c => wind.EnableWind(c.ToBoolean())
         );
     receiver.AssignCommandHandler(
         VmmCommands.WindStrength,
         c => wind.SetStrength(c.ParseAsPercentage())
         );
     receiver.AssignCommandHandler(
         VmmCommands.WindInterval,
         c => wind.SetInterval(c.ParseAsPercentage())
         );
     receiver.AssignCommandHandler(
         VmmCommands.WindYaw,
         c => wind.WindYawDegree = c.ToInt()
         );
 }
Example #29
0
        public FaceTrackerReceiver(IMessageReceiver receiver, FaceTracker faceTracker)
        {
            _faceTracker = faceTracker;

            receiver.AssignCommandHandler(
                VmmCommands.SetCameraDeviceName,
                message => SetCameraDeviceName(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.EnableFaceTracking,
                message => SetEnableFaceTracking(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.ExTrackerEnable,
                message => SetEnableExTracker(message.ToBoolean())
                );
            receiver.AssignCommandHandler(
                VmmCommands.CalibrateFace,
                message => _faceTracker.StartCalibration()
                );
            receiver.AssignCommandHandler(
                VmmCommands.SetCalibrateFaceData,
                message => _faceTracker.SetCalibrateData(message.Content)
                );
            receiver.AssignCommandHandler(
                VmmCommands.DisableFaceTrackingHorizontalFlip,
                message => _faceTracker.DisableHorizontalFlip = message.ToBoolean()
                );

            receiver.AssignQueryHandler(
                VmmQueries.CameraDeviceNames,
                query => query.Result = string.Join("\t", GetCameraDeviceNames())
                );
        }
Example #30
0
        public FaceControlManagerMessageIo(
            IMessageReceiver receiver, IMessageSender sender,
            EyeBonePostProcess eyeBonePostProcess,
            FaceControlManager faceControlManager
            )
        {
            receiver.AssignCommandHandler(
                VmmCommands.AutoBlinkDuringFaceTracking,
                message =>
                faceControlManager.PreferAutoBlinkOnWebCamTracking = message.ToBoolean()
                );

            receiver.AssignCommandHandler(
                VmmCommands.FaceDefaultFun,
                message =>
                faceControlManager.DefaultBlendShape.FaceDefaultFunValue = message.ParseAsPercentage()
                );

            receiver.AssignCommandHandler(
                VmmCommands.SetEyeBoneRotationScale,
                message => eyeBonePostProcess.Scale = message.ParseAsPercentage()
                );
        }