ã¯ããã«
ã©ãããåéã§ãã
å æ¥ãMeta XR SDKã®MRæ©è½ããã±ã¼ã¸ã§ããMRUK(Mixed Reality Utility Kit)ã«ã¢ãããã¼ããæ¥ã¾ããã é¢ç½ãããªæ©è½ãããã¤ã追å ããã¦ããã®ã§ãã£ã¦ã¿ã¾ããã
âãªãªã¼ã¹ãã¼ã
Environment Raycast Manager
é¨å±ã«å¯¾ããRaycastãè¡ããããã«ãã¾ãã
空ã®ãªãã¸ã§ã¯ããä½æããEnvironment Raycast Managerã追å ãã¾ãã
ããã使ãããã®ã³ã¼ããæ¸ãã¦ããã¾ãã
using Meta.XR; using UnityEngine; public class SceneRaycastTest : MonoBehaviour { [SerializeField] private EnvironmentRaycastManager _raycastManager; [SerializeField] private Transform originTransform; [SerializeField] private GameObject pointer; private Ray _ray; private void Start() { _ray = new Ray(originTransform.position, originTransform.forward); } private void Update() { _ray.origin = originTransform.position; _ray.direction = originTransform.forward; if (_raycastManager.Raycast(_ray, out var hit)) { if (hit.status == EnvironmentRaycastHitStatus.Hit) { //Debug.Log($"hit: {hit.point}, {hit.normal}"); pointer.transform.position = hit.point; pointer.transform.rotation = Quaternion.LookRotation(hit.normal); } } } }
使ãæ¹ã¯å¤§ä½ãé常ã®Raycastã¨åãã§ãã
ä»åã¯æããRayãé£ã°ãã¦ã¾ãã
Raycastãã¦é¨å±ã®ã¡ãã·ã¥ã«Rayãå½ãã㨠EnvironmentRaycastHit
ãåå¾ã§ããã®ã§ããããããããä½ç½®ã®3次å
座æ¨ã¨ãããå¹³é¢ã¨ã®æ³ç·ãã¯ãã«ãªã©ãåå¾ã§ãã¾ãã
EnvironmentRaycastHitStatus
ã§Raycastã¹ãã¼ã¿ã¹æ
å ±ãåå¾ã§ãã¾ãã
å ¬å¼ããã¥ã¡ã³ãã¯ãã¡ã
Destructible Global Mesh
ç ´å£å¯è½ãªé¨å±ã®ã¡ãã·ã¥ãã¼ã¿ãæ±ããããã«ãªãã¾ããã
空ã®ãªãã¸ã§ã¯ãã«Destructible Global Mesh Spawnerã追å ãã¾ãã
Global Mesh Materialã«ãããªã¢ã«ãæå®ãããã¨ã§Global Meshãå¯è¦åã§ãã¾ãã
â» Meta XR Simulatorã使ç¨ãããã¨ã§ãã«ãããã«é¨å±ã®ã¡ãã·ã¥ã®ãã¹ããã§ãã¾ãã
åçããã¨GlobalMeshã®åãªãã¸ã§ã¯ãã«Destructible Global Mesh Segmentãçæããã¦ããã®ã確èªã§ãã¾ãã
ãããGlobal Meshãåå²ãããã¡ãã·ã¥ã§ãããããæ¶ããã¨ã§ãç¾å®ã®å£ãç ´å£ãããã®ãããªè¡¨ç¾ãä½ãã¾ãã
å ç¨ã®Environment Raycastã¨çµã¿åããã¦ãæãããå£ãç ´å£ãã表ç¾ãä½ã£ã¦ã¿ã¾ãã
âåå²ãããã¡ãã·ã¥ãåå¾ãã¦ãMeshColliderã追å ãã¦ãã¾ãã
using Meta.XR.MRUtilityKit; using UnityEngine; public class DestructibleGlobalMeshTest : MonoBehaviour { [SerializeField] private MRUK mruk; [SerializeField] private DestructibleGlobalMeshSpawner _globalMeshSpawner; private void Start() { _globalMeshSpawner.OnDestructibleMeshCreated.AddListener(_ => { Debug.Log("mesh created"); MRUKRoom room = mruk.GetCurrentRoom(); if (_globalMeshSpawner.TryGetDestructibleMeshForRoom(room,out var globalMesh)) { Debug.Log($"mesh: {globalMesh.DestructibleMeshComponent.GetDestructibleMeshSegmentsCount()}"); foreach (var mesh in globalMesh.DestructibleMeshComponent.transform.GetComponentsInChildren<Transform>()) { if(mesh == globalMesh.DestructibleMeshComponent.transform)continue; mesh.gameObject.AddComponent<MeshCollider>(); } } }); } }
DestructibleMeshçææã«çºç«ãã OnDestructibleMeshCreated
ã®UnityEventãè³¼èªãã¦å®è¡ãã¦ãã¾ãã
TryGetDestructibleMeshForRoom
㧠DestructibleGlobalMesh
ãåå¾ããããã«çæãããåå²ã¡ãã·ã¥DestructibleMesh
ã®è¦ªãªãã¸ã§ã¯ãã§ããDestructibleMeshComponent
ãåå¾ãã¾ãã
â ãã¤ã³ã¿ã¼ãªãã¸ã§ã¯ãã«ã¢ã¿ããããã¹ã¯ãªãã
æããã³ãããã¨ç ´å£ããã
public class DestroyRoomMesh : MonoBehaviour { [SerializeField] private OVRHand _hand; private GameObject selectObject; private void Update() { if (_hand.GetFingerIsPinching(OVRHand.HandFinger.Index)) { if (selectObject==null) return; Debug.Log("Destroy"); selectObject.SetActive(false); } } private void OnTriggerEnter(Collider other) { Debug.Log("select: " + other.gameObject); selectObject = other.gameObject; } }
ç ´å£ãããå ã«ãã¼ãã£ã«ç©ºéãåºãæ¹æ³ã¯ä»¥ä¸ãã覧ãã ããã
ã¨ãããã¨ã§å®æãã¾ããã
å ¬å¼ããã¥ã¡ã³ãã¯ãã¡ã