• [holoLens2 ๊ฐœ๋ฐœ ํŠœํ† ๋ฆฌ์–ผ] HoloLens 2 fundamentals: develop mixed reality applications (1)

    2022. 1. 15.

    by. ํ•ด๋Š”์„ 

    ์ด ๊ธ€์€ ๋‹ค์Œ์˜ hololens2 fundamentals ํŠœํ† ๋ฆฌ์–ผ์„ ๋”ฐ๋ผํ•˜๊ณ , ์ด๋ฅผ ์ •๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค.

    https://docs.microsoft.com/en-us/learn/paths/beginner-hololens-2-tutorials/

     

    HoloLens 2 fundamentals: develop mixed reality applications - Learn

    Explore best practices for developing Azure-enabled mixed reality applications with the Mixed Reality Toolkit.

    docs.microsoft.com

    1. Introduction to the Mixed Reality Toolkit-Set Up Your Project and Use Hand Interaction

    1) Introduction to the Mixed Reality Toolkit--Set Up Your Project and Use Hand Interaction

    • Mixed Reality Toolkit(MRTK)๋Š” VR, AR์— ๋Œ€ํ•ด ํ˜ผํ•ฉํ˜„์‹ค๊ฒฝํ—˜์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” cross-platform toolkit.
    • ํ™€๋กœ๊ทธ๋ž˜ํ”ฝ ๋ฌผ์ฒด๋ฅผ ์›€์ง์ด๊ณ , ๋Œ๋ฆฌ๊ณ , ํ‚ค์šฐ๊ณ  ์ค„์ด๋Š”๋ฐ ์žˆ์–ด ๊ฐœ๋ฐœ์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“ค์–ด ์คŒ.
    • ์ด module (ํŠœํ† ๋ฆฌ์–ผ)์„ ๋๋‚ด๋ฉด, MRTK ๊ฐœ๋ฐœ์„ ์œ„ํ•œ unity project ์„ค์ •์„ ํ•˜๊ณ , ์ด๋ฅผ ์ด์šฉํ•ด ๊ฐœ๋ฐœ์„ ๊ฐ€์†ํ™” ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ.

     

    <๋ฐฐ์šฐ๋Š” ๊ฒƒ>

    • ์œˆ๋„์šฐ ํ˜ผํ•ฉํ˜„์‹ค ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ์œ ๋‹ˆํ‹ฐ ํ™˜๊ฒฝ์„ค์ •
    • MRTK ๊ธฐ์ดˆ ํŒจํ‚ค์ง€๋ฅผ unity๋กœ ๋ถˆ๋Ÿฌ์˜ค๋Š” ๋ฒ•
    • Unity scene์— mrtk ์ถ”๊ฐ€
    • ์„ธ๊ฐ€์ง€ ๊ธฐ๋ณธ MRTK ์ƒํ˜ธ์ž‘์šฉ ๋ชจ๋ธ์„ ๋น„๊ต&๋Œ€์กฐ
    • ObjectManipulator๋ฅผ ์ด์šฉํ•ด์„œ ํ™€๋กœ๊ทธ๋žจ ์กฐ์ž‘

     

     

    2) Set up a mixed reality project in Unity with the Mixed Reality Toolkit

    • ๋จผ์ € unity project๋ฅผ windows mixed reality development๋ฅผ ์œ„ํ•ด ํ™˜๊ฒฝ์„ค์ •(๊ตฌ์„ฑ)์„ ํ•ด์•ผ ํ•จ.
    • ์ด ๊ตฌ์„ฑ์€ unity project๋ฅผ ๋งŒ๋“ค ๋•Œ ๋งˆ๋‹ค ์ˆ˜๋™์œผ๋กœ ํ•ด์•ผ ํ•จ.

     

    <Universal Windows Platform>

    •  windows mixed reality๋ฅผ ๋Œ€์ƒ์œผ๋กœ ํ•˜๊ธฐ ์œ„ํ•ด unity project๋ฅผ universal windows platform ์•ฑ์œผ๋กœ ๋‚ด๋ณด๋‚ด๋„๋ก ์„ค์ •ํ•ด์•ผ ํ•จ.
    • ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ชจ๋“  ์žฅ์น˜๋ฅผ ๋Œ€์ƒ์œผ๋กœ ๋นŒ๋“œ ์„ค์ •์ด ๋˜์–ด์žˆ์Œ (๋ณ€๊ฒฝ ๊ฐ€๋Šฅ)
    universal windows platform(UWP) : microsoft์—์„œ ๊ฐœ๋ฐœํ•œ .NET core ๊ธฐ๋ฐ˜์˜ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ ํ”Œ๋žซํผ. ์ฆ‰, windows์šฉ ํด๋ผ์ด์–ธํŠธ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ ํ”Œ๋žซํผ.

     

    <Create an immersive view>

    • Windows app์—๋Š” 2D view, immersive view๊ฐ€ ์กด์žฌ.
    • ๋ชฐ์ž…ํ˜• ๋ทฐ(immersive view)๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ ์žˆ๋‹ค๋ฉด mixed reality app, ์ „ํ˜€ ์—†๋‹ค๋ฉด 2D apps์œผ๋กœ ๋ถ„๋ฅ˜.
    • Virtual Reality Supported๋ฅผ ํ™œ์„ฑํ™” ํ•ด์„œ ๋ชฐ์ž…ํ˜• ๋ทฐ๋ฅผ ์ƒ์„ฑํ•˜๋„๋ก ํ”„๋กœ์ ํŠธ๋ฅผ ๊ตฌ์„ฑ ๊ฐ€๋Šฅ.
    • Vritual reality SDK๋กœ๋Š” ๊ทธ๋ƒฅ windows 10 SDK๋ฅผ ์‚ฌ์šฉ.

     

    <How are holograms rendered>

    •  mixed reality app์—์„œ scene์€ ์‚ฌ๋žŒ ๋ˆˆ ๊ฐ๊ฐ์— ๋Œ€ํ•ด ํ•œ ๋ฒˆ์”ฉ, ์ด ๋‘ ๋ฒˆ ๋ Œ๋”๋ง ๋จ. => ์ด ๋ฐฉ๋ฒ•์„ stereoscopic vision์ด๋ผ๊ณ  ํ•จ.
    • ๊ธฐ์กด 3D ๊ฐœ๋ฐœ๊ณผ ๋‹ค๋ฅด๊ฒŒ ๊ณ„์‚ฐ๋Ÿ‰์ด 2๋ฐฐ๊ฐ€ ๋จ => ํšจ์œจ์ ์ธ rendering ๊ฒฝ๋กœ ์„ ํƒ์ด ์ค‘์š”
    • Single pass instanced rendering์€ ์ด ํŒŒ์ดํ”„๋ผ์ธ์„ ์ตœ์ ํ™” => ์ด๊ฑธ ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ํ•˜๋Š”๊ฒŒ ์ข‹๋‹ค.

     

    <How to stabilize holograms>

    • Depth Buffer Sharing ํ—ˆ์šฉ => Unity๊ฐ€ ์ƒ์„ฑํ•œ depth map์„ Windows Mixed Reality flatform๊ณผ ๊ณต์œ ํ•ด์„œ ๋” ๋‚˜์€ ํ™€๋กœ๊ทธ๋žจ ์•ˆ์ •์„ฑ (stability)๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Œ.
    • 16-bit depth๋ฅผ ์„ ํƒํ•˜๋ฉด ๋ฐ์ดํ„ฐ๋Ÿ‰์ด ์ ์–ด์ ธ์„œ bandwidth requirements๋„ ๋Œ€ํญ ์ค„์–ด๋“ฆ.

     

     

    3) Exercise - Configure Unity for Windows Mixed Reality

    <Create a new unity project>

    • Unity Hub -> projects -> New (module Prerequisites์— ๋งž๊ฒŒ ์„ ํƒ)
    • new project๋ฅผ ๋งŒ๋“ค ๋•Œ, templates - 3D ์„ ํƒ -> create

     

    <Switch the build platform - unity 2020 ์ด์ƒ ๊ธฐ์ค€>

    • (in unity memu) file -> build settings
    • (in build settings) UWP๋ฅผ ์„ ํƒํ•˜๊ณ  ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •

    • ์ดํ›„ Switch Platform์„ ๋ˆ„๋ฅด๊ณ , ์Šค์œ„์นญ์ด ๋๋‚˜๋ฉด X๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์ฐฝ์„ ๋‹ซ๋Š”๋‹ค.

     

    4) Import and configure resources

    • MRTK๋Š” unity mixed reality project๋กœ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋Š” open-source toolkit. ์—†์–ด๋„ ํ˜ผํ•ฉํ˜„์‹ค ์•ฑ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์ง€๋งŒ, ์žˆ์œผ๋ฉด ๋” ๋นจ๋ฆฌ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ์Œ.

     

    <MRTK Unity>

    • HoloLens, WMR, OpenVR์—์„œ Unity ๊ฐœ๋ฐœ์„ ์œ„ํ•œ basic building block ์ œ๊ณต
    • in-editor simulation์„ ์ด์šฉํ•ด ์ฆ‰์‹œ ํ™•์ธ ๊ฐ€๋Šฅ
    • core components๋ฅผ ๊ต์ฒด๊ฐ€๋Šฅํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋Š” extensible framework๋กœ ์ž‘๋™.
    • HoloLens, HoloLens2, Windows Mixed Reality Headsets, OpenVR headsets(HTC Vive, Oculus Rift) ๋“ฑ์„ ์ง€์›.

     

    <MRTK Unity foundation package>

    • MRTK foundation package๋Š” project์—์„œ MRTK๋ฅผ ์“ฐ๊ธฐ ์œ„ํ•œ ์œ ์ผํ•œ ํ•„์ˆ˜ ํŒจํ‚ค์ง€. 2.5.x ๋ฒ„์ „ ์ด์ƒ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•จ.
    • MRTK๊ฐ€ scene์— ์ถ”๊ฐ€๋˜๊ณ  ๊ตฌ์„ฑ๋˜๋ฉด MixedRealityToolkit, MixedRealityPlayspace ๋‘๊ฐ€์ง€ object๊ฐ€ scene hierarchy window์— ์ถ”๊ฐ€๋จ.
    • MixedRealityToolkit - toolkit ๊ทธ ์ž์ฒด / MixedRealityPlayspace - headset/controller ๋“ฑ other required system์ด scene์—์„œ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๊ด€๋ฆฌ๋˜๋„๋ก ๋ณด์žฅ.
    • Main camera๋Š” MixedRealityPlayspace์˜ ์ž์‹์œผ๋กœ ์ด๋™

     

    <Configuration profile>

    • profile : MRTK core components์˜ ํ–‰๋™์„ ๊ตฌ์„ฑ.
    • MixedRealityToolkit object์—๋Š” active profile์ด ํฌํ•จ๋˜์–ด ์žˆ์œผ๋ฉฐ, Inspector window์—์„œ ๋ณผ ์ˆ˜ ์žˆ์Œ.
    • MRTK๊ฐ€ scene์— ์ถ”๊ฐ€๋˜๋ฉด, DefaultMixedRealityToolkitConfigurationProfile์ด ๋ฏธ๋ฆฌ ์„ ํƒ๋จ.
    • MRTK๋Š” ์ง€์›ํ•˜๋Š” ๋Œ€๋ถ€๋ถ„์˜ ํ”Œ๋žซํผ&์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ๋‹ค๋ฃจ๋Š” ์ถ”๊ฐ€ basic profile ์ œ๊ณต. ์œ„์—์„œ ๋ฏธ๋ฆฌ ์„ ํƒ๋œ profile์€ general use profile์ด๋ฏ€๋กœ ํŠน์ • ํ”Œ๋žซํผ์— ์ตœ์ ํ™” ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด MRTK๊ฐ€ ์ œ๊ณตํ•˜๋Š” profile์„ ์„ ํƒํ•ด์•ผ ํ•จ.

     

    <How are customize and configure the default MRTK profiles>

    • default MRTK profiles์€ ์ˆ˜์ • ๋ถˆ๊ฐ€๋Šฅ. ๋Œ€์‹ , ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด profile์„ cloneํ•ด์„œ ์ˆ˜์ • ๊ฐ€๋Šฅ.
    • sub-profile์„ ์ˆ˜์ •ํ•˜๋ ค๋ฉด ๊ทธ๊ฒƒ๋„ ๋ณต์ œํ•ด์•ผ ํ•จ.

     

    5) Exercise - Import and configure resources

    <Import the MRTK Unity foundation package>

    • MRTK๋ฅผ importํ•˜๋ ค๋ฉด Mixed Reality Feature๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•จ.
    • microsoft download center์—์„œ Mixed Reality Feature tool์„ ๋‹ค์šด๋ฐ›๊ณ , exe๋ฅผ ์‹คํ–‰.
    • (in MR feature tool) Start -> project folder open -> Discover Features
    ์ด๋•Œ, folder path๋ฅผ ๋„ฃ๊ธฐ ์œ„ํ•ด์„œ๋Š” ์›ํ•˜๋Š” folder์— ๋“ค์–ด๊ฐ€์„œ file path์— _๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ํ™•์ธ์„ ๋ˆ„๋ฅด๋ฉด ๋œ๋‹ค.
    • Mixed Reality Toolkit -> Mixed Reality Toolkit Foundation ์„ ํƒ
    • Platform Support -> Mixed Reality OpenXR Plugin ์„ ํƒ (์ตœ์‹ ๋ฒ„์ „์œผ๋กœ)
    • get feature ํด๋ฆญ -> validate ํด๋ฆญ -> No validation issues were detected ๊ฐ€ ๋‚˜์™€์•ผ ์ •์ƒ!
    • import -> approve => ๋!

     

    <Configure the Unity project>

    • warning ์ฐฝ์ด ๋œจ๋ฉด yes๋ฅผ ๋ˆ„๋ฅธ๋‹ค.
    • ๊ทธ๋Ÿฌ๋ฉด MRTK configurator๊ฐ€ ๋œจ๋Š”๋ฐ, ์•ˆ ๋œจ๋ฉด ๋‹ค์Œ ๊ฒฝ๋กœ๋กœ ๋“ค์–ด๊ฐ€์„œ ๋„์šด๋‹ค.
      Mixed Reality > Toolkit > Utilities > Configure Project for MRTK
    • (in MRTK configurator) Unity OpenXR plugin -> XR Plug-In Management Settings
    • ๊ทธ ๋’ค, project setting์ด ์—ด๋ฆฌ๋Š”๋ฐ, XR Plugin management -> UWP(์œˆ๋„์šฐ ๋กœ๊ณ ) ์„ค์ •์—์„œ OpenXR, Microsoft HoloLens feature set ํ™œ์„ฑํ™”.
    • XR Plug-In Management Settings -> OpenXR์—์„œ depth 16bit ์„ ํƒ, interaction profile์— microsoft hand interaction profile ์ถ”๊ฐ€.
    • ๊ทธ๋ฆฌ๊ณ  Apply๋ฅผ ๋ˆ„๋ฅด๋ฉด unity๊ฐ€ ์žฌ์‹œ์ž‘.

     

    • ์žฌ์‹œ์ž‘ ํ›„, Edit -> project setting -> player -> publishing settings์˜ package name์— ์ด๋ฆ„ ์ž‘์„ฑ (์ด๋Š” ๊ณ ์œ  ์‹๋ณ„์ž๋กœ์จ ์•ฑ์˜ ๊ณ ์œ  ๋ฒˆํ˜ธ? ๊ฐ™์€ ๊ฒƒ์ž„. ์ด๊ฒŒ ๊ฐ™์œผ๋ฉด ๊ธฐ์กด์— ์กด์žฌํ•˜๋Š” ์•ฑ์ด ๋ฎ์–ด์”Œ์›Œ์ง)
    • product name์€ hololens start menu์— ํ‘œ์‹œ๋จ. _ ์„ ์ด๋ฆ„ ์•ž์— ๋„ฃ์œผ๋ฉด ์•ž์— ์ •๋ ฌ๋˜์–ด์„œ ๋นจ๋ฆฌ ์ฐพ์„ ์ˆ˜ ์žˆ์Œ (๊ฐœ๋ฐœ ์‹œ์—๋งŒ)

     

    <Create the scene and configure MRTK>

    • (in unity menu) File -> New Scene -> Basic (Built-in) -> create
    • (in unity menu) Mixed Reality -> Toolkit -> Add to Scene and Configure
    • (in Hierarchy window) MixedRealityToolkit object๊ฐ€ ์„ ํƒ๋œ ์ƒํƒœ๋กœ, Inspector window์—์„œ MixedRealityToolkit configuration profile์ด DefaultMixedRealityToolkitConfigurationProfile์ธ์ง€ ํ™•์ธ
    • (in unity menu) file -> save as => Asset > Scenes ์•„๋ž˜์— scene์„ ์ €์žฅ.

     

    6) Interaction models

    • MRTK๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด 6DoF controler, ์†, ์Œ์„ฑ๊ณผ ๊ฐ™์€ ๋‹ค์–‘ํ•œ input ์‚ฌ์šฉ ๊ฐ€๋Šฅ. ์—ฌ๊ธฐ์„œ๋Š” ์„ธ ๊ฐ€์ง€ ๊ธฐ๋ณธ interactino model๊ณผ unity input simulation์— ๋Œ€ํ•ด ์•Œ์•„๋ณผ ๊ฒƒ.

     

    <Hands and motion controllers model>

    • ํ•œ ์† ๋˜๋Š” ๋‘ ์†์„ ์‚ฌ์šฉํ•จ.
    • ์†์œผ๋กœ ์ง์ ‘ ์กฐ์ž‘ (direct manipulation) / ์†์œผ๋กœ ๊ฐ€๋ฆฌํ‚ค๊ธฐ (point and commit) / ์ปจํŠธ๋กค๋Ÿฌ ์ด์šฉ (motion controllers)

     

    <Hands-free model>

    • ์†์„ ๋ชป ์“ฐ๋Š” ์ƒํ™ฉ์ผ ๋•Œ ์Œ์„ฑ์ด๋‚˜ ๋ˆˆ ์›€์ง์ž„์„ ์ด์šฉํ•จ.
    • ์Œ์„ฑ์ž…๋ ฅ (voice) / ์‘์‹œ ๋ฐ ๊ธฐ๋‹ค๋ฆผ(gaze and dwell)

     

    <Gaze and dwell>

    • ๋ˆˆ์„ ๋งˆ์šฐ์Šค์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•˜๋ฉด ๋ชจ๋ธ! ์›๊ฑฐ๋ฆฌ ์ž…๋ ฅ ๋ชจ๋ธ์ด๋ผ ์†์ด ๋‹ฟ์ง€ ์•Š๋Š” ๊ฒƒ๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ๊ฐ€์žฅ ์ข‹์Œ.
    • ์‘์‹œ ์ž…๋ ฅ / other commit (์‹œ์„ ์„ ์ด์šฉํ•˜์—ฌ ๋Œ€์ƒ ์ง€์ • ํ›„ ์Œ์„ฑ๋ช…๋ น, ๋ฒ„ํŠผ๋ˆ„๋ฅด๊ธฐ, ์† ์ œ์Šค์ณ)

     

    <Unity in-editor input simulation>

    • ์žฅ๋ฉด ์ด๋™ : WASD(์•ž์™ผ๋’ค์˜ค), QE(์ˆ˜์ง์ด๋™), right mouse(์นด๋ฉ”๋ผ ํšŒ์ „)
    • hand input ์‹œ๋ฎฌ : space ๋ˆ„๋ฆ„(์˜ค๋ฅธ์† ํ™œ์„ฑํ™”), ์™ผ์ชฝ shift ๋ˆ„๋ฆ„(์™ผ์† ํ™œ์„ฑํ™”) => ๋งˆ์šฐ์Šค๋กœ ์›€์ง์ž„)
      ๋งˆ์šฐ์Šค ํœ (์†์˜ ๊นŠ์ด), ๋งˆ์šฐ์Šค ์™ผ์ชฝ (ํ•€์น˜ ์ œ์Šค์ฒ˜), T/Y (๋ทฐ์— ์† ๋งŒ๋“ค๊ธฐ), CTRL ๋ˆ„๋ฆ„ + ๋งˆ์šฐ์Šค์ด๋™ (์† ํšŒ์ „)

     

    7) Exercise - Add hand interaction with object manipulator

    <Add a cube to the scene>

    • Cube๋ฅผ ์†์œผ๋กœ ์กฐ์ž‘ํ•ด๋ณด์ž!
    • cube ์ƒ์„ฑ : GameObject -> 3D Object -> Cube
    • cube ์œ„์น˜ : position (0, -0.1, 0.5), rotation (0, 0, 0), scale (0.1, 0.1, 0.1)
    • Add Component์— Object manipulator, NearInteractionGrabbable ์„ ์ถ”๊ฐ€ (์ƒํ˜ธ์ž‘์šฉ์„ ์œ„ํ•จ)
    • Play button์„ ๋ˆŒ๋Ÿฌ ์‹œ๋ฎฌ๋ ˆ์ด์…˜

     

    <Build HoloLens2>

    • ๋จผ์ € Unity project๋ฅผ build ํ•ด์•ผ ํ•จ.
    • File -> Build settings -> add open scenes -> build
    • ์ €์žฅ์œ„์น˜ ์ง€์ •ํ•˜๊ณ , ์„ ํƒ (๊ทธ๋Ÿฌ๋ฉด build ๋จ)

     

    • ๊ทธ ํ›„ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋นŒ๋“œ ๋ฐ ๋ฐฐํฌ
    • buildํ•œ project๋ฅผ visual studio์—์„œ ์—ด๊ณ  master/release, ARM64๋ฅผ ์„ ํƒ.
    • hololens๋ฅผ ์ปดํ“จํ„ฐ์— ์—ฐ๊ฒฐํ•œ ํ›„ debug -> start without debugging. (๊ทธ๋Ÿผ ์–ดํ”Œ์ด ์ž๋™์‹œ์ž‘๋จ.)

     

    ๋Œ“๊ธ€