Unity/AR

03. ARCore - ๋ฐ”๋‹ฅ ์ธ์‹, ์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ

๐Ÿ”ถ ๋ฐ”๋‹ฅ ์ธ์‹

- ๋นˆ ๊ฒŒ์ž„ ์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ : PlaneVisualizer

- ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€

    - Detected Plane Generator

- DetectedPlaneVisualizer ์—ฐ๊ฒฐ

 

 

 

- build & run

- ๋ฐ”๋‹ฅ์œผ๋กœ ์ธ์‹ํ•œ ๊ณณ์— ํฐ์ƒ‰์œผ๋กœ ํด๋ฆฌ๊ณค์ด ์ƒ๊ธฐ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Œ

 

 

 

๐Ÿ”ถ ํ„ฐ์น˜ ์‹œ ์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ

- ๋นˆ ๊ฒŒ์ž„ ์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ : TouchMgr

- ์Šคํฌ๋ฆฝํŠธ ์ƒ์„ฑ : TouchMgr

- ์Šคํฌ๋ฆฝํŠธ ๋„ฃ๊ธฐ

 

 

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleARCore;

public class TouchMgr : MonoBehaviour
{
    private Camera arCamera;
    // ์ƒ์„ฑํ•  ์บ๋ฆญํ„ฐ
    public GameObject monster;

    private TrackableHit hit;

    void Start()
    {
        arCamera = Camera.main;
    }

    void Update()
    {
        if (Input.touchCount == 0) return;

        Touch touch = Input.GetTouch(0);

        TrackableHitFlags filter = TrackableHitFlags.Default;
        if (touch.phase == TouchPhase.Began && Frame.Raycast(touch.position.x, touch.position.y, filter, out hit))
        {
            var anchor = hit.Trackable.CreateAnchor(hit.Pose);
            Instantiate(monster, hit.Pose.position, hit.Pose.rotation, anchor.transform);
        }
    }
}

- filter : ๊ฒ€์ถœ ๋Œ€์ƒ. ๋ ˆ์ด์–ด์™€ ๋น„์Šทํ•œ ์“ฐ์ž„์ƒˆ

- Anchor : ์œ„์น˜๊ฐ€ ๋ณ€ํ•˜์ง€ ์•Š๋Š” ๊ฐ์ฒด

 

 

 

- ์ƒ์„ฑํ•  ์˜ค๋ธŒ์ ํŠธ์˜ ์Šค์ผ€์ผ ์กฐ์ ˆ

    - 10cm๋กœ ์„ค์ •ํ•จ

 

 

 

- monster ํ”„๋ฆฌํŒนํ™”

- ํ•˜์ด์–ด๋ผํ‚ค ์ฐฝ์—์„œ monster ์‚ญ

- TouchMgr์— ํ”„๋ฆฌํŒน ์—ฐ๊ฒฐ

 

 

 

- build & run

- plane์ด ๊น”๋ฆฐ ์œ„์น˜๋ฅผ ํ„ฐ์น˜ํ•ด๋ณด๋ฉด ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์ƒ์„ฑ๋จ

'Unity > AR' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

06. ARCore - ์ž ๋งŒ๋“ค๊ธฐ  (0) 2021.09.15
05. ARCore - Face Tracking  (0) 2021.09.14
04. ARCore - ๋กœ๊ทธ์บฃ  (0) 2021.09.12
02. ARCore - Feature point ์‹œ๊ฐํ™”  (0) 2021.09.09
01. ARCore - ์„ค์น˜  (0) 2021.09.07