void Start()
        {
            var server = GetComponent <uOSC.uOscServer>();

            server.onDataReceived.AddListener(OnDataReceived);

            window                   = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();
            faceController           = GameObject.Find("AnimationController").GetComponent <FaceController>();
            VMCEvents.OnModelLoaded += (GameObject CurrentModel) =>
            {
                if (CurrentModel != null)
                {
                    this.CurrentModel = CurrentModel;
                    vrmLookAtHead     = CurrentModel.GetComponent <VRMLookAtHead>();
                    animator          = CurrentModel.GetComponent <Animator>();
                    headTransform     = null;
                    if (animator != null)
                    {
                        headTransform = animator.GetBoneTransform(HumanBodyBones.Head);
                    }
                }
            };
            VMCEvents.OnCameraChanged += (Camera currentCamera) =>
            {
                this.currentCamera = currentCamera;
            };

            beforeFaceApply = () =>
            {
                vrmLookAtHead.Target = lookTargetOSC.transform;
                vrmLookAtHead.LookWorldPosition();
                vrmLookAtHead.Target = null;
            };
        }
    void Start()
    {
        var server = GetComponent <uOSC.uOscServer>();

        server.onDataReceived.AddListener(OnDataReceived);

        window                    = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();
        faceController            = GameObject.Find("AnimationController").GetComponent <FaceController>();
        window.ModelLoadedAction += (GameObject CurrentModel) =>
        {
            if (CurrentModel != null)
            {
                this.CurrentModel = CurrentModel;
                vrmLookAtHead     = CurrentModel.GetComponent <VRMLookAtHead>();
            }
        };
        window.CameraChangedAction += (Camera currentCamera) =>
        {
            this.currentCamera = currentCamera;
        };

        beforeFaceApply = () =>
        {
            vrmLookAtHead.Target = lookTargetOSC.transform;
            vrmLookAtHead.LookWorldPosition();
            vrmLookAtHead.Target = null;
        };
    }
 void Start()
 {
     window = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();
     window.ModelLoadedAction += (GameObject CurrentModel) =>
     {
         if (CurrentModel != null)
         {
             blendShapeProxy = CurrentModel.GetComponent <VRMBlendShapeProxy>();
         }
     };
 }
Beispiel #4
0
        private void Start()
        {
            window = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();

            VMCEvents.OnModelLoaded += (GameObject CurrentModel) =>
            {
                if (CurrentModel != null)
                {
                    this.CurrentModel = CurrentModel;
                    vrik = CurrentModel.GetComponent <VRIK>();
                }
            };

            KeyboardAction.KeyDownEvent += (object sender, KeyboardEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    if (e.KeyName == "左Shift")
                    {
                        isLeftShiftKeyDown = true;
                    }
                    if (e.KeyName == "右Shift")
                    {
                        isRightShiftKeyDown = true;
                    }
                    if (e.KeyName == "P")
                    {
                        Import(isLeftShiftKeyDown || isRightShiftKeyDown);
                    }
                }
            };

            KeyboardAction.KeyUpEvent += (object sender, KeyboardEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    if (e.KeyName == "左Shift")
                    {
                        isLeftShiftKeyDown = false;
                    }
                    if (e.KeyName == "右Shift")
                    {
                        isRightShiftKeyDown = false;
                    }
                }
            };

            RootObject = new GameObject("TrackerImporter").transform;
        }
Beispiel #5
0
    void Start()
    {
        var server = GetComponent <uOSC.uOscServer>();

        server.onDataReceived.AddListener(OnDataReceived);

        window = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();
        window.ModelLoadedAction += (GameObject CurrentModel) =>
        {
            if (CurrentModel != null)
            {
                this.CurrentModel = CurrentModel;
                blendShapeProxy   = CurrentModel.GetComponent <VRMBlendShapeProxy>();
                vrmLookAtHead     = CurrentModel.GetComponent <VRMLookAtHead>();
            }
        };
        window.CameraChangedAction += (Camera currentCamera) =>
        {
            this.currentCamera = currentCamera;
        };
    }
Beispiel #6
0
    private void Start()
    {
        window = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();

        window.ModelLoadedAction += (GameObject CurrentModel) =>
        {
            if (CurrentModel != null)
            {
                this.CurrentModel = CurrentModel;
                vrik = CurrentModel.GetComponent <VRIK>();
            }
        };

        KeyboardAction.KeyDownEvent += (object sender, KeyboardEventArgs e) =>
        {
            if (this.isActiveAndEnabled)
            {
                if (e.KeyName == "S")
                {
                    Export();
                }
            }
        };
    }
Beispiel #7
0
    void Start()
    {
        uClient         = GetComponent <uOSC.uOscClient>();
        window          = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();
        handTrackerRoot = GameObject.Find("HandTrackerRoot");

        trackerHandler = handTrackerRoot.GetComponent <TrackerHandler>();

        window.ModelLoadedAction += (GameObject CurrentModel) =>
        {
            if (CurrentModel != null)
            {
                this.CurrentModel = CurrentModel;
                animator          = CurrentModel.GetComponent <Animator>();
                vrik            = CurrentModel.GetComponent <VRIK>();
                blendShapeProxy = CurrentModel.GetComponent <VRMBlendShapeProxy>();
            }
        };

        window.CameraChangedAction += (Camera currentCamera) =>
        {
            this.currentCamera = currentCamera;
        };

        steamVR2Input.KeyDownEvent += (object sender, OVRKeyEventArgs e) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: ConDown");
                try
                {
                    uClient?.Send("/VMC/Ext/Con", 1, e.Name, e.IsLeft ? 1 : 0, e.IsTouch ? 1 : 0, e.IsAxis ? 1 : 0, e.Axis.x, e.Axis.y, e.Axis.z);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };

        steamVR2Input.KeyUpEvent += (object sender, OVRKeyEventArgs e) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: ConUp");
                try
                {
                    uClient?.Send("/VMC/Ext/Con", 0, e.Name, e.IsLeft ? 1 : 0, e.IsTouch ? 1 : 0, e.IsAxis ? 1 : 0, e.Axis.x, e.Axis.y, e.Axis.z);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };

        steamVR2Input.AxisChangedEvent += (object sender, OVRKeyEventArgs e) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: ConAxis");
                try
                {
                    if (e.IsAxis)
                    {
                        uClient?.Send("/VMC/Ext/Con", 2, e.Name, e.IsLeft ? 1 : 0, e.IsTouch ? 1 : 0, e.IsAxis ? 1 : 0, e.Axis.x, e.Axis.y, e.Axis.z);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };

        KeyboardAction.KeyDownEvent += (object sender, KeyboardEventArgs e) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: KeyDown");
                try
                {
                    uClient?.Send("/VMC/Ext/Key", 1, e.KeyName, e.KeyCode);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };
        KeyboardAction.KeyUpEvent += (object sender, KeyboardEventArgs e) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: KeyUp");
                try
                {
                    uClient?.Send("/VMC/Ext/Key", 0, e.KeyName, e.KeyCode);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };

        midiCCWrapper.noteOnDelegateProxy += (MidiJack.MidiChannel channel, int note, float velocity) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: KeyDown");
                try
                {
                    uClient?.Send("/VMC/Ext/Midi/Note", 1, (int)channel, note, velocity);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };
        midiCCWrapper.noteOffDelegateProxy += (MidiJack.MidiChannel channel, int note) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: KeyDown");
                try
                {
                    uClient?.Send("/VMC/Ext/Midi/Note", 0, (int)channel, note, (float)0f);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };
        midiCCWrapper.knobUpdateFloatDelegate += (int knobNo, float value) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: KeyDown");
                try
                {
                    uClient?.Send("/VMC/Ext/Midi/CC/Val", knobNo, value);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };
        midiCCWrapper.knobUpdateBoolDelegate += (int knobNo, bool value) =>
        {
            if (this.isActiveAndEnabled)
            {
                //Debug.Log("Ext: KeyDown");
                try
                {
                    uClient?.Send("/VMC/Ext/Midi/CC/Bit", knobNo, (int)(value?1:0));
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        };
    }
        void Start()
        {
            uClient         = GetComponent <uOSC.uOscClient>();
            window          = GameObject.Find("ControlWPFWindow").GetComponent <ControlWPFWindow>();
            handTrackerRoot = GameObject.Find("HandTrackerRoot");

            VMCEvents.OnModelLoaded += (GameObject CurrentModel) =>
            {
                if (CurrentModel != null)
                {
                    this.CurrentModel = CurrentModel;
                    animator          = CurrentModel.GetComponent <Animator>();
                    vrik            = CurrentModel.GetComponent <VRIK>();
                    blendShapeProxy = CurrentModel.GetComponent <VRMBlendShapeProxy>();
                }
            };

            VMCEvents.OnCameraChanged += (Camera currentCamera) =>
            {
                this.currentCamera = currentCamera;
            };

            window.VRMmetaLodedAction += (VRMData vrmdata) =>
            {
                this.vrmdata    = vrmdata;
                this.remoteName = null;
                this.remoteJson = null;
                SendPerLowRate(); //即時送信
            };
            window.VRMRemoteLoadedAction += (string path) =>
            {
                this.vrmdata = null;
                if (path.StartsWith("dmmvrconnect://"))
                {
                    var parsed = path.Substring("dmmvrconnect://".Length).Split('/');
                    remoteName = "dmmvrconnect";
                    remoteJson = Json.Serializer.Serialize(new DMMVRConnectRemote {
                        user_id = parsed[0], avatar_id = parsed[1]
                    });
                }
                else if (path.StartsWith("vroidhub://"))
                {
                    var characterModelId = path.Substring("vroidhub://".Length);
                    remoteName = "vroidhub";
                    remoteJson = Json.Serializer.Serialize(new VRoidHubRemote {
                        characterModelId = characterModelId
                    });
                }
                SendPerLowRate(); //即時送信
            };

            VMCEvents.OnLightChanged += () =>
            {
                SendPerLowRate(); //即時送信
            };

            VMCEvents.OnLoadedConfigPathChanged += path =>
            {
                SendPerLowRate(); //即時送信
            };

            steamVR2Input.KeyDownEvent += (object sender, OVRKeyEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: ConDown");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Con", 1, e.Name, e.IsLeft ? 1 : 0, e.IsTouch ? 1 : 0, e.IsAxis ? 1 : 0, e.Axis.x, e.Axis.y, e.Axis.z);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };

            steamVR2Input.KeyUpEvent += (object sender, OVRKeyEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: ConUp");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Con", 0, e.Name, e.IsLeft ? 1 : 0, e.IsTouch ? 1 : 0, e.IsAxis ? 1 : 0, e.Axis.x, e.Axis.y, e.Axis.z);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };

            steamVR2Input.AxisChangedEvent += (object sender, OVRKeyEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: ConAxis");
                    try
                    {
                        if (e.IsAxis)
                        {
                            uClient?.Send("/VMC/Ext/Con", 2, e.Name, e.IsLeft ? 1 : 0, e.IsTouch ? 1 : 0, e.IsAxis ? 1 : 0, e.Axis.x, e.Axis.y, e.Axis.z);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };

            KeyboardAction.KeyDownEvent += (object sender, KeyboardEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: KeyDown");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Key", 1, e.KeyName, e.KeyCode);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };
            KeyboardAction.KeyUpEvent += (object sender, KeyboardEventArgs e) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: KeyUp");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Key", 0, e.KeyName, e.KeyCode);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };

            midiCCWrapper.noteOnDelegateProxy += (MidiJack.MidiChannel channel, int note, float velocity) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: KeyDown");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Midi/Note", 1, (int)channel, note, velocity);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };
            midiCCWrapper.noteOffDelegateProxy += (MidiJack.MidiChannel channel, int note) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: KeyDown");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Midi/Note", 0, (int)channel, note, (float)0f);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };
            midiCCWrapper.knobUpdateFloatDelegate += (int knobNo, float value) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: KeyDown");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Midi/CC/Val", knobNo, value);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };
            midiCCWrapper.knobUpdateBoolDelegate += (int knobNo, bool value) =>
            {
                if (this.isActiveAndEnabled)
                {
                    //Debug.Log("Ext: KeyDown");
                    try
                    {
                        uClient?.Send("/VMC/Ext/Midi/CC/Bit", knobNo, (int)(value ? 1 : 0));
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            };

            this.gameObject.SetActive(false);
            uClient.enabled = true;
        }