PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX...

21
PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 1 / 21 Pimax VR SDK_Unity Development Documentation Versionv_1.1.2

Transcript of PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX...

Page 1: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

1 / 21

Pimax VR SDK_Unity

Development Documentation

Version:v_1.1.2

Page 2: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

2 / 21

1. Environment construction ............................................................................... 4

1. Installation of Piplay .................................................................................... 4

2. Connecting the Pimax helmet device........................................................... 4

2. Use of Unity..................................................................................................... 5

1. Downloading Unity development engine...................................................... 5

2. Create a UNITY project ................................................................................ 5

3. Import SDK ....................................................................................................... 7

1. Installation of SDK ........................................................................................ 7

2. Import SDK ................................................................................................... 8

4. Use of SDK......................................................................................................10

5. Packaging of Unity….......................................................................................12

6. Function realization of helmet button...............................................................15

7. Reset the positive direction .............................................................................18

8. Meaning of each Scripting Interface................................................................ 18

1. PVRSESSION.CS ...................................................................................... 182. PVRPOSETRACKING.CS ......................................................................... 193. PVREYEOFFSET.CS ................................................................................. 20 4.

PVRSURFACE.CS ..................................................................................... 205. PVRINPUTEVENT.CS ................................................................................ 20

9. Introduction of demo scenarios...................................................................... 21

1. SIMPLEVRDEMO.................................................................................... 212. MULTICAMERADEMO............................................................................ 213. OBJECTTRACKEDDEMO....................................................................... 21

Page 3: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

3 / 21

4. RECENTERONINPUTDEMO.................................................................. 215. CustomMirrorWindowDemo..................................................................... 21

Page 4: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

4 / 21

1. Environment construction

1. Installation of Piplay

Login to the official website of Pimax http://www.pimaxvr.com/ . Click on the

“Download”button, and then download it.

Piplay software

2. Connecting Pimax helmet device

Connect the HDMI cable and USB cable to the computer, turn on the Piplay and wait

for the device connecting with the computer. When the light on the helmet turns

blue, the connection succeeds.

Page 5: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

5 / 21

2. Use of Unity

1. Downloading Unity development engine

Search Unity on Google.com, then login on to the official website of Unity and

download the Unity engine.

2. Create a UNITY project

1. Double-click the Unity on the desktop, and create a new project. Then click “NEW”

on the upper right corner

Creating a project

Page 6: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

6 / 21

2. After clicking it comes with an option window, whose first line is Project name and

the second line is Location which is the path of storage items. After inputting the

project name and location, you can click “Create project” and create a Unity project.

Page 7: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

7 / 21

3. After creating the project, you can enter a Unity operating window, which is our

Unity project.

3. Import SDK

1. Installation of SDK

1. Obtain the Pimax VR Unity development plugin pvr_unity_sdk_setup.exe.

2. Double click the .exe file to install (Language Selection)

Confirm-->Next-->Next-->Install-->Confirm, then it will open the content of SDK

that is successfully installed.

3. The content of Unity_SDK is the path of installing Piplay stored

\Pimax\Sdk\Unity_plugin

Page 8: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

8 / 21

2. Import SDK

1. After finding the Unity_plugin folder, you can import PVR-Unity.unitypackage to the

scenario. There are two approaches to import the PVR-Unity.unitypackage to the

scenario:

Approach1: Drag PVR-Unity.unitypackage to the Assets folder as illustrated in the

following figure.

Approach2: After finding the Assets file directory in the figure, right-click the Assets

and then select Custom Package from the Import Package. After finding the folder

storing the PVR-Unity.unitypackage in the shown select box, you can click the

PVR-Unity.unitypackage in the folder, and then click the “Open” button in the

bottom right corner.

Page 9: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

9 / 21

2. Finishing one of the two above-mentioned approaches, you can see the pop-up

window as shown in the figure below, then click the “Import” button in the bottom

right corner to import SDK.

Page 10: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

10 / 21

3. If it shows the source file directory as shown below, it proves that we have imported

the SDK successfully.

4. Use of SDK

1. After finding the PVRUnity folder in the Asset directory, you can see a Prefab folder

in it, open it and drag two prefabs PVRCameraRig and PVRSSession to the Scene view,

and delete the MainCamera in the original scenario, as illustrated in the following

figure:

Page 11: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

11 / 21

2. Under the premise of successfully connecting the helmet in the Piplay, single-click

the left triangle button in the red circle in the figure below, then you can begin the

travel of VR development.

Page 12: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

12 / 21

5. Packaging of Unity

How to package the VRDisplayDemo to .exe file?

First step:Click the Save Scene in the File column on the upper left corner and save

the scene.

Page 13: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

13 / 21

Second step: Click the File -> Build Setting on the top, it will show a select box.

Third step: Click the “addOpenScenes” and add the VRDisplayDemo, the scenario

you have packed. Then select the first one in the selection box (The PC one from the

Page 14: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

14 / 21

red box) to be the published platform and choose x86_64(When you click the left

sidebar of “x86”, you will see the drop-down menu, and select the X86_64)to the

Architecture.

Forth step: After finishing the above two steps, click the Build button on the upper

right corner, as shown below, you can see the path of selection box storing exe. file.

Select the path you are going to store, click save button. In this way, you have

finished a VR project in Unity version successfully.

Page 15: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

15 / 21

6. Function realization of helmet button

The response of the keypress events

1. Finding the PVRInputEvent.cs script in the src folder in PVRUnity of Asset

directory, you can right-click in the space on the Hierarchy panel to create Empty.

Then click the GameObject and drag the script to the position shown in the

following figure.

2. Create a script: right-click on the red space in the figure below Create --> C#

Script. In this way, you have created a script, then double-click it to enter.

Page 16: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

16 / 21

3. Perform the event response of keys, and make the script inherent with

PVR.Unity.IPVRInputEventTarget. Add the codes in the following figure to the

script and change the output print log to the related logic codes to realize the

keypress event response.

Page 17: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

17 / 21

4. You can also refer each event response format in the RecenterTest.cs in the

Sample directory to realize various of keypress function.

Page 18: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

18 / 21

7. Reset the positive direction

Calling interface:

PVR.Unity.PVRSession.instance.recenterTrackingOrigin();

You can call the interface in the keypress response to realize the reset of the positive

direction. As shown in the following figure:

8. Meaning of each Scripting Interface

1. PVRSession.cs

To realize the connection with PVR runtime. You only need to add one in each

scenario and you can use PVRSession.prefab to add it.

Page 19: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

19 / 21

2. PVRPoseTracking.cs

To realize the banding of GameObject’s posture(direction and position) with

head and handle, when you check out the specific script in the PVRCamera, the

sub-object of PVRCamereRig, the gyroscope on the VR helmet can be turned off.

You can see in the figure below:

Page 20: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

20 / 21

3. PVREyeOffset.cs

Set the position according to the position of eyes.

4. PVRSurface.cs

To realize output the scene of the camera to the helmet, we rely on the Camera

module and PVREyeOffset module.

5. PVRInputEvent.cs

To realize the transmit of handle key event, we can receive the event using the script

in the RecenterTest.cs and achieve the response of press. In this way, we can achieve

the key control.

Page 21: PimaxVRSDK Unity DevelopmentDocumentationpiplay.pimaxvr.com/PiUnitySDKEN.pdf · PIMAX TECHNOLOGY(SHANGHAI) CO., LTD 5/21 2. Use of Unity 1. Downloading Unity development engine Search

PIMAX TECHNOLOGY(SHANGHAI) CO., LTD

21 / 21

9. Introduction of demo scenarios

1. SimpleVRDemo:

A VR demo of single PVRCameraRig.

2. MultiCameraDemo:

This demo uses multiple PVRCameraRig to realize more complicated requirements,

including that we can customization each PVRCameraRig no matter whether it is

able to follow the control of head.

3. ObjectTrackedDemo:

Some object has movement control over head or handle in demo scenario.

4. RecenterOnInputDemo:

Illustrate event handling of the handle buttons and reset of positive direction.

5. CustomMirrorWindowDemo:

This demo uses common camera to show the different window scene with the

helmet.