OSCã¡ãã»ã¼ã¸ã§VRChatã®ã¢ã¯ã·ã§ã³ãå®è¡ãã
ã¯ããã«
æè¿ãVRChatã«é±1ã§ãã¼ã¹ã¡ããã¡ãããã°ã¤ã³ãã¦éãã§ããä¸æ¹ãç¾å®ã¨VRChatãçµã³ä»ããé¢ç½ããã®ãä½ããªããã¨æ¨¡ç´¢ãã¦ãã¾ãã ãããªãã«éã¹ããã®ãããã¤ãä½ããã¨ãã§ããã®ã§ãããããããOSCã¡ãã»ã¼ã¸ãæ å ±ä¼æ¬æ段ã®ã³ã¢æè¡ã¨ãªã£ã¦ãã¾ãã ãã ãå人çã«ã¯ã¨ã£ã¦ãæç¨ãªä»çµã¿ã ã¨æã£ã¦ãããã®ã®ããã¾ãæ å ±ãåºåã£ã¦ããªãããã使ç¨ä¾ã¯ãã¾ãè¦ãããªãå°è±¡ã§ãã ããã§ãOSCã¡ãã»ã¼ã¸ã«ããããªã¬ã¼ã¨ã¢ã¯ã·ã§ã³ã誰ã§ãåãããããã«ããã³ãºãªã³å½¢å¼ã®èª¬æãã¤ãã¤ãæ¸ãã¦ã¿ã¾ããã
ä»åã¯ãã¥ã¼ããªã¢ã«ã¨ãã¦ãã¯ã¼ã«ãä¸ã®Cubeãªãã¸ã§ã¯ããã¢ã¯ãã£ãã¼ã/ãã£ã¢ã¯ãã£ãã¼ããã¦ã¿ã¾ãã ãªãOSCã¡ãã»ã¼ã¸ã®éä¿¡å´ã¯Pythonã¹ã¯ãªããã åä¿¡å´ã¯Unityã§å®è£ ãã¾ãã 誰ã§ãã¨è¨ãã¤ã¤ç³ã訳ãªãã®ã§ãããæä½éãä¸è¨ã®ã¹ãã«ããããã¨ãåæã¨ãã¾ãã
- Unity(VRChat SDK)ã§èªä½ã¯ã¼ã«ãããã«ããã¦ããã°ã¤ã³ã§ãã
- VRChatãèµ·åããPCã«Pythonãã¤ã³ã¹ãã¼ã«ããã¦ãããPythonã¨pipã³ãã³ããPowerShellããå®è¡ã§ãã
2ã«ã¤ãã¦ã¯ãPowerShellãéãã¦ä¸è¨ã®ã³ãã³ããå®è¡ã§ããã°å¤§ä¸å¤«ã§ãã
PS> python --version PS> pip --version
OSCã¨ã¯
ãããã"OSC"ãªãã¦ç¥ããªãæ¹ãæ®éãªã®ã§ããã£ã¨èª¿ã¹ã¦ã¿ã¾ãã
OpenSound Controlï¼OSCï¼ã¨ã¯ãé»å楽å¨ï¼ç¹ã«ã·ã³ã»ãµã¤ã¶ã¼ï¼ãã³ã³ãã¥ã¼ã¿ãªã©ã®æ©å¨ã«ããã¦é³æ¥½æ¼å¥ãã¼ã¿ããããã¯ã¼ã¯çµç±ã§ãªã¢ã«ã¿ã¤ã ã«å ±æããããã®éä¿¡ãããã³ã«ã§ããã
https://ja.wikipedia.org/wiki/OpenSound_Control
ã©ããããOSCã¯MIDIã¨åããé³æ¥½ã®æ¼å¥ãã¼ã¿éä¿¡ã«ä½¿ç¨ãããã¨ãç®çã¨ãã¦ä½ããããããã³ã«ã®ããã§ãã
ãã ã¡ãã»ã¼ã¸ã®æ§é ãã·ã³ãã«ã§æ±ç¨æ§ãããã®ã§ãé³æ¥½ç¨é以å¤ã§ãåé¡ãªã使ãã¾ãã
ãããå
·ä½çã«ã©ããªæ§é ãã¨ããã¨ãOSCã¡ãã»ã¼ã¸ã¯ãã¢ãã¬ã¹ãã¨ãå¼æ°ãããæãç«ã£ã¦ãã¾ã(å¼ç§°ã«ã¯ãã©ã¤ããããããã§ã)ã
ã¢ãã¬ã¹ã¯é層æ§é ãæããããã¨ãã§ããã®ã§ãåä¿¡å´ã§ãã¼ã¹ããããããã«è¨è¨ã§ãã¾ãã
ã¾ãå¼æ°ã«ã¤ãã¦ã¯ãä¸ã¤ã®ã¢ãã¬ã¹ã«å¯¾ãã¦è¤æ°å®ç¾©ãã¦ãããã¨ãå¯è½ãªããã§ãã
ä¾ãã°ãRGBã§èµ¤ã表ç¾ãããããªã¡ãã»ã¼ã¸ã§ããã°"/color 255 0 0"ã"/color/red 255"ã¨ããããã«è¨è¿°ã§ãã¾ãã
VRChatã«ãããOSCã¡ãã»ã¼ã¸ã®åãæ±ã
VRChatã«ã¯ãæ§ã ãªããªã¬ã¼ã¨ã¢ã¯ã·ã§ã³ãçµã¿åããããã¨ã§èªä½ã¯ã¼ã«ããæ§ç¯ã§ããä»çµã¿ãåãã£ã¦ãã¾ãã ãã®ããªã¬ã¼ã®1ã¤ã¨ãã¦ãVRChat SDKã«ã¯"VRC_OscButtonIn"ãå«ã¾ãã¦ãããç¹å®ã®OSCã¡ãã»ã¼ã¸ãéä¿¡ããã°çºç«ããããã¾ãã ãã ãå®è¡ã§ããã®ã¯ã¹ã¤ããã®On/Offã®ã¿ã§ã"0"ãåãåãã°Offã"ãã以å¤ã®æ°å¤"ãåãåãã°Onã¨ãã¦åä½ãã¾ãã ã¨ã¯ãããVRChatã®ãå¤é¨ãããããªã¬ã¼ãçºç«ãããããè²´éãªä»çµã¿ãªã®ã§ãããã使ç¨ã§ããã¨è¡¨ç¾ã®å¹ ãä¸æ°ã«åºããã¾ãã 次ç¯ä»¥éã§ã¯ãOSCã¡ãã»ã¼ã¸ã使ç¨ãã¦ãªãã¸ã§ã¯ãã®ã¢ã¯ãã£ãã¼ã/ãã£ã¢ã¯ãã£ãã¼ããå®è£ ããæ¹æ³ã説æãã¾ãã
OSCã¡ãã»ã¼ã¸éä¿¡å´ã®å®è£
pythonoscã®ãã¦ã³ãã¼ã
ã¾ããããããä½æããPythonã¹ã¯ãªããã«ã¦OSCã¡ãã»ã¼ã¸ãç°¡åã«ä½¿ç¨ã§ããããã«ãããããpythonoscããã±ã¼ã¸ããã¦ã³ãã¼ããã¾ãã PowerShellãèµ·åããpipã³ãã³ãã§ããã±ã¼ã¸ãåã£ã¦ãã¾ãã ãã¤ãã³ãå¿ è¦ãªã®ã§ãå¿ããã«ã
PS> pip install python-osc
ã¹ã¯ãªããã®å®è£
pythonoscããã¦ã³ãã¼ãåºæ¥ãããã¹ã¯ãªãããæ¸ãã¦ããã¾ãã ã¡ã¢å¸³ãéãã¦ãã好ããªå ´æã«ä¿åãã¦ãã ããã ä»åã¯ãã¡ã¤ã«åã"osc_message_client.py"ã¨ãã¦ä¿åãã使ç¨ãã¾ãã
# -*- coding: utf-8 -*- import sys from pythonosc import udp_client from pythonosc.osc_message_builder import OscMessageBuilder def main(): # åä¿¡å ã®VRChat IP = '127.0.0.1' PORT = 9000 # OSCã¡ãã»ã¼ã¸æ å ±ã®èªã¿è¾¼ã¿ address = sys.argv[1] arg = sys.argv[2] print('Address: '+address) print('Arg: '+arg) # OSCã¡ãã»ã¼ã¸ã®æ§ç¯ client = udp_client.UDPClient(IP, PORT) msg = OscMessageBuilder(address=address) msg.add_arg(arg) m = msg.build() # OSCã¡ãã»ã¼ã¸ã®éä¿¡ client.send(m) if __name__ == '__main__': main()
å®è¡ãã¦ããå¦çã®æ¦è¦ã¯ãã³ã¡ã³ãã«è¨è¼ã®éãã§ãã ãã¹ãç¨ã®ã¹ã¯ãªãããªã®ã§ãã¨ã©ã¼ãã³ããªã³ã°ãªãã詳細ãªè§£èª¬ãå²æãã¾ãã
ã¹ã¯ãªãããå®è£ ã§ããããPowerShellãã試ãã«åããã¦ã¿ã¾ãã ã¢ãã¬ã¹ã¯"/cube/activate"ãå¼æ°ã¯"1"ã¨"0"ãããããæå®ãã¦ã¿ã¾ãã
PS> cd [ãã¡ã¤ã«ã®ä¿åå ãã©ã«ã] PS> python .\osc_message_client.py /cube/activate 1 Address: /cube/activate Arg: 1 PS> python .\osc_message_client.py /cube/activate 0 Address: /cube/activate Arg: 0 PS>
ã¢ãã¬ã¹ã¨å¼æ°ãã¹ã¯ãªããã«æ¸¡ããç¹ã«åé¡ãªãåãã¦ããããã§ãã ãã®æç¹ã§ãOSCã¡ãã»ã¼ã¸ã¯éä¿¡ããã¦ãã¾ãã ãããåä¿¡å´ãã¾ã æ§ç¯ãã¦ããªãã®ã§ãè¦ãããä¸ã¯ä½ãèµ·ããã¾ããã ãã®ã¡ãã»ã¼ã¸ã¯ãã¾ãå¾ã»ã©ä½¿ç¨ãã¾ãã
OSCã¡ãã»ã¼ã¸åä¿¡å´ã®å®è£
ãã¹ãç¨ã¯ã¼ã«ãã®æ§ç¯
次ã¯åä¿¡å´ã®å®è£ ã§ãã ãã¡ãã¯VRChatã®èªä½ã¯ã¼ã«ãã«ãªãã®ã§ãUnityã使ç¨ãã¾ãã ã¾ãã¯ãããã¸ã§ã¯ããä½æãã¾ãã ã好ã¿ã§ãé©å½ã«ååãä»ãã¦ãã ããã
ãªãã¸ã§ã¯ãã®é ç½®
ããã¸ã§ã¯ããä½æããããã·ã¼ã³ã®ä¿åã¨VRChat SDKãã¤ã³ãã¼ããã¾ãã ããããããã¨ã©ã«ãã¼ã«ã±ã±ã£ã¨ä¸è¨ã®ãã®ã追å ãã¾ãããã
- åºç¨ã®Plane
- ããªã¬ã¼ãã³ããªã³ã°ç¨ã®ç©ºãªãã¸ã§ã¯ã
- ã¿ã¼ã²ããã«ãªãCubeãªãã¸ã§ã¯ã
- ãªã¹ãã¼ã³ç¨ã®Prefab(VRCWorld)
é層æ§é ã¯ç¹ã«æ°ã«ããå¿ è¦ã¯ãªãã§ãããä»åã¯Cubeãªãã¸ã§ã¯ãã空ãªãã¸ã§ã¯ãã®åè¦ç´ ã«ãã¾ãã ã¾ããããªã¢ã«ãCubeã«é©ç¨ãã¦ãã¾ãããç¹ã«æå³ã¯ãªãã®ã§ãã好ã¿ã§ã©ããã é ç½®ãçµãã£ãããCubeãªãã¸ã§ã¯ãã¯ãã£ã¢ã¯ãã£ãã«ãã¦ããã¾ãã
ã¢ã¯ã·ã§ã³ã®è¨å®
OSCã¡ãã»ã¼ã¸åä¿¡æã®ã¢ã¯ã·ã§ã³ãè¨å®ãã¦ããã¾ãã ã¡ãªã¿ã«ããªã¬ã¼ã¨ã¢ã¯ã·ã§ã³ã¯ãã¿ã¼ã²ããã¨ãªãCubeãªãã¸ã§ã¯ãã§ã¯ãªãã親è¦ç´ ã®ç©ºãªãã¸ã§ã¯ãã«å¯¾ãã¦è¨å®ãã¾ãã ã¨ããã®ããCubeãªãã¸ã§ã¯ãã«ããªã¬ã¼ãè¨å®ãã¦ãã¾ãã¨ãã£ã¢ã¯ãã£ãã¼ãããæç¹ã§ããªã¬ã¼ãç¡å¹ã«ãªã£ã¦ãã¾ãã OSCã¡ãã»ã¼ã¸ãåä¿¡ã§ããªããªã£ã¦ãã¾ãããã§ãã
ããã§ã¯ãHierarchyã¿ãã«ã¦ç©ºãªãã¸ã§ã¯ããé¸æãã¾ãããã ãããããInspectorã¿ãã®Add Componentãã¿ã³ãã¯ãªãã¯ãã¦ãVRC_Triggerã追å ãã¾ãã
次ã«ãã¢ã¯ãã£ãã¼ãã¨ãã£ã¢ã¯ãã£ãã¼ãç¨ã«ãã¢ã¯ã·ã§ã³ã2ã¤è¿½å ãã¦ãã ããã ãã®éã«é¸æããããªã¬ã¼ã¯ã"custom"ã§ããã§ãã ä¸è¨ã®ããã«ããããè¨å®ãã¦ãå³ã¨åãããã«ãªãã°å¤§ä¸å¤«ã§ãã
ã¢ã¯ãã£ãã¼ã·ã§ã³è¨å®
â Advance Modeã«ãã§ãã¯ãå
¥ãã
â¡"Always"ãé¸æ
â¢"OscButtonOn"ãå
¥å
â£åè¦ç´ ã®Cubeãªãã¸ã§ã¯ããé¸æ
â¤"True"ãé¸æ
ãã£ã¢ã¯ãã£ãã¼ãè¨å®
â¥"OscButtonOff"ãå
¥å
â¦"False"ãé¸æ
ããªã¬ã¼ã®è¨å®
åä¿¡é¨ã®è¦ã§ãããããªã¬ã¼ã®è¨å®ã§ãã ã¢ã¯ã·ã§ã³ã¨åãã"Add Component"ãã¿ã³ãã¯ãªãã¯ãã¦ã "VRC_Osc Button In"ã追å ãã¾ãã
ããã§è¨å®ããé ç®ã¯ã3ã¤ããã¾ãã
Address
ããã¯ãå
ã»ã©èª¬æããOSCã¡ãã»ã¼ã¸ã®ã¢ãã¬ã¹ã§ããå
ã»ã©ã®Pythonã¹ã¯ãªããã§æ¸¡ãã"/cube/activate"ãå
¥åãã¾ãã
On Button On/Off
ããã«ã¯ãããããã¹ã¤ããã®On/Offæã®ã¢ã¯ã·ã§ã³ãè¨å®ãã¾ãã
å·¦å´ã®æ¬ã§ã¯VRC_Triggerã追å ãããªãã¸ã§ã¯ããå³å´ã®æ¬ã§ã¯å®è¡ããã¢ã¯ã·ã§ã³ãé¸æãã¾ãã
ä»åã®ã±ã¼ã¹ã§ã¯ããªãã¸ã§ã¯ãã¯ã¨ãã«ç©ºãªãã¸ã§ã¯ããã¢ã¯ã·ã§ã³ã¯å
ã«è¨å®ãã"OscButtonOn"ã¨"OscButtonOff"ãé¸æãã¾ãã
ããã§ãè¨å®ã¯å®äºã§ãã
OSCã¡ãã»ã¼ã¸ã®éåä¿¡ãã¹ã
ãã¦ã以ä¸ã§Unityå´ã®è¨å®ãå®äºããã®ã§ãã¯ã¼ã«ãã®åä½ç¢ºèªãè¡ãã¾ãããã é常ã®ã¯ã¼ã«ããã¹ããåãããã«ãã¹ããã«ããå®è¡ãããã°ã¤ã³ãã¦ãã ããã ã¡ãªã¿ã«ã¦ã£ã³ãã¦ã®æä½ãè¡ãã®ã§ããã¹ã¯ãããã¢ã¼ãã好ã¾ããã§ãã
ãã°ã¤ã³æç¹ã§ã¯ãCubeãªãã¸ã§ã¯ãã¯ãã£ã¢ã¯ãã£ãã¼ãããã¦ããã®ã§è¦ãã¾ããã ããã§ãå ã»ã©ä½ã£ãã¹ã¯ãªãããå度å©ãã¦ã¿ã¾ãããã
PS> python .\osc_message_client.py /cube/activate 1 Address: /cube/activate Arg: 1 PS> python .\osc_message_client.py /cube/activate 0 Address: /cube/activate Arg: 0 PS>
"1"ãéä¿¡ããã¨Cubeãåºç¾ãã"0"ãéä¿¡ããã¨Cubeãæ¶ããããã«ãªãã¾ãã ããã確èªã§ããã°ãç¡äºã«OSCã¡ãã»ã¼ã¸ãVRChatã¾ã§å±ãã¦ãã¾ãããã£ããã
ãããã«
ããã¾ã§ãå®éã«ãµã³ãã«ãä½æããªããåºæ¬çãªåä½ã¨å®è£ ãç´¹ä»ãã¾ããã ä»åã®ä¾ã§ã¯ãã¾ãé åãä¼ãããªãã£ãããããã¾ããããOSCã¡ãã»ã¼ã¸ã使ãããªããã¨ã§ãArduinoãRaspberry Piã«ç¹ãã ã»ã³ãµã¼ã¨çµã¿åãããããå¤é¨ããã®éä¿¡ã«åºã¥ãã¦ã¡ãã»ã¼ã¸ãéä¿¡ãããªã©ãç¾å®ä¸çã®ã¤ãã³ããããªã¬ã¼ã¨ãã¦ä½¿ç¨ã§ããããã«ãªãã¾ããä¸ä¾ã§ãããä¸è¨ã®ããã«ã¹ãã¼ããã©ã³ããããªã¬ã¼ãå¼ããã¨ãå¯è½ã§ãã
ã¹ããããVRChatã¯ã¼ã«ãä¸ã®ãªãã¸ã§ã¯ãã®è²ãä»»æã®å¤(Rã®ã¿0-255)ã§å¤ããããããã«ãªãã¾ããããã¢ã¯ã·ã§ãããã©ãã¤ã³ã¿ã¼ãã§ã¼ã¹ããä½ã£ã¦ããã°ãã¹ããã«éããä½ããã§ããããã¯ããArduinoã¨ãããªã¢ã«ã¿ã¤ã ã§ã©ãã¾ã§ãããã®ãã¯ãè¦æ¤è¨¼ã§ãã§ãã pic.twitter.com/jSteEgNiH5
— ãããã@VRChat (@jscmla1118) 2018å¹´10æ8æ¥
ä¸æ¹ã§ãVRChatå´ã§ãã¢ãã¬ã¹ããè¨å®ãã¦ããã°å¤æ°ã®OSCã¡ãã»ã¼ã¸ãç¬æã«åä¿¡ã§ããã®ã§ãè¤éãªã¢ã¯ã·ã§ã³ããããã¾å®è¡ã§ãã¾ããæ±ã次第ã§ã¯ãä¸è¨ã®ããã«é£ç¶çã§ç´°ããªæä½ãã§ããããã«ãªãã®ã§ããã²ãããã試ãã¦ã¿ã¦ãã ããã
ç¾å®ãããªã¢ã«ã¿ã¤ã ã§èªç±ã«æä½ã§ãããVRChatåãã®ç §æãå®è£ ãã¾ããï¼MIDIã³ã³ããã¼ã©çµç±ã§ãè²åããæãããå¾ããå¤æ´ã§ãã¾ããã¾ã ã¾ã 試ä½æ®µéã ãã©ãVRChatä¸ã§ã®åç»ä½æããèå°æ¼åºãªããã«å¿ç¨åºæ¥ãããª...ï¼ pic.twitter.com/DCTfujAYcw
— ãããã@VRChat (@jscmla1118) 2018å¹´10æ13æ¥