All pages
Powered by GitBook
1 of 1

Loading...

SceneManager Description

Description of Scene Manager

Required components of SceneManager

The following is code for required components of SceneManager

Required Components

  • ARManager

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.");
}

Use VPSStudioController to learn the name of server using location positioning

Occlusion Culling

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

MaxstSceneManager.cs
foreach (GameObject eachGameObject in occlusionObjects)
{
    Renderer[] cullingRenderer = eachGameObject.GetComponentsInChildren<Renderer>();
    foreach (Renderer eachRenderer in cullingRenderer)
    {
        eachRenderer.material.renderQueue = 1900;
        eachRenderer.material = runtimeBuildingMaterial;
    }
}

์นด๋ฉ”๋ผ ์‹œ์ž‘ / ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹œ์ž‘

์Šค๋งˆํŠธํฐ๊ณผ ์Šค๋งˆํŠธ ๊ธ€๋ž˜์Šค์™€ ๊ฐ™์€ ๋ชจ๋ฐ”์ผ ๊ธฐ๊ธฐ ํ™˜๊ฒฝ์—์„œ๋Š” ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ํ•˜๋“œ์›จ์–ด ์นด๋ฉ”๋ผ๊ฐ€ ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค. MAC OS X์™€ Windows ํ™˜๊ฒฝ์—์„œ๋Š” VPSStudioController๋ฅผ ํ†ตํ•ด ์„ ํƒํ•œ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๋ฐ์ดํ„ฐ๊ฐ€ ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ํ˜„์žฅ์— ์ง์ ‘ ๋‚˜๊ฐ€์ง€ ์•Š์•„๋„ ์•ฑ ๊ฐœ๋ฐœ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

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();
    }
}

VPS Tracker ์‹œ์ž‘

VPS Tracker๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•ด๋‹น VPS ๊ณต๊ฐ„์ง€๋„์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ์„œ๋ฒ„ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

MaxstSceneManager.cs
TrackerManager.GetInstance().StartTracker();

if (serverName != "")
{
    string vpsquery = "{\"vps_server\":\"" + serverName + "\"}";
    TrackerManager.GetInstance().AddTrackerData(vpsquery);
}

VPS ํŠธ๋ž˜ํ‚น ๊ฒฐ๊ณผ ์–ป๊ธฐ

ํŠธ๋ž˜ํ‚น ๊ฒฐ๊ณผ๋Š” UpdateFrame()๊ณผ GetARFrame()์„ ํ†ตํ•ด์„œ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. GetARFrame()์„ ํ†ตํ•ด ์–ป์€ ARFrame์˜ ์ธ์Šคํ„ด์Šค์—๋Š” ํ˜„์žฌ ํŠธ๋ž˜ํ‚น ์ƒํƒœ, ์ด๋ฏธ์ง€, 6์ž์œ ๋„ ์ž์„ธ๋ฅผ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

ARFrame์˜ GetARLocationRecognitionState()๋ฅผ ํ†ตํ•ด์„œ ํ˜„์žฌ ์œ„์น˜ ์ธ์‹ ์ƒํƒœ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ƒํƒœ ์ •๋ณด์— ๋งž์ถฐ ์ฆ๊ฐ•์‹œํ‚ฌ 3D Object์˜ ํ™œ์„ฑํ™” ์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค.

ARCamera
  • VPSStudioController

  • CameraBackgroundBahavior

  • RootTrackable

  • 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);
        }
    }