Skip to content

πŸ”Ž It is my project of computer animation course!

Notifications You must be signed in to change notification settings

ms0680146/unity-ar-vr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ARTOVR

It is my project of computer animation course in NCCU!

Demo Website!

http://imlab3.cs.nccu.edu.tw/~105257029/

Tools:

Unity5.6 / Vuforia-unity-6-2-10 / ovr_unity_utilities_1.13.0 / Gear VR HMD

Introduction:

I want to make an AR to VR experience through Vuforia!
Demo for the AR/VR Sample.
https://www.youtube.com/watch?v=rLIVKO3YFos
Integrating Gear VR and the AR/VR Sample in Unity 5.3 and above
https://library.vuforia.com/articles/Solution/Integrating-Gear-VR-and-the-AR-VR-Sample-in-Unity-5-3-and-above.html

Step1-Using Vuforia with Unity 5.3's Built-in VR Functionality and Oculus Utilities:

Unity VR with Oculus Utilities for Unity 5: Enable Unity's VR and link the OVRCameraRig prefab to the ARCamera and have access to additional Oculus-specific APIs.

  1. Download the Oculus Utilities for Unity 5
  2. Create a new Unity project and import the following:
  • arvr-x-y-z.unitypackage (In Vuforia Develop -> Samples -> Digital Eyewear -> Dowload for unity!)
  • OculusUtilities.unitypackage (ovr_unity_utilities_1.13.0)
  1. Open the Vuforia-3-AR-VR.unity scene
  2. Open the Android Player Settings (File > Build Settings... > Player Settings) and enable the following checkbox options:
  • Multithreaded Rendering
  • Virtual Reality Supported
    image
  1. Drag an instance of OVRCameraRig to the Hierarchy and position at [0, 2, -1].
  2. Now configure the CenterEyeAnchor fields:
  • Clear Flags = Solid Color
  • Background = Black
  • Clipping Planes [Near] = 0.05 *
  • Clipping Planes [Far] = 300 *
  • TargetEye = Left
  1. Duplicate the CenterEyeAnchor, name it CenterRightEyeAnchor, and set the following:
  • TargetEye = Right We recommend Near = 0.05 and Far = 300 for AR/VR scenes, but you can adjust to suit your 3D scene.
    image
  1. Add two new Empty GameObjects (VuforiaCenterAnchor & TrackableParent) to the existing OVRCameraRig in the Vuforia-3-AR-VR scene as shown in the partial hierarchical outline below (screenshot shows full rig hierarchy):
  • TrackableParent eGO x=0, y=0, z=0
  • VuforiaCenterAnchor eGO x=0, y=0, z=0
  • eGO = Empty GameObject
  • Make all targets (i.e. Trackables) in the scene children of the TrackableParent object. In the AR-VR sample, the Trackable is the ImageTargetStones GameObject.
    image
  1. Attach the VRIntegrationHelper.cs script to both the CenterEyeAnchor and CenterRightEyeAnchor
  2. On the CenterEyeAnchor, enable the checkbox Is Left and drag the TrackableParent object onto the Trackable Parent property in the Inspector.
    image

Step2-Camera Rig Binding Steps for the Two Integration Techniques:

  1. Select the ARCamera in the Hierarchy
  2. Vuforia 6.2 in the VuforiaConfiguration asset set the following properties:
  • Eyewear Type = Video See-Through
  • Stereo Camera Config = Gear VR (Oculus)
    image
  1. Drag the following GameObjects in the Hierarchy to the respective fields:
  • VuforiaCenterAnchor to Central Anchor Point
  • CenterEyeAnchor (Oculus) to Left Camera
  • CenterRightEyeAnchor (Oculus) to Right Camera
    image
  1. Click the Add Vuforia Components button that will appear under the Left Camera and also under Right Camera fields in the Inspector.

Step3-Additional Build Details

Place Oculus Signature Files (OSIGs) in the following Unity project location: Assets/Plugins/Android/assets/

Step4-VRIntegrationHelper.cs OnPreRender()

Open the VRIntegrationHelper.cs script located in Assets/Vuforia/Scripts/Utilities and replace the code in OnPreRender() with the following:

void OnPreRender()
{
    // on pre render is where projection matrix and pixel rect 
    // are set up correctly (for each camera individually)
    // so we use this to acquire this data.
     
    if (IsLeft && !mLeftCameraDataAcquired)
    {
        if (
            !float.IsNaN(mLeftCamera.projectionMatrix[0,0]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[0,1]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[0,2]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[0,3]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[1,0]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[1,1]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[1,2]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[1,3]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[2,0]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[2,1]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[2,2]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[2,3]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[3,0]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[3,1]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[3,2]) &&
            !float.IsNaN(mLeftCamera.projectionMatrix[3,3])
           )
        {
            mLeftCameraMatrixOriginal = mLeftCamera.projectionMatrix;
            mLeftCameraPixelRect = mLeftCamera.pixelRect;
            mLeftCameraDataAcquired = true;
        }
    }
    else if (!mRightCameraDataAcquired)
    {
        if (
            !float.IsNaN(mRightCamera.projectionMatrix[0,0]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[0,1]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[0,2]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[0,3]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[1,0]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[1,1]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[1,2]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[1,3]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[2,0]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[2,1]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[2,2]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[2,3]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[3,0]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[3,1]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[3,2]) &&
            !float.IsNaN(mRightCamera.projectionMatrix[3,3])
           )
        {
            mRightCameraMatrixOriginal = mRightCamera.projectionMatrix;
            mRightCameraPixelRect = mRightCamera.pixelRect;
            mRightCameraDataAcquired = true;
        }
    }
}

Reference:

Unite 2015 - Creating Mixed Reality Apps with Vuforia 5
https://www.youtube.com/watch?v=RdDAjgfj_Yw

About

πŸ”Ž It is my project of computer animation course!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published