arrow-left

Only this pageAll pages
gitbookPowered by GitBook
1 of 16

Documentation (ENG)

Loading...

Getting Started

Loading...

Loading...

3D Object

Loading...

Unity Scene

Loading...

Scene Manager

Loading...

Samples

Loading...

Loading...

NReal

Loading...

Loading...

SceneManager Description

Description of Scene Manager

hashtag
Required components of SceneManager

The following is code for required components of SceneManager

circle-check

Required Components

  • ARManager

  • ARCamera

  • VPSStudioController

circle-info

Use VPSStudioController to learn the name of server using location positioning

hashtag
Occlusion Culling

When rendered 3D Objects are visibly hidden from the building mesh is called Occlusion Culling. Occlusion is applied when runtimeBuildingMaterial is rendered.

hashtag
카메라 시작 / 시뮬레이션 시작

스마트폰과 스마트 글래스와 같은 모바일 기기 환경에서는 아래 코드를 통해 하드웨어 카메라가 시작됩니다. MAC OS X와 Windows 환경에서는 VPSStudioController를 통해 선택한 시뮬레이션 데이터가 시작됩니다. 이를 통해 현장에 직접 나가지 않아도 앱 개발이 가능합니다.

hashtag
VPS Tracker 시작

VPS Tracker를 시작하기 위해서는 해당 VPS 공간지도에 접근할 수 있도록 서버 이름을 입력해야 합니다.

hashtag
VPS 트래킹 결과 얻기

트래킹 결과는 UpdateFrame()과 GetARFrame()을 통해서 얻을 수 있습니다. GetARFrame()을 통해 얻은 ARFrame의 인스턴스에는 현재 트래킹 상태, 이미지, 6자유도 자세를 포함되어 있습니다.

ARFrame의 GetARLocationRecognitionState()를 통해서 현재 위치 인식 상태를 얻을 수 있습니다. 이 상태 정보에 맞춰 증강시킬 3D Object의 활성화 여부를 결정합니다.

CameraBackgroundBahavior

  • RootTrackable

  • MaxstSceneManager.cs
    ARManager arManagr = FindObjectOfType<ARManager>();
    if (arManagr == null)
    {
        Debug.LogError("Can't find ARManager. You need to add ARManager prefab in scene.");
        return;
    }
    else
    {
        arCamera = arManagr.gameObject;
    }
    
    vPSStudioController = FindObjectOfType<VPSStudioController>();
    if (vPSStudioController == null)
    {
        Debug.LogError("Can't find VPSStudioController. You need to add VPSStudio prefab in scene.");
        return;
    }
    else
    {
        string serverName = vPSStudioController.vpsServerName;
        vPSStudioController.gameObject.SetActive(false);
    }
    
    cameraBackgroundBehaviour = FindObjectOfType<CameraBackgroundBehaviour>();
    if (cameraBackgroundBehaviour == null)
    {
        Debug.LogError("Can't find CameraBackgroundBehaviour.");
        return;
    }
    
    if(rootTrackable == null)
    {
        Debug.LogError("You need to add RootTrackable.");
    }
    MaxstSceneManager.cs
    foreach (GameObject eachGameObject in occlusionObjects)
    {
        Renderer[] cullingRenderer = eachGameObject.GetComponentsInChildren<Renderer>();
        foreach (Renderer eachRenderer in cullingRenderer)
        {
            eachRenderer.material.renderQueue = 1900;
            eachRenderer.material = runtimeBuildingMaterial;
        }
    }
    MaxstSceneManager.cs
    if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
    {
        string simulatePath = vPSStudioController.vpsSimulatePath;
        if (Directory.Exists(simulatePath))
        {
            CameraDevice.GetInstance().Start(simulatePath);
            MaxstAR.SetScreenOrientation((int)ScreenOrientation.Portrait);
        }
    }
    else
    {
        if (CameraDevice.GetInstance().IsFusionSupported(CameraDevice.FusionType.ARCamera))
        {
            CameraDevice.GetInstance().Start();
        }
        else
        {
            TrackerManager.GetInstance().RequestARCoreApk();
        }
    }
    
    MaxstSceneManager.cs
    TrackerManager.GetInstance().StartTracker();
    
    if (serverName != "")
    {
        string vpsquery = "{\"vps_server\":\"" + serverName + "\"}";
        TrackerManager.GetInstance().AddTrackerData(vpsquery);
    }
    MaxstSceneManager.cs
    void Update()
    {
        TrackerManager.GetInstance().UpdateFrame();
    
        ARFrame arFrame = TrackerManager.GetInstance().GetARFrame();
        
        TrackedImage trackedImage = arFrame.GetTrackedImage();
    
    
        if (trackedImage.IsTextureId())
        {
            IntPtr[] cameraTextureIds = trackedImage.GetTextureIds();
            cameraBackgroundBehaviour.UpdateCameraBackgroundImage(cameraTextureIds);
        }
        else
        {
            cameraBackgroundBehaviour.UpdateCameraBackgroundImage(trackedImage);
        }
    
        if(arFrame.GetARLocationRecognizeState() == ARLocationRecognizeState.ARLocationRecognizeStateNormal)
        {
            Matrix4x4 targetPose = arFrame.GetTransform();
    
            arCamera.transform.position = MatrixUtils.PositionFromMatrix(targetPose);
            arCamera.transform.rotation = MatrixUtils.QuaternionFromMatrix(targetPose);
            arCamera.transform.localScale = MatrixUtils.ScaleFromMatrix(targetPose);
    
            rootTrackable.SetActive(true);
        }
        else
        {
            rootTrackable.SetActive(false);
        }
    }

    3D Object Placement

    Easily place rendered 3D Object in UnitySceneView and precisely arrange its positioning via simulation using reference camera

    hashtag
    Load VPS Map

    Load VPS Map on VPSStudio GameObject via VPSStudioController

    Select map in VPSStudio

    Once VPS Map is loaded, it is presented in UnitySceneView as depicted below.

    Unity Scene View once the map is loaded

    hashtag
    Contents Placement

    Placing content on Map is based on the location of the mesh. Place contents around mesh and confirm through ReferenceCamera

    circle-exclamation

    Change the location of the content upon selecting ReferenceCamera, and the user will be able to accurately pinpoint its position.

    hashtag
    Check the status of Content Generation via Simulation Data

    Upon completion of content generation, you will be able to confirm through VPS Simulation Data on VPSStudio. The Simulation Data of the particular regions will be available on OSX or Windows.

    hashtag
    Mesh Settings for Occlusion

    The features of occlusion (Hidden features of building meshes) is specified on the page below

    Unity Scene Components

    Detailed Information on Unity Scene components of MAXST VPS

    hashtag
    Scene Components

    The Unity Scene Hierarchy for MAXSTVPS is as follows.

    circle-check

    ARCamera GameObject : Process tracking camera images and positioning

  • VPSStudio GameObject : Manage VPS Map data

  • RootTrackable GameObject : Root Object of rendered 3D objects on VPS Map

    • (Rendering 3D Objects must be placed under Root Objects)

  • SceneManager GameObject : Control MAXSTVPS actions

  • hashtag
    ARCamera GameObject

    ARCamera components
    circle-info

    ARCamera reflects 6Degree of Freedom (Position/Rotation) of the camera on user's device

    hashtag
    CameraBackground GameObject

    CameraBackground display images extracted from hardware camera

    hashtag
    VPSStudio GameObject

    VPSStudio manages VPS Map data

    VPSStudio Inspector

    VPSStudio Controller menu is as follows:

    • Using VPS Map combo box, check the VPS Map list under VPSData Folder and select the desired location

    • Using VPS Map combo box, check the simulation data list under VPSData/VPSSimulationData/your_vps_map and select the desired simulation data

    • The mesh information & reference camera of the selected location will be loaded when you press Load VPS Map button

    • The mesh information and reference camera will be deleted when you press clear button

    circle-info

    Reference Camara Controller will find the optimized perspective for 3D object placement

    Navigation Controller will offer navigation function within the selected location

    • Position Distance indicates the interval between rendering arrow objects in alignment to navigation path. The unit is in meters.

    • Arrow prefab is 3D arrow objects in the navigation path.

    • Root Trackable is Root GameObject to render 3D Object on the navigation path based on tracking position

    hashtag
    Scene Manager

    SceneManager manages VPS controls

    SceneManager Inspector
    • Disable Objects are GameObjects that needs to be disabled from the perspective of Unity Play. (VPSStudio Game Object includes camera eye, thus needs to be disabled).

    • Root Trackable is GameObject that includes all tracking contents

    • Occlusion Objects are Mesh that needs to add occlusion from the perspective of Unity Play. If there are additional mesh that needs occlusion culling, you can simply add the following element.

    SceneManager Descriptionchevron-right
    Place content around the mesh
    Select ReferenceCamera around the mesh
    Confirm through ReferenceCamera
    Unity Game View

    AR Navigation

    Description of AR Navigation using MAXSTVPS

    hashtag
    AR Navigation

    The code to determine the point of departure and arrival to find the navigation path is as follows. If you wish to get a navigation path from the point of user's location, set arCamera.tranform.position as a point of departure. This will only be successful if the localization is practiced correctly.

    NavigationController is collected from VPSStudio GameObject. Through MakePath() from Instance of NavigationController, you will receive the path from the point of departure to the point of arrival.

    Setup Guide

    Setup Guide of MAXSTVPS SDK

    hashtag
    Requirements & Supports

    Requirements

    • MAXSTVPS SDK recommends or higher

    VPS Map Coverage

    Currently available VPS Maps

    hashtag
    Around Yangjae Station, Seoul, South Korea

    Gross Area: Approx. 79,659 m²

    Prerequisites

    Requirements to MAXSTVPS SDK

    hashtag
    MAXSTVPS Unity Project for Smart Phones

    AR Navigation Sample
    circle-info

    Enter 3D coordinate value as the point of arrival based on the mesh of VPS Map.

    • arCamera.transform.position is position of camera in relation to VPS Map's coordinate system.

    MaxstSceneManager.cs
    public void OnClickNavigation()
    {
        NavigationController navigationController = vPSStudioController.GetComponent<NavigationController>();
        navigationController.MakePath(arCamera.transform.position, new Vector3(77.975977f, 0, 71.859565f), serverName);
    }

    In order to use MAXSTVPS SDK for Unity, you need basic knowledge of Unity developer tools and developer resources.

  • To find out more about developer tools for Unity, click herearrow-up-right for more information.

  • hashtag
    Install MAXST VPS Unity SDK

    1. Download MAXSTVPS SDK

    2. Create or Open Unity Project

    3. Newly created project, must download MAXSTVPSSDK_0.8.0.unitypackage and install on Unity

    4. Download VPSData and install VPSMap in accordance to location

    circle-info

    Download these files via email.

    hashtag
    Unity Setting

    Description of File/Build Settings/Player Settings for Unity

    triangle-exclamation
    • Android must only select OpenGLES3 in Graphic APIs on Other Settings

    • Android must uncheck Multithreaded Rendering

    • Android must have Custom Main Manifest & Custom Main Gradle Template installed on Publishing Settings

    Refer to the following Github links for Manifest and Gradle

    Github Link

    circle-exclamation

    iOS must include descriptions for Camera Usage Description and Location Usage Description

    hashtag
    Install Editor Coroutines Package

    MAXSTVPS SDK requires Editor Coroutines Package in Unity

    triangle-exclamation

    If the following message pops up, go to Unity > Window > PackageManager > Search Editor Coroutines and download the package

    hashtag
    Install VPS Map

    VPS Map includes mesh, reference images and simulation data of the location. As suggested below, VPSData folder needs to be created at same hierarchy as Unity Project folder (MAXSTVPSUnity), and VPSMap folder needs to be saved under VPSData.

    Once you unzip VPSData_yangjae_indoor.zip by MAXST, it automatically opens under VPSData folder as VPSMap and VPSSimulationData. yangjae_indoor folder will be generated automatically under these two folders.

    VPSMap Folder Structure
    circle-exclamation

    You must follow VPSMap Folder Structure in order to successfully activate VPS Map

    Unity 2020arrow-up-right

    37.48513

    127.03492

    Yangjae Station Crossroad (2)

    37.48450

    127.03408

    Map boarders (3)

    37.48756

    127.03168

    Map boarders (4)

    37.48798

    127.03300

    Map boarders (5)

    37.48509

    127.03555

    Map boarders (6)

    37.48369

    127.03500

    Map boarders (7)

    37.48441

    127.03214

    VPS Map _ Around Yangjae station

    Landmarks

    Latitude

    Longitude

    MAXST Office (1)

    file-pdf
    397KB
    VPS맵커버리지(영문).pdf
    PDF
    arrow-up-right-from-squareOpen
    VPSMapCoverage_YangjaeStation

    iPhones (supporting ARKit), Android Phones (supporting ARCore)

    Samples

    Placement by Raycasting, AR Navigation

    hashtag
    MAXSTVPS Unity Project for Nreal Glasses

    Included SDK Version

    0.8.0

    Requirements

    Unity 2020 or later,

    Supported Devices

    Nreal Glasses

    Samples

    Placement by Raycasting, AR Navigation

    hashtag
    VPS Map

    VPS Map includes the following information of the locations: Mesh, Reference Camera, Simulation Data

    Included SDK Version

    0.8.0

    Requirements

    Unity 2020 or later

    Supported Devices

    The type or namespace name 'EditorCoroutines' does not exist in the namespace ‘Unity'.  
    Nreal Unity SDKarrow-up-right
    AndroidManifest.xmlarrow-up-right
    MainTemplate.gradlearrow-up-right

    API Reference

    API Reference Link

    Click to check API Reference

    herearrow-up-right

    Placement by Raycast

    hashtag
    Placement by Raycast

    This is a sample of placing 3D objects on to the surface of buildings with the point of contact. Using mouse or touch panel, ray is casted that connects to camera's focal point, and thus calculate code based on transactional points with building mesh.

    MaxstSceneManager.cs
    public void AttachLogo()
    {
        Vector2 vTouchPos = Input.mousePosition;
    
        Ray ray = Camera.main.ScreenPointToRay(vTouchPos);
    
        RaycastHit vHit;
        if (Physics.Raycast(ray.origin, ray.direction, out vHit))
        {
            maxstLogObject.transform.position = vHit.point;
            maxstLogObject.transform.rotation = Quaternion.FromToRotation(Vector3.forward, vHit.normal) * Quaternion.Euler(-90.0f ,0.0f, 0.0f);
        }
    }
    Example of Placement by Raycasting

    Nreal Support

    hashtag
    Nreal Unity SDK Download

    In order to support Nreal Glasses, Nreal Unity SDK is required. click herearrow-up-right to download the SDK. Download Nreal Unity SDK and click Assets/import Package to add onto your project.

    hashtag
    MAXST VPS Unity SDK for Nreal Glasses Download

    In order to support Nreal Glasses, MAXSTVPS Unity SDK for Nreal Glasses is required. Click to download the SDK. Click Assets/import Package to add the SDK onto your project.

    hashtag
    Unity Scene Components

    Unity Scene components for Nreal Glasses are as follows. Detailed information regarding Unity Scene components can be found in the link below. ARCamera from the former Unity Scene is replaced with NRCameraRig.

    hashtag
    SceneManager Components

    ARCamera from SceneManager is replaced with NRCameraRig Object

    hashtag
    Nreal Camera Start/ VPS Tracker Start

    ‌Play() of Instance from NRCollect YUV starts Nreal Camera.

    VPSTracker Start can be found in the page below.

    hashtag
    Get result for VPS Tracker

    This is a code for ARFrame Instance from Unity Update(). This is a code to obtain the posture of 6Degrees of Freedom on VPS Map at the time of update and reflect it on the virtual camera for rendering.

    herearrow-up-right
    Unity Scene Componentschevron-right
    SceneManager Descriptionchevron-right
    Unity Scene Hierarchy for Nreal Glasses
    SceneManager Components for Nreal
    NRealSceneManager.cs
    nRCollectYUV = new NRCollectYUV();
    nRCollectYUV.Play();
    TrackerManager.GetInstance().StartTracker();
    
    if (serverName != "")
    {
        string vpsquery = "{\"vps_server\":\"" + serverName + "\"}";
        TrackerManager.GetInstance().AddTrackerData(vpsquery);
    }
    NRealSceneManager.cs
    void Update()
    {
        TrackerManager.GetInstance().UpdateFrame();
        nRCollectYUV.UpdateFrame();
        var eyePoseFromHead = NRFrame.EyePoseFromHead;
        Matrix4x4 Mhe = MatrixUtils.ConvertPoseToMatrix4x4(eyePoseFromHead.RGBEyePos);
    
        ARFrame arFrame = TrackerManager.GetInstance().GetARFrame();
    
        if (arFrame.GetARLocationRecognizeState() == ARLocationRecognizeState.ARLocationRecognizeStateNormal)
        {
            Matrix4x4 targetPose = arFrame.GetTransform(Mhe);
    
            arCamera.transform.position = MatrixUtils.PositionFromMatrix(targetPose);
            arCamera.transform.rotation = MatrixUtils.QuaternionFromMatrix(targetPose);
            arCamera.transform.localScale = MatrixUtils.ScaleFromMatrix(targetPose);
    
            rootTrackable.SetActive(true);
        }
        else
        {
            rootTrackable.SetActive(false);
        }
    }