# 2024 Oculus Quest: Standalone XR 開發教學 ## VR 種類 **PC VR** vs **Standalone VR** ![image](https://hackmd.io/_uploads/r1k_pG3ap.png) ![image](https://hackmd.io/_uploads/ryG1TG3aa.png) ![image](https://hackmd.io/_uploads/Sk24EK0pT.png) * PC VR: * HMD 需接線至電腦, ex: HTC VIVE, Oculus Rift, Valve Index. * 平台: Windows(SteamVR) * 優點: 遊戲畫質/品質優, 可支援高效能渲染 * 缺點: 需接線至電腦, 仰賴 SteamVR(OpenXR), 只支援HMD部分功能(ex: 不一定支援手勢, XR功能) * **Standalone VR/XR**: * 一體機, ex: HTC Flow/Cosmos, Oculus Pro/Quest2/3, Pico. * 平台: Android * 優點: 遊戲畫質/品質差, 便利, 不需要另外接線, 支援HMD完整功能 * 缺點: 無法支援高階渲染 --- ## 1. 註冊META開發者帳號 https://developer.oculus.com/ ### A. 建立開發者帳號 ![image](https://hackmd.io/_uploads/rkI_-SuTT.png) 點選 -> 個人頭像/My Preferences ![image](https://hackmd.io/_uploads/Hy7Dxru66.png) 點選 -> Set Up Two-Factor .../Set Up ![image](https://hackmd.io/_uploads/Hk-q3l36a.png) 點選 -> 新增一組 Facebook ![image](https://hackmd.io/_uploads/BJZvqBOTp.png) 完成圖 :::info *若無法驗證開發者帳號,請參考: https://www.cnblogs.com/deciduousmap/p/16946110.html* ::: ---- ## 2. Meta Oculus 設定為開發者 ### A. 下載 Meta Oculus app | IOS | Android | | -------- | -------- | | ![image](https://hackmd.io/_uploads/Hk0O5FAp6.png =25%x) | ![image](https://hackmd.io/_uploads/BJV4qY0aa.png =25%x) | | [IOS/Meta Oculus](https://apps.apple.com/us/app/meta-quest/id1366478176) | [Android/Meta Oculus](https://play.google.com/store/apps/details?id=com.oculus.twilight&pcampaignid=web_share) | ### B. 配對 Oculus Quest 功能表/裝置/連線到新裝置/Meta Quest2/... ![IMG_5559](https://hackmd.io/_uploads/rJnlkL_Ta.png =25%x) ![IMG_5560](https://hackmd.io/_uploads/HyogkUOaa.png =25%x) ![IMG_5561](https://hackmd.io/_uploads/BknlyLd66.png =25%x) ### C. 開啟偵錯模式 開啟 Meta Oculus/點 Meta Oculus2/頭戴式顯示器/Meta Quest2/開發人員模式/偵錯模式 ![IMG_5554](https://hackmd.io/_uploads/BJkU2H_Ta.png =25%x) ![IMG_5556](https://hackmd.io/_uploads/Bym7jr_T6.png =25%x) ![IMG_5555](https://hackmd.io/_uploads/rJv7iSO6p.png =25%x) ![IMG_5557](https://hackmd.io/_uploads/rkRzjHuaa.png =25%x) ![IMG_5558](https://hackmd.io/_uploads/HypGjSdaT.png =25%x) :::info *Step by Step Tutorial https://www.youtube.com/watch?v=iA9cIlH8sps* ::: ### D. 安裝 Oculus Link (Windows 使用) Windows 平台 (mac 未支援) Oculus Link: https://www.oculus.com/download_app/?id=1582076955407037 Devices/新增頭戴式裝置 ![image](https://hackmd.io/_uploads/HJci7rpT6.png) 設定頁(參考) ![image](https://hackmd.io/_uploads/Hk9eoamyC.png) ![image](https://hackmd.io/_uploads/SJTC7SapT.png) Unity Editor/Play ![image](https://hackmd.io/_uploads/rktDHSTpa.png) --- ### E. APP Debug Build成APP後, 想要Debug, 可參考一下方法: ![image](https://hackmd.io/_uploads/HkmMgc-7A.png) ![image](https://hackmd.io/_uploads/ry9wlqbQA.png) --- ## 3. 安裝 apk ### 方法1: Unity/Build Settings/Build And Run Run Device 設定為 Oculus Quest2/按下 **Build And Run** ![image](https://hackmd.io/_uploads/HJUCPSp6p.png) ### 方法2: ADB (Android Debug Bridge) 安裝 apk #### A. ADB 安裝 mac 版本: https://esisterebbb.blogspot.com/2019/04/mac-macandroid-adb-how-to-install-adb.html Windows 版本: https://dl.google.com/android/repository/platform-tools-latest-windows.zip #### B. apk 安裝指令 ##### Mac 開啟 adb `Ctrl + space`,輸入 terminal ![image](https://hackmd.io/_uploads/HyAWPhfCT.png =50%x) ##### Windows 開啟 adb 解壓縮後貼到任意的資料夾, apk 一併複製到這個資料夾 ![image](https://hackmd.io/_uploads/B1xCFl3p6.png) 路徑欄輸入 cmd, 並按下 Emter ![image](https://hackmd.io/_uploads/H1Pe9xh6p.png) 結果: 即可輸入指令 ![image](https://hackmd.io/_uploads/SJlG9xnTa.png) ##### 安裝指令 列出目前所有的設備 ``` adb devics ``` 安裝 apk ``` adb install 123.apk ``` ![image](https://hackmd.io/_uploads/B1jMDc56T.png =100%x) --- ## 4. Unity 環境設置 Unity 版本: 2023.3.21f1 自行建立專案, 須注意以下幾點: * 安裝套件: Oculus Integration (Asset Store) * 安裝套件: Oculux XR (Package Manager) * Android 開發環境設置 * XR 環境設置 * Build Settings * Runtime Debug Mode (Windows 限定) **懶人包** * 專案下載路徑: https://github.com/shinn716/OVR_XR_Sample * git repo: ``` https://github.com/shinn716/OVR_XR_Sample.git ``` ## 5. XR App 開發 ### A. Oculus Interaction Examples [![Snipaste_2024-04-12_16-17-27](https://hackmd.io/_uploads/H1JYRvUl0.png)](https://scontent.oculuscdn.com/v/t64.5771-25/10000000_265719752527806_3675186975230176175_n.mp4?_nc_cat=102&ccb=1-7&_nc_sid=4081c1&_nc_ohc=0TJvVFwKiGcQ7kNvgH2djkY&_nc_ht=scontent.oculuscdn.com&oh=00_AYBHEy_qwK4cucew3Np33Ta_bfUleL32gDn-fycPF95WbA&oe=66560177) https://assetstore.unity.com/packages/tools/integration/oculus-integration-deprecated-82022 File/Build Settings ![image](https://hackmd.io/_uploads/ByDYzWNJA.png) #### 推薦範例1: MetaInteractionSDKSamples {%youtube Ril-5dWBOSU %} https://github.com/dilmerv/MetaInteractionSDKSamples #### 推薦範例2: Unity Starter Samples ![image](https://hackmd.io/_uploads/S1940j67R.png) https://github.com/oculus-samples/Unity-StarterSamples ### B. 抓取功能實作 Hand Grab Interaction ![image](https://hackmd.io/_uploads/HJ567z9l0.png) Grab 觸發事件 ![image](https://hackmd.io/_uploads/Sy4b4zceR.png) 自訂義腳本 ![image](https://hackmd.io/_uploads/BJ3zEf9gR.png) ### C. Pick And Place 功能實作 ![image](https://hackmd.io/_uploads/HJ9oyd2XC.png) ![image](https://hackmd.io/_uploads/Hka_yu3m0.png) ![image](https://hackmd.io/_uploads/S1CPkO2XC.png) https://drive.google.com/file/d/1m5LbvXM96AHUArgcBYvqOvVWQ2gz6Cxg/view?usp=drive_link ### D. 投球物理/籃球機 接續 B. #### 1. 被丟物件上, 需新增的元件 * Physics Grabbable ![image](https://hackmd.io/_uploads/BJfP2CS-R.png =50%x) * RigidBody ![image](https://hackmd.io/_uploads/SkwK30SZC.png =50%x) * Grabbable * Hand Grab Interactable ![image](https://hackmd.io/_uploads/S17WaRS-R.png =50%x) #### 2. 新增 velocity components * HandVelocityCalculator 放置 LeftHands ![image](https://hackmd.io/_uploads/rJX3p0HWR.png =50%x) * LeftHand/HandInteractorsLeft/HandGrabInteractor 將 HandVelocityCalculator 物件拖入 HandGrabInteractor/Velocity Calculator ![image](https://hackmd.io/_uploads/rkToCAr-R.png =50%x) * RightHands 設定如上步驟 :::info *投擲物件, 官方參考資料: https://developer.oculus.com/documentation/unity/unity-isdk-throw-object/* ::: ### E. 開啟 PassThrough Model #### 1. 移除 Lighting/Lighting Setting 和 Environment (如下圖) ![image](https://hackmd.io/_uploads/H1LlxdUlR.png =50%x)![image](https://hackmd.io/_uploads/BySbgdLgR.png =50%x) #### 2. Hierarchy/OVRCameraRig/OVR Manager Tracking Origin Type 設定為 Stage Enable passthrough 勾選 ![image](https://hackmd.io/_uploads/HJ_eZd8gC.png =50%x) #### 3. OVRCameraRig 元件新增 OVR Passthrough Layer Projection Surface 設定為 Reconstructed Placement 設定為 Underlay Composition Depth 設定為 1 ![image](https://hackmd.io/_uploads/SkBqWOLe0.png =50%x) #### 4. OVRCameraRig/TrackingSpace/CenterEyeAnchor Background 設定為黑色透明 ![image](https://hackmd.io/_uploads/HJk9fuLxC.png) #### 5. 確認 Project Setting/Oculus/Checllist 全部為綠色 (若不是請按下 Fix all) ![image](https://hackmd.io/_uploads/HyvJmuIeC.png) #### 6. Build APK (參考 B.) #### 7. 選擇右上角**不明來源** ![com.oculus.shellenv-20240412-164053](https://hackmd.io/_uploads/rkUrj53eA.jpg) #### 8. 選擇 OVR_Sample ### E. MixReality #### Oculus Quest3 Overview {%youtube Exu7r2vZpcw %} #### Setup {%youtube c1aSifzwhfo %} https://www.youtube.com/watch?v=c1aSifzwhfo&t=27s https://github.com/dilmerv/MetaAdvancedFeatures #### Room Scanning Quest3 環境設置(現階段桌、椅、台燈,必須手動建立) {%youtube xu2wgPzZNN8 %} 未來趨勢搭配LLM、Room Scanning ![image](https://hackmd.io/_uploads/SyD8J8RMR.png) https://www.androidauthority.com/meta-ai-room-scanning-3427933/ #### OVR_Sample/SceneAPI ![image](https://hackmd.io/_uploads/ByK3Rip7C.png) 開啟 Scene_API ![image](https://hackmd.io/_uploads/ry9il26Q0.png) 掃描環境, 並建立 mesh (包含碰撞) ![image](https://hackmd.io/_uploads/BJrbenaXA.png) https://drive.google.com/file/d/1xjhQ7Fycb2Rvqwv6o5dShYMuLcau6Qs8/view?usp=drive_link 抓取 Scene, 在地板建立 Cube #### 推薦XR範例: MetaXRTableTopGames {%youtube QHMtVEX9O0Y %} https://github.com/dilmerv/MetaXRTableTopGames --- ## 6. 其他 ### 設備相容性 ![image](https://hackmd.io/_uploads/B1U7a67kA.png) https://github.com/oculus-samples/Unity-Phanto ### XR 功能總覽 ![image](https://hackmd.io/_uploads/rJZnr1I-0.png) https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@6.0/manual/index.html --- ## 參考 * Meta Develop mode https://youtu.be/wJzHjk1QT3E?si=SMZ1sgmduGT_YLVy * Hand tracking https://www.youtube.com/watch?v=WELSs-lPJYA * Oculus Integration And Interaction https://www.youtube.com/watch?v=xuGGfl1vJ28 * Meta XR All-in-One SDK https://assetstore.unity.com/packages/tools/integration/meta-xr-all-in-one-sdk-269657 * Passthrough WithHands & SpatialAnchors https://github.com/dilmerv/OculusPassthroughWithHands * OCULUS QUEST 搭配UNITY環境設定QUEST LINK與apk https://home.gamer.com.tw/artwork.php?sn=5806842 * Throwing Objects in VR using Unity https://developer.oculus.com/documentation/unity/unity-isdk-throw-object/ * Meta repo/Unity-Phanto https://github.com/oculus-samples/Unity-Phanto * How To Grab And Throw Objects In VR - Interaction SDK#4 https://www.youtube.com/watch?app=desktop&v=Ril-5dWBOSU * Passthrough | Unity VR Tutorial for Oculus Quest https://www.youtube.com/watch?v=RtoTGYBdGI4