Metaverse/Unity

Crescendor - HandTracking Transform API

onenewkong 2024. 1. 17. 17:52

이벤트가 발생하면, 사용자의 손의 위치를 반환하여 해당 위치로 오브젝트의 위치를 변경하려고 한다.

그러면 Hand 관련 API에서 Transform 정보를 받아와야했고, 그 정보는 OVRHand의 PointerPose였다.

또한, PointerPose에 사용자의 Hand Data를 대입하기 위해 OVRHand에 Tracked Pose Driver라는 컴포넌트가 필요했다. 

Tracked Pose Driver는 트래킹 대상 객체의 정보를 전달해주는 컴포넌트이다.

 

OVRPlugin과 OVRCommon에는 각각 HandState와 FromFlippedZVector3f() 가 명시되어 있다.

 

간단한 테스팅을 위해 다음과 같이 함수를 작성하여 UI 버튼 클릭 이벤트 발생 시 Note의 위치를 바꿔주었다.

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

public class Note : MonoBehaviour
{
    [SerializeField]
    GameObject note;

    public void Move(Vector3 HandPos)
    {
        note.transform.position = HandPos;
    }
}
using Oculus.Interaction;
using Oculus.Interaction.Input;
using Oculus.Interaction.PoseDetection;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine.XR.Interaction.Toolkit;

public class NoteMove : MonoBehaviour
{
    [SerializeField]
    Note note;

    [SerializeField]
    OVRHand ovrhand;
    Vector3 HandPos;
    
    public void HandPosition()
    {
        HandPos = ovrhand.PointerPose.transform.position;

        note.Move(HandPos);
    }
}

 

영상이 있는데, passthrough 모드라 미러링을 하면 배경이 날아가서 잘 안보일거다.. 

HandPosition.mp4
3.43MB

 

 

 

이렇게 Oculus 관련 모든 기능은 테스팅이 끝이 났고, 이걸 기반으로 본격적인 개발에 들어갈 예정이다.

'Metaverse > Unity' 카테고리의 다른 글

Crescendor - Scene Loading 구현  (0) 2024.04.13
OVRInput - 제스처 인식  (0) 2024.03.10
Crescendor - HandTracking, Interactor  (0) 2024.01.06
Crescendor - Android Build 관련 삽질  (1) 2024.01.04
RPG Project - Inventory  (0) 2023.10.14