http://forum.exceedu.com/forum/forum.php?mod=viewthread&tid=34175php
Oculus Unity Development Guide開發指南
轉載請保留原始地 http://t.cn/RAblKoh
Oculus/GearVR開發者羣 302294234
Welcometo the Unity Development Guide
Introduction簡介
Welcometo the Oculus Unity Developer Guide.
歡迎來到OculusUnity開發者指南。
Thisdocument describes developing Unity 3D games and applications for VR deviceswith the Oculus PC and mobile SDKs. A Unity integration package, sample Unityapplications, and mobile SDK Unity examples are available for PC and mobiledevelopment to help you create virtual reality applications in Unity.
本文檔描述瞭如何在使用Oculus PC及移動端SDK爲VR設備開發U3d遊戲及應用。咱們提供了Unity整合包、Unity應用實例,以及移動SDK Unity實例來爲PC及移動端開發工做提供幫助,幫助你在Unity中創造VR應用。
Thisguide covers:
•Getting started
•Downloading and installing the Oculus Unity integration
•Contents of the integration package
• Howto use the provided samples, assets, and sample applications
•Configuring Unity VR projects for build to various targets
本指南包括的內容有:
• 如何開始
• 下載並安裝OculusUnity整合包
• 整合包中的內容
• 如何使用當中的實例、組件以及實例應用
• 怎樣對應多平臺的生成方式
ThisUnity Integration is available for use with the PC development environment forthe Oculus Rift. It is also bundled with the mobile SDK for Samsung Gear VR.Both Unity integrations are capable of building targets for PC or Android.However, keep in mind that the requirements and optimizations for PC and mobileVR applications differ substantially. If you would like to generate builds forboth PC and mobile from a single project, it is important to follow the morestringent mobile development best practices.
本次的Unity整合包能夠用來在PC上針對OculusRift的開發環境下使用,同時也能夠隨着三星Gear VR的移動SDK一塊兒使用。另外整合包能夠同時應對PC和安卓的兩種生成方式。不過須要注意的是,PC與移動VR應用在需求以及優化上是存在本質區別的。若是你想讓一個單獨的項目同時生成在PC端和安卓端上,那麼必須注意遵循更加嚴格的移動開發最佳實踐(best practices)。
Thisdocument describes the mobile Unity integration release 0.4.3. Most informationcontained in this guide also applies to the PC Unity integration .4.4. Any exceptionsare clearly indicated where they occur (e.g., the Moonlight folder in OVRcontains assets relevant only to mobile development).
本文檔描述了移動Unity整合包,版本0.4.3。本指南中包含的絕大多數信息也能夠同時運用在PC Unity整合包裏.4.4。若有不一樣之處通常都會當場指出(好比說OVR裏的Moonlight文件夾裏包含的組件只和移動開發有關)
Requirements需求
Systemand Hardware Requirements系統和硬件需求
Pleasereview the relevant documentation to be sure that you are using supportedhardware and that your development environment and devices are configured andset up properly:
• PCSDK: OculusDeveloper Guide
•Mobile SDK: Deviceand Environment Setup Guide
Beforebeginning Unity development, you should be able to run the available SDK Unitydemo applications.
請參閱相關文檔以確保你使用的是受支持的硬件設備,同時確保你的開發環境及硬件都已經通過了正確的調試和安裝:
• PC端SDK: OculusDeveloper Guide
• 移動端SDK: Deviceand Environment Setup Guide
在開始Unity開發工做以前,你應該能夠先運行一下手頭已經擁有了的SDK Unity Demo應用。
UnityRequirements Unity需求
TheOculus Unity Integration is compatible with Unity Pro 4.6.1 , which includessupport for Lollipop (Android 5.0).
整合包能夠由Unity Pro 4.6.1進行編譯,由於其也包含了對Lollipop棒棒糖(安卓5.0)的支持。
Note:For mobilebuilds, we strongly recommend using Unity 4.6.2p2 or higher, which includeimportant fixes for a memory leak and a null reference bug.
注意:對於移動端的生成,咱們強烈建議使用Unity 4.6.2.p2或者更高的版本,由於會對內存溢出或者空引用BUG的狀況做出重要修正。
Unity Free support is available with Unity 4.6 or higher. Afeature set comparison between Unity Pro and Unity Free may be found here: http://unity3d.com/unity/licenses
對Unity4.6或更高版本提供了Unity免費版的支持。Pro版和免費版的功能有哪些區別能夠參考文檔http://unity3d.com/unity/licenses
Note: Thereare noteworthy feature support differences between Unity licenses. Pleasereview the limitations cited below as well as the license comparison on Unity’swebsite before committing considerable resources to one path. Your licensechoice will depend largely on the performance characteristics and distributionneeds of your app.
注意:對於Unity許可證書之間對功能支持的區別,其中有某些地方值得一看。請在安排工做以前參閱下列Unity網址中的限制條件以及許可證書中的區別。對許可證類型的選擇在很大程度上依賴於你的應用的表現形式和分佈需求。
Gamepad Controller
You may wish to have a compatible gamepad controller for use withthe supplied demo applications, such as the Xbox 360 controller for Windows, anHID-compliant game controller for Mac, or a Samsung EI-GP20 or other compatiblecontroller for Gear VR.
Oculus Unity
遊戲控制器
你也許會須要有一個可供編譯的遊戲手柄在受支持的Demo應用當中,好比對應windows的Xbox 360手柄,對應Mac的HID-compliant遊戲手柄或者一部三星 EI-GP20或其餘對應Gear VR的其餘可編譯控制器。
Oculus/GearVR開發者羣 302294234
Installation安裝
All Oculus Unity development materials are available for downloadat our Developer site (requires login): https://developer.oculus.com/downloads/
全部的OculusUnity開發所需材料均可以在咱們的開發者平臺上下載到(須要登陸)https://developer.oculus.com/downloads/
The Oculus Unity Integration is the heart of the supplieddevelopment resources - it installs the minimum set of required files necessaryfor VR integration into Unity. We have also included various assets, scripts,and sample applications to assist with development.
Oculus Unity整合包是整個開發資源中的核心——它會在最低限度上爲你安裝全部必要的用以開發VR的文件。咱們一樣在裏面放入了多種組件、腳本以及應用實例來輔助開發過程。
The Mobile SDK also includes Unity example source code illustratingthe construction and use of common resources such as simple rooms, menus, andmore. They may be found in the folder SDKExamples. See Oculus Mobile SDKExamples formore information.
移動SDK一樣包含了Unity實例資源代碼來講明各類結構以及大部分資源的使用方法好比simpleRooms、Menus等等。它們能夠在文件夾SDKExamples裏找到。參閱Oculus MobileSDKExamples 以得到更多信息。
The PC Unity Integration bundle includes PC Unity整合包捆綁內容有:
• OculusUnityIntegration(Oculus Unity 整合包)
The mobile SDK includes the following移動SDK包含有:
• OculusUnityIntegration(Oculus Unity 整合包)
• BlockSplosion sample application (source and pre-built apk) 應用實例 (資源以及預生成apk)
• Shadowgun sample application (pre-built-apk) 應用實例 (預生成apk)
• SDKExamples (source) (資源)
Preparing for Development: PC SDK準備工做:PC SDK
When developing for PC, we recommend beginning with the Oculus Developer Guide and theOculus Best Practices Guide, whichincludes information and guidelines for developing great VR experiences, andshould be considered a go-to reference when designing your Oculus-ready games.
當在PC上作開發時,咱們推薦先從OculusDeveloper Guide 和Oculus Best Practices Guide兩部文檔開始,由於它們包含了如何開發牛逼VR體驗項目的信息和指導,並且當你準備好要設計一個Oculus做品時也能夠將它們做爲一個直觀的參考。
Direct Mode Display Driver直觀顯示模式驅動
On Windows, Oculus recommends users install the Oculus DisplayDriver, which includes a feature known as Direct Display Mode. In direct mode,the driver makes your Rift behave as an appliance instead of a standard Windowsdisplay. Applications target the Rift by loading the driver and pointingrendering to it before initialization. This is the default behavior. Forcompatibility, the Rift can also still be used as a Windows monitor.
在windows上,Oculus推薦用戶安裝上Oculus Display Driver,其中有個功能叫作Direct Display Mode(直觀顯示模式)。在直接模式裏,驅動程序會將你的Rift設置爲取代Windows標準屏幕的顯示器。應用程序在讀取驅動以後會直接標記Rift並在初始化以前先行把渲染工做作好。這是一種默認的行爲模式。爲了考慮兼容性,Rfit也能做爲windows的顯示屏來使用。
This is known as Extended Display Mode. When extended mode isactive, rendering works as usual, with no Oculus intervention. You can choosethe mode from the Oculus Configuration Utility's Rift Display Mode screen.
這被稱爲擴展顯示模式。當擴展模式是激活的,渲染就照常工做不用人爲干預。你能夠選擇應用程序的屏幕顯示模式。
The direct mode driver is not yet available for platforms otherthan Windows.
目前windows以外的平臺還不提供直觀模式的驅動程序。
Monitor Setup顯示器設置
To get the best experience, you and your users should alwaysconfigure the Rift correctly.
爲了能獲得最好的體驗,最好老是將Rift調試到最佳狀態。
In Windows 7 and Windows 8, you can change Windows' displaysettings by right-clicking on the desktop and selecting Screen resolution.
在win7和win8裏,你能夠直接更改windows的顯示設置,右鍵點桌面選個性化便可。
• It is possible to clone the same image on all of your displays.To ensure each display uses the correct
frequency, Oculus recommends extending the desktop instead ofcloning it.
• 能夠把圖像克隆到不一樣的屏幕上。但爲了確保每一個屏幕都使用了正確的頻率,Oculus推薦最好仍是擴展桌面而不是簡單複製。
• If you are using the Rift in extended mode, it should be set toits native resolution. This is 1920x1080 for DK2 and 1280x800 for DK1.
• 若是你是在擴展模式下使用Rift,那麼最好將它設置爲原生分辨率。對於DK2來講是1920x1080,對DK1來講就是1280x800。
On Mac systems open System Preferences, and then navigateto Displays.
在Mac系統裏打開系統設置,定位到顯示菜單。
• As with Windows, it is possible to mirror the same image on allof your displays. Oculus recommends against mirroring. Click Arrangement andensure Mirror Displays is not enabled.
• 在windows裏能夠直接把圖像鏡像到全部屏幕上。但Oculus推薦仍是不要鏡像。點擊Arrangement並確保Mirror Displays沒有啓用。
• Some Unity applications will only run on the main display. Inthe Arrangement screen, drag the white bar onto the Rift's blue box tomake it the main display.
• 有些Unity應用只會在主要屏幕上顯示。在Arrangement界面,拖動白條把Rift的藍色盒子設置爲主屏幕。
• Always use the Rift's native resolution and frequency. Click GatherWindows. For DK2, the resolution
should be Scaled to 1080p, the rotation should be 90° andthe refresh rate should be 75 Hertz. For DK1, the resolution should be1280x800, the rotation should be Standard, and the refresh rate should be 60Hertz.
• 常態保持Rift爲原生分辨率和頻率。點擊GatherWindows。對DK2來講,分辨率應該調Scaled到1080p,旋轉角(rotation)應該是90°而刷新率應該是75Hz。對DK1來講,分辨率應該是1280x800,旋轉角設置爲標準,刷新率應該是60Hz。
Recommended Configuration推薦配置
We recommend the following settings in your project:
咱們推薦項目工程採用以下配置:
• On Windows, enable Direct3D 11. D3D 11 and OpenGL expose themost advanced VR rendering capabilities. In some cases, using D3D 9 may resultin slightly reduced visual quality or performance.
• 在windows上,啓用Direct3D 11。D3D 11和Open GL能最大限度展示VR的渲染能力。在某些狀況下,用D3D 9可能會致使畫質或表現的輕微降低。
• Use the Linear Color Space. Linear lighting is not only morecorrect for shading, it also causes Unity to perform sRGB read/write to the eyetextures. This helps reduce aliasing during VR distortion rendering, where theeye textures are interpolated with slightly greater dynamic range.
• 使用線性的顏色空間(linear color space)。線性光並不只僅正確做用於着色(shading),它還可讓Unity在肉眼材質上展示sRGB的讀/寫。這一點能夠幫助VR在渲染失真時下降混淆程度,尤爲是在肉眼材質被輕微的大動態範圍(slightly greater dynamic range)改動時。
• Never clone displays. When the Rift is cloned with anotherdisplay, the application may not vsync properly.
This leads to visible tearing or judder (stuttering or vibratingmotion).
• 不要複製屏幕。當Rift被克隆到另外一塊屏幕時,應用程序可能沒辦法完美同步。
頗有可能致使視界撕裂或者抖動(斷斷續續或者運動震動)。
• On Windows, always run DirectToRift.exe. Even in extended mode,DirectToRift.exe makes your application run full-screen on the Rift.
• 在windows上保持運行DirectToRift.exe。哪怕在擴展模式中,DirectToRift.exe也能讓你的應用程序在Rift上保持全屏。
• When using the Unity editor, use extended display mode. Directmode is currently supported only for
standalone players. Using it with the Unity editor will result ina black screen on the Rift.
• 在使用Unity編輯器時,使用擴展屏幕模式。直觀模式目前僅支持單一玩家。用Unity編輯器打開它有可能會致使Rift上的黑屏。
Oculus/GearVR開發者羣 302294234
Preparing for Development: Mobile SDK
準備開發:移動SDK
When developing for mobile, please be sure to fully review all ofthe relevant performance and design
documentation, especially the MobileUnity Best Practices guide. Mobile apps are subject tomore stringent limitations and requirements and computational limitations whichshould be taken into consideration from the ground up.
當針對移動端進行開發時,請先保證徹底瀏覽過全部相關的表現和設計文檔,特別是Mobile Unity Best Practices guide.移動應用意味着要一直考慮更嚴格的限制和需求以及從頭至尾都要一直考慮的計算限制。
We hope that the process of getting your Oculus device integratedinto your Unity environment is a fun and easy experience.
咱們但願把你的Oculus硬件整合進Unity環境裏的過程能變得有趣和輕鬆。
Getting Started開始
This section describes steps taken to begin working in Unity.
這個版塊描述瞭如何開始用Unity展開工做。
Importing the Unity Integration
導入Unity整合包
If you are already working in a Unity project, save your workbefore beginning.
若是你已經作好準備要進行Unity的項目開發了,記得在開始以前先存個檔。
First, create a new project that you can import the Oculus assetsinto. From the Unity menu, select File > New Project. Clickthe Browse button and select the folder where the Unity project will belocated.
Make sure that the Setup defaults for: field is set to 3D.
首先,建立一個新的項目來導入Oculus組件。在Unity菜單裏,選擇文件—新項目。點擊Browse按鈕選擇放置Unity項目的文件夾位置。確保Setup defaults for:區域選擇的是3D。
You do not need to import any standard or pro Unity assetpackages, as the Oculus Unity integration is fully selfcontained.
不須要再導入任何標註或Pro Unity組件包,由於Oculus Unity整合包已經徹底包含進去了。
Click the Create button. Unity will reopen with the newproject loaded.
點擊Create按鈕,Unity會重啓並讀取新的項目。
To import the Integration into Unity, select Assets > CustomPackage... and select the Unity Integration .unitypackage to import theassets into your new project. Alternately, you can locate the .unitypackagefile and double-click to launch, which will have the same effect.
要想把整合包導入Unity,選擇Asset—Custom Package…並選擇Unity Intergration.unitypackage來把組件都導入到你的新項目裏。固然你也能夠直接雙擊那個文件,效果是同樣的。
When the Importing package dialog box opens, leave all ofthe boxes checked and select Import. The import process may take a fewminutes to complete.
當Importingpackage日誌框彈出時,全選全部內容並點擊導入。整個過程可能會持續幾分鐘時間來完成。
Mobile SDK: the mobile Unity Integration includes a ProjectSettings folder which provides default settings for a VR mobile application.You may manually copy these files to your [Project]/Assets/ProjectSettingsfolder.
移動SDK:移動Unity整合包包含了一個Project Settings文件夾,能夠爲VR移動應用提供默認設置。你也能夠自行將這些文件複製到你的[項目]/Assets/ProjectSettings文件夾下。
Importing Sample Applications
導入實例
In this section we'll describe how to import sample Unityapplication source into Unity, using BlockSplosion as an example.
在這個環節咱們會描述一下如何把一個簡單的Unity應用資源導入到Unity中,就拿BlockSplosion做爲例子吧。
Note: Sampleapplication import is relevant to mobile only. The Room sample applicationprovided for PC development is included as a scene in the UnityIntegrationpackage.
注意:實例應用的導入只與移動端有關。爲PC開發而提供的Room實例已經做爲一個場景被添加到Unity整合包裏了。
If you are already working in a Unity project, save your workbefore beginning.
若是已經準備好在Unity項目上開始工做,先記得存個檔。
To import the Integration into Unity, select Assets > CustomPackage... and select BlockSplosion.unitypackage to import the assets intoyour new project. Alternately, you can locate the BlockSplosion.unitypackagefile and double-click to launch, which will have the same effect.
The import process may take a few minutes to complete.
點Assets/CustomPackage… 選擇BlockSplosion.unitypackage來把全部組件導入新項目裏。固然,直接雙擊文件也行。
過程會持續幾分鐘時間。
Adding VR to an Existing Unity Project
將VR添加到已有的項目中
The Unity Integration package may be used to integrate Oculus VRinto an existing project. This may be useful as a way of getting oriented to VRdevelopment, but dropping a VR camera into a Unity game that wasn't designedwith VR best practices in mind is unlikely to produce a great experience.
Unity整合包能夠用來將Oculus VR整合進一個已有的項目裏。在面向VR開發的道路上這個方法會很是有用,可是把一個VR攝像頭隨便扔進一個並非爲VR設計的Unity遊戲中,若是事先並無在腦海裏通過仔細構想(bestpractices)的話,可能沒辦法產生良好的體驗效果。
Note: This isone simple method for adding VR to an existing application, but is by no meansthe only way. For example, you may not always wish to use OVRPlayerController.
注意:這只是一個將VR添加到已有應用程序的簡單方案,毫不是惟一方法。舉例說明,你大概也不想老是用OVRPlayerController。
1. Importpackage
2. InstantiateOVRCameraRig if you already have locomotion figured out or instantiateOVRPlayerController to walk around.
3. Copyany scripts from the non-VR camera to the OVRCameraRig. Any image effectsshould go to both the Left/RightEyeAnchor GameObjects that are children of theOVRCameraRig.
4. Disableyour old non-VR camera.
5. Buildyour project and run normally.
1. 導入包
2. 實例化一個OVRCameraRig,若是你已經搞懂了移動方面的內容或者經過實例化OVRPlayerController來負責移動。
3. 把全部非VR攝像頭的腳本都複製到OVRCameraRig裏。全部的圖像效果都應該直接放到OVRCameraRig下的Left/RightEyeAnchorGameObjects裏。
4. 把你以前的非VR攝像頭統統Disable掉。
5. 像日常那樣生成你的項目並運行。
A Detailed Look at the Unity Integration
從細節看Unity整合包
This section examines the Unity integration, including thedirectory structure of the integration, the Unity prefabs are described, andseveral key C# scripts.
這個環節開始着重分析Unity整合包,包括整合包的目錄結構,Unity預製體的描述以及幾個關鍵的C#腳本。
Note: Thereare minor differences between the contents of the Unity Integration providedfor PC development and the version bundled with the mobile SDK.
注意:分別針對PC開發和捆綁在移動SDK上的Unity 整合包在內容上幾乎沒什麼區別。
Contents
內容
OVR
The contents of the OVR folder inOculusUnityIntegration.unitypackage are uniquely named and should be safe toimport into an existing project.
在OculusUnityIntegration.unitypackage中的OVR文件夾裏的內容都是獨特命名的,並且應該能夠安全導入已有的項目裏。
The OVR directory contains the following subdirectories:
OVR路徑下包含着以下的分支路徑:
<ignore_js_op>
Editor編輯器 包含能夠爲Unity編輯器添加功能的腳本,還有強化過的C#組件腳本。
Materials材料 包含了整合包中圖形組件會用到的材料,好比主要GUI屏幕。
Moonlight 包含了針對移動Gear VR開發而準備的類(僅針對移動端)。
Prefabs預製體 包含了爲了將VR嵌入Unity場景而提供框架的主要預製體:OVRCameraController和OVRPlayerController。
Resources資源 包含了部分須要被OVR腳本實例化的預製體和其餘對象,好比主GUI。
Scene 場景包含了簡單的場景。
Scripts腳本 包含了將VR框架和Unity組件結合起來的C#文件。許多腳本都要結合多種預製體一塊兒使用。
Shaders着色器 包含了多種Cg着色器,某些OVR組件會用得上。
Textures紋理 包含了圖像部件,某些腳本組件會用得上。
Note: Westrongly recommend that developers not directly modify the included OVR scripts.
注意:咱們強烈建議開發者們不要直接修改內置的OVR腳本。
Plugins插件
The Plugins folder contains the OculusPlugin.dll, which enablesthe VR framework to communicate with Unity on Windows (both 32 and 64-bitversions).
插件文件夾包含了OculusPlugin.dll,可以使VR框架得以和windows版Unity(32位和64位)交流數據。
This folder also contains the plugins for other platforms:OculusPlugin.bundle for MacOS; and Android/ libOculusPlugin.so, vrlib.jar, andAndroidManifest.xml for Android.
這個文件夾一樣包含了針對其餘平臺的插件:OculusPlugin.bundle對應MacOS;Android/libOculusPlugin.so。vrlib.jar,還有對應安卓的AndroidManifest.xml
Prefabs
預製體
The current integration for adding VR support into Unityapplications is based on two prefabs that may be added into a scene:
當前的整合包裏向Unity應用添加VR支持的功能都來源於於兩個應該添加進場景的預製體。
• OVRCameraRig
• OVRPlayerController
To use, simply drag and drop one of the prefabs into your scene.
要使用它們,拖過來扔到你場景裏的預製體裏就行。
Note: You canalso add these prefabs into the scene from the Oculus - Prefabs menu.
注意:你也能夠經過Oculus-Prefabs菜單把這些預製體加入場景。
OVRCameraRig
OVRCameraRig replaces the regular Unity Camera within a scene. Youcan drag an OVRCameraRig into your scene and you will be able to start viewingthe scene with the Gear VR and Rift.
OVRCameraRig在場景中用來替換掉常規的Unity Camera。你只要把這東西拖進場景就能夠直接開始在Gear VR或者Rift裏看到畫面了。
Note: Makesure to turn off any other Camera in the scene to ensure that OVRCameraRig isthe only
one being used.
注意:確保關掉場景中的其餘攝像頭,確保OVRCameraRig是惟一一個啓用的。
Figure 15: Prefabs: OVRCameraRig,expanded in the inspector
<ignore_js_op>
OVRCameraRig contains two Unity cameras, one for each eye. It ismeant to be attached to a moving object (such as a character walking around, acar, a gun turret, etc.) This replaces the conventional Camera.
OVRCameraRig包含了兩個Unity攝像頭,倆眼一眼一個。原本目的是用來針對移動目標(好比一個處處走的角色,一輛車,一個炮塔等等),它替換掉的是傳統的攝像頭
The following scripts (components) are attached to theOVRCameraRig prefab:
下列腳本(組件)都附加在OVRCameraRig預製體上:
• OVRCameraRig.cs
• OVRManager.cs
OVRPlayerController
The OVRPlayerController is the easiest way to start navigating avirtual environment. It is basically an OVRCameraRig prefab attached to asimple character controller. It includes a physics capsule, a movement system,a simple menu system with stereo rendering of text fields, and a cross-haircomponent.
能夠說是最簡單的一種用來定位虛擬環境的方式了。它簡單來講就是把一個OVRCameraRig預製體跟一個簡單的character controller給綁在了一塊兒。它包含了一個物理capsule,一個移動系統,一個簡單的有立體感文字區域渲染的菜單系統,還有一個cross-hair組件。
To use, drag the player controller into an environment and beginmoving around using a gamepad, or a keyboard and mouse Note: Make sure thatcollision detection is active in the environment.
要使用的話,把player controller拖到環境裏面而且用遊戲控制器來移動他,或者鍵盤和鼠標。
注意:確認一下環境裏面的碰撞檢測是否是激活狀態。
Two scripts (components) are attached to the OVRPlayerControllerprefab:
下列兩個腳本(組件)被綁定在OVRPlayerController預製體上:
• OVRPlayerController.cs
• OVRGamepadController.cs
Figure 16: Prefabs: OVRPlayerController,expanded in the inspector
<ignore_js_op>
Unity Components
Unity組件
The following section gives a general overview of what each of thescripts within the Scripts folder does.
下面這個環節會告訴咱們在腳本文件夾裏的每一個腳本大體上是作什麼的。
OVRCameraRig
OVRCameraRig is a component that controls stereo rendering andhead tracking. It maintains three child "anchor" Transforms at theposes of the left and right eyes, as well as a virtual "center" eyethat is half-way between them.
OVRCameraRig是一個控制立體感渲染和頭部運動追蹤的組件。它有三個子「錨點」分別提供左右眼位置的座標,以及一個虛擬出來的在兩眼「中間」的眼睛。
This component is the main interface between Unity and thecameras. This is attached to a prefab that makes it easy to add VR support to ascene.
Important: All camera control should be done through thiscomponent. You should understand this script when implementing your own cameracontrol mechanism.
這個組件是Unity和這個攝像頭之間主要的接口。這些都綁定在一個預製體上以便能更容易地把VR支持添加到場景裏。
OVRManager
OVRManager is the main interface to the VR hardware. It includeswrapper functions for all exported C++ functions, as well as helper functionsthat use the stored Oculus variables to help configure camera behavior.
OVRManager是面向VR硬件的主要接口。它負責封裝全部導出的C++功能,以及一個輔助功能,能夠用儲存的Oculus變量幫助調節攝像頭的行動。
This component is added to the OVRCameraRig prefab. It can be partof any application object. However, it should only be declared once, becausethere are public members that allow for changing certain values in the Unityinspector.
這個組件添加在OVRCameraRig預製體裏。它能夠成爲任何應用程序對象的一部分。不過它只能被declare一次,由於在Unity的inspector裏存在容許改變某些值的public成員。
OVRManager.cs contains the following public members:
OVRmanage.cs包含以下public成員:
Table 4: Mobile and PC Public Members移動和PC端的public成員
<ignore_js_op>
Monoscopic單屏 若是設置爲true,那麼渲染工做就會試圖把本來對應倆眼的渲染方式優化成單視角。不能對應全部平臺。
EyeTexture Format肉眼紋理格式 設置肉眼渲染紋理的格式。通常狀況下你應該使用Default或者DefaultHDR來對應高動態範圍渲染。
EyeTexture Depth肉眼紋理深度 設置肉眼渲染紋理的深度精度。有可能會用付出性能代價的方式來修復z-fighting效果。
EyeTexture Antialiasing肉眼紋理抗鋸齒 爲肉眼渲染紋理設置抗鋸齒等級。
Table 5: PC-Only Public Members只在PC端獨有的public成員
<ignore_js_op>
NativeTexture Scale原生紋理比例 在camera controller裏的每個攝像頭都會建立一個渲染紋理,有着能得到最清晰的像素密度的理想比例(一個1-to-1的像素尺寸能在屏幕中間展現透鏡失真效果)。這個區域能夠用來把一個攝像頭的渲染對象從尺寸的角度調整到能夠針對多個理想像素保真度的程度,以便讓你可以在性能和質量之間找到平衡點。
VirtualTexture Scale虛擬紋理比例 若有必要,這個區域能夠用來動態調整攝像頭的渲染對象,以使其值低於理想狀態下的像素密度,能夠在運行時幫助下降GPU佔用。
UsePosition Tracking 使用位置追蹤 若是禁用,則由追蹤器偵測到的位置座標會中止更新HMD座標。
UseRotation Tracking 使用旋轉角追蹤 若是禁用,則由追蹤器偵測到的定向會中止更新HMD定向。
Mirrorto Display 鏡像屏幕 若是Oculus直觀顯示驅動已被啓用,並且這個選項也被選中的話,畫面會在除了Rift以外的桌面窗口中出現。禁用這個選項會輕微提升性能。
TimeWarp(desktop only)時間扭曲(僅供桌面)TimeWarp是一個調整通過渲染的圖像在屏幕上顯示位置的技術,當某個時間點用戶能看到它的時候給予最後追蹤姿態的狀況做出調整。啓用這個選項會強制執行垂直同步,而且會使其餘時間上的調整的等待時間下降。
FreezeTime Warp(desktop only) 凍結時間扭曲(僅供桌面)啓用這個選項會在時間扭曲時暫時凍結通過渲染的眼部姿態(renderedeye pose)來講明這個效果。
ResetTracker On Load 讀取時重置追蹤器 這個選項默認爲True。關掉的話,在讀取隨後的場景時將不會重置追蹤器。這樣就能夠在場景切換時保持原有的朝向了,同時會保持磁力計(magnetometer)設置完整。
Helper Classes
輔助類
In addition to the above components, your scripts can alwaysaccess the HMD state via static members of OVRManager. 除了上述組件以外,你的腳本還會常常經過OVRManager裏的靜態成員訪問HMD狀態。
<ignore_js_op> ios
<ignore_js_op> web
<ignore_js_op>
<ignore_js_op>
windows
未完待續..............框架