public new void Awake() { base.Awake(); if (SpatialMappingCollider == null) { SpatialMappingCollider = FindObjectOfType <SpatialMappingCollider>(); if (SpatialMappingCollider == null) { SpatialMappingCollider = gameObject.AddComponent <SpatialMappingCollider>(); } } if (SpatialMappingRenderer == null) { SpatialMappingRenderer = FindObjectOfType <SpatialMappingRenderer>(); if (SpatialMappingRenderer == null) { SpatialMappingRenderer = gameObject.AddComponent <SpatialMappingRenderer>(); } } VisualizeSpatialMesh = visualizeSpatialMesh; }
public void Begin() { mApplicationManager = GameObject.FindObjectOfType <cApplicationManager>(); //Get the manager if (mRenderer == null) { mRenderer = GameObject.FindObjectOfType <SpatialMappingRenderer>(); } if (mCollider == null) { mCollider = GameObject.FindObjectOfType <SpatialMappingCollider>(); } mRenderer.enabled = true; //Default to active and unfrozen mRenderer.freezeUpdates = false; mCollider.enabled = true; mCollider.freezeUpdates = false; mUIManager = GameObject.FindObjectOfType <cUIManager>(); //Get the UI Manager mUIManager.UpdateUI(UI_STRINGS[0]); //Set the UI text to the first string gestureRecognizer = new GestureRecognizer(); //Setup Gesture Recognizer gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap); gestureRecognizer.TappedEvent += GestureRecognizer_TappedEvent; gestureRecognizer.StartCapturingGestures(); }
// Use this for initialization void Start() { col = GetComponent <SpatialMappingCollider>(); rend = GetComponent <SpatialMappingRenderer>(); active = true; occlu = true; }
public CursorLocator(Transform holoLens) { _holoLens = holoLens; #if UNITY_WSA _collider = Camera.main.gameObject.AddComponent <SpatialMappingCollider>(); #endif HEVS.Configuration.OnPreUpdate += Update; }
void Start() // au lancement { spatialMappingRenderer = gameObject.GetComponent <SpatialMappingRenderer>(); // récupération du renderer natif associé au spatial mapping spatialMappingRenderer.surfaceParent = this.gameObject; spatialMappingCollider = gameObject.GetComponent <SpatialMappingCollider>(); // récupération du collider natif associé au spatial mapping spatialMappingCollider.surfaceParent = this.gameObject; spatialMappingCollider.layer = physicsLayer; PhysicsRaycastMask = 1 << physicsLayer; DrawVisualMeshes = drawVisualMeshes; MappingEnabled = mappingEnabled; }
// Use this for initialization void Start() { spatialMappingRenderer = gameObject.GetComponent <SpatialMappingRenderer>(); spatialMappingRenderer.surfaceParent = this.gameObject; spatialMappingCollider = gameObject.GetComponent <SpatialMappingCollider>(); spatialMappingCollider.surfaceParent = this.gameObject; spatialMappingCollider.layer = physicsLayer; PhysicsRaycastMask = 1 << physicsLayer; DrawVisualMeshes = drawVisualMeshes; MappingEnabled = mappingEnabled; }
/// <summary> /// Runs at initialization right after Awake method /// </summary> void Start() { // Initialize and configure the collider spatialMappingCollider = gameObject.GetComponent <SpatialMappingCollider>(); spatialMappingCollider.surfaceParent = this.gameObject; spatialMappingCollider.freezeUpdates = false; spatialMappingCollider.layer = physicsLayer; // define the mask PhysicsRaycastMask = 1 << physicsLayer; // set the object as active one gameObject.SetActive(true); }
// Use this for initialization void Start() { spatialMappingCollider = gameObject.GetComponent <SpatialMappingCollider>(); //禁用流动更新,使物理环境更稳定 spatialMappingCollider.freezeUpdates = false; spatialMappingCollider.surfaceParent = this.gameObject; //仅31物理layer发生碰撞 spatialMappingCollider.layer = physicsLayer; //只检测physicsLayer PhysicsRaycastMask = 1 << physicsLayer; gameObject.SetActive(true); }
// Use this for initialization void Start() { mappingCollider = GetComponent <SpatialMappingCollider>(); mappingRenderer = GetComponent <SpatialMappingRenderer>(); if (mappingRenderer == null || mappingCollider == null) { Debug.Log("Spatial mapping components are misconfigured"); Destroy(this.gameObject); } if (autoStart) { StartScanning(); } }
void OnEnable() { _collider = target as SpatialMappingCollider; }
void Start() { SpatialMappingCollider collider = gameObject.GetComponent <SpatialMappingCollider>(); collider.layer = SpatialMappingLayer; }
void makePhysical() { if (clickCount == 0) { Debug.Log("click to disable updates"); GameObject temp0 = GameObject.FindGameObjectWithTag("SpatialMap"); SpatialMappingCollider SMC = temp0.GetComponent <SpatialMappingCollider>(); SMC.freezeUpdates = true; SpatialMappingManager.Instance.StopObserver(); StatusText.text = "Spatial Mapping finalised, tap to finalise object placement"; } else if (clickCount == 1) { //SurfaceMeshesToPlanes Debug.Log("Requested to make physically interactable"); //IsPhysical = true; //SpatialUnderstanding.Instance.RequestFinishScan(); foreach (GameObject temp in GameObject.FindGameObjectsWithTag("Targets")) { temp.SetActive(false); } foreach (GameObject temp in GameObject.FindGameObjectsWithTag("PhysicalModel")) { //Rigidbody RB = temp.AddComponent<Rigidbody>(); Rigidbody RB = temp.GetComponent <Rigidbody>(); RB.useGravity = true; RB.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation; //RB.isKinematic = true; } StatusText.text = "Object Placement finalised, tap to make interactable"; } else if (clickCount == 2) { //SurfaceMeshesToPlanes Debug.Log("Requested to make physically interactable"); IsPhysical = true; //SpatialUnderstanding.Instance.RequestFinishScan(); //foreach (GameObject temp in GameObject.FindGameObjectsWithTag("Targets")) //{ // temp.SetActive(false); //} foreach (GameObject temp in GameObject.FindGameObjectsWithTag("PhysicalModel")) { //Rigidbody RB = temp.AddComponent<Rigidbody>(); Rigidbody RB = temp.GetComponent <Rigidbody>(); RB.constraints = RigidbodyConstraints.None; //RB.isKinematic = true; } StatusText.text = "Interaction Enabled"; } //foreach (GameObject temp in DefaultTrackableEventHandler.PhysicalObjectArray) //{ // Rigidbody RB = temp.GetComponent<Rigidbody>(); // RB.useGravity = true; // //MeshCollider MC = temp.AddComponent<MeshCollider>(); // //MC.sharedMesh = Mesh. //} //add spatial mapping freeze update to click 1 and rest to click 2 }
// Use this for initialization void Start() { spatialMappingRenderer = gameObject.GetComponent<SpatialMappingRenderer>(); spatialMappingRenderer.surfaceParent = this.gameObject; spatialMappingCollider = gameObject.GetComponent<SpatialMappingCollider>(); spatialMappingCollider.surfaceParent = this.gameObject; spatialMappingCollider.layer = physicsLayer; PhysicsRaycastMask = 1 << physicsLayer; DrawVisualMeshes = drawVisualMeshes; MappingEnabled = mappingEnabled; }
void OnDestroy() { // remove event handlers if (isInitialized) { isInitialized = false; WorldManager.OnPositionalLocatorStateChanged -= WorldManager_OnPositionalLocatorStateChanged; if (surfaceRootTransform) { Destroy(surfaceRootTransform.gameObject); surfaceRootTransform = null; surfaceRenderer = null; } if (surfaceCollider) { Destroy(surfaceCollider.gameObject); surfaceCollider = null; } if (gestureRecognizer != null) { gestureRecognizer.StopCapturingGestures(); gestureRecognizer.Tapped -= GestureRecognizer_Tapped; // gestureRecognizer.HoldStarted -= GestureRecognizer_HoldStarted; // gestureRecognizer.HoldCompleted -= GestureRecognizer_HoldCompleted; // gestureRecognizer.HoldCanceled -= GestureRecognizer_HoldCanceled; gestureRecognizer.NavigationStarted -= GestureRecognizer_NavigationStarted; gestureRecognizer.NavigationUpdated -= GestureRecognizer_NavigationUpdated; gestureRecognizer.NavigationCompleted -= GestureRecognizer_NavigationCompleted; gestureRecognizer.NavigationCanceled -= GestureRecognizer_NavigationCanceled; } //if(isDisplayOpaque) { // stop interaction manager // InteractionManager.InteractionSourcePressed -= InteractionManager_InteractionSourcePressed; // InteractionManager.InteractionSourceUpdated -= InteractionManager_InteractionSourceUpdated; // InteractionManager.InteractionSourceReleased -= InteractionManager_InteractionSourceReleased; InteractionManager.InteractionSourceDetected -= InteractionManager_InteractionSourceDetected; InteractionManager.InteractionSourceLost -= InteractionManager_InteractionSourceLost; InteractionManager.InteractionSourceUpdated -= InteractionManager_InteractionSourceUpdated; } if (arManager) { // get arData-reference MultiARInterop.MultiARData arData = arManager.GetARData(); // destroy all world anchors foreach (string anchorId in arData.allAnchorsDict.Keys) { // remove the anchor from the system GameObject anchorObj = GameObject.Find(anchorId); if (anchorObj) { WorldAnchor anchor = anchorObj.GetComponent <WorldAnchor>(); if (anchor) { anchor.OnTrackingChanged -= Anchor_OnTrackingChanged; Destroy(anchor); } } Destroy(anchorObj); } // clear the list arData.allAnchorsDict.Clear(); } } }
// -- // -- // -- // -- // -- // -- // -- // -- // -- // -- // void Start() { if (!isInterfaceEnabled) { return; } // determine if display is opaque or transparent isDisplayOpaque = HolographicSettings.IsDisplayOpaque; Debug.Log("Display: " + (isDisplayOpaque ? "Opaque" : "Transparent")); // modify the main camera in the scene Camera currentCamera = MultiARInterop.GetMainCamera(); if (!currentCamera) { GameObject currentCameraObj = new GameObject("Main Camera"); currentCameraObj.tag = "MainCamera"; currentCamera = currentCameraObj.AddComponent <Camera>(); } // reset camera position & rotation //currentCamera.transform.position = Vector3.zero; currentCamera.transform.rotation = Quaternion.identity; // set camera parameters currentCamera.clearFlags = CameraClearFlags.SolidColor; currentCamera.backgroundColor = new Color(0f, 0f, 0f, 0f); currentCamera.nearClipPlane = 0.5f; // HoloLens recommended currentCamera.farClipPlane = 100f; if (isDisplayOpaque) { currentCamera.clearFlags = CameraClearFlags.Skybox; } // set the fastest quality setting QualitySettings.SetQualityLevel((int)qualityLevel); Debug.Log("QualityLevel: " + QualitySettings.names[(int)qualityLevel]); // reference to the AR main camera mainCamera = currentCamera; // don't destroy the light between scenes DontDestroyOnLoad(currentCamera.gameObject); // // add camera parent // if(currentCamera.transform.parent == null) // { // GameObject cameraParent = new GameObject("CameraParent"); // currentCamera.transform.SetParent(cameraParent.transform); // } // modify the directional light Light currentLight = MultiARInterop.GetDirectionalLight(); if (!currentLight) { GameObject currentLightObj = new GameObject("Directional light"); currentLight = currentLightObj.AddComponent <Light>(); currentLight.type = LightType.Directional; } // reset light position & rotation currentLight.transform.position = Vector3.zero; currentLight.transform.rotation = Quaternion.Euler(40f, 40f, 0f); // set light parameters currentLight.color = new Color32(255, 254, 244, 255); // add the ar-light component //currentLight.gameObject.AddComponent<MultiARDirectionalLight>(); // reference to the AR directional light //directionalLight = currentLight; // don't destroy the light between scenes DontDestroyOnLoad(currentLight.gameObject); // there is no point cloud in WinMR MultiARInterop.MultiARData arData = arManager.GetARData(); // check for point cloud getter if (arManager.pointCloudPrefab != null) { arData.pointCloudData = new Vector3[0]; arData.pointCloudLength = 0; arData.pointCloudTimestamp = 0.0; } // set tracking state cameraTrackingState = WorldManager.state; WorldManager.OnPositionalLocatorStateChanged += WorldManager_OnPositionalLocatorStateChanged; // // set tracking space type // Debug.Log("Before: " + XRDevice.GetTrackingSpaceType()); // if(XRDevice.GetTrackingSpaceType() != TrackingSpaceType.Stationary) // { // if(!XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary)) // { // Debug.LogError("Cannot set stationary space type!"); // } // } // create gesture input if (!isDisplayOpaque) { gestureRecognizer = new GestureRecognizer(); gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap | GestureSettings.Hold | GestureSettings.NavigationX | GestureSettings.NavigationY | GestureSettings.NavigationZ); gestureRecognizer.Tapped += GestureRecognizer_Tapped; // gestureRecognizer.HoldStarted += GestureRecognizer_HoldStarted; // gestureRecognizer.HoldCompleted += GestureRecognizer_HoldCompleted; // gestureRecognizer.HoldCanceled += GestureRecognizer_HoldCanceled; gestureRecognizer.NavigationStarted += GestureRecognizer_NavigationStarted; gestureRecognizer.NavigationUpdated += GestureRecognizer_NavigationUpdated; gestureRecognizer.NavigationCompleted += GestureRecognizer_NavigationCompleted; gestureRecognizer.NavigationCanceled += GestureRecognizer_NavigationCanceled; gestureRecognizer.StartCapturingGestures(); Debug.Log("Gesture recognizer inited and started."); } //else { // init interaction manager // InteractionManager.InteractionSourcePressed += InteractionManager_InteractionSourcePressed; // InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated; // InteractionManager.InteractionSourceReleased += InteractionManager_InteractionSourceReleased; InteractionManager.InteractionSourceDetected += InteractionManager_InteractionSourceDetected; InteractionManager.InteractionSourceLost += InteractionManager_InteractionSourceLost; InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated; Debug.Log("Interaction manager inited."); } // create surface renderer if (arManager.useOverlaySurface != MultiARManager.SurfaceRenderEnum.None) { GameObject objRenderer = new GameObject(); objRenderer.name = "SurfaceRenderer"; objRenderer.layer = MultiARInterop.GetSurfaceLayer(); arData.surfaceRendererRoot = objRenderer; surfaceRootTransform = objRenderer.transform; DontDestroyOnLoad(objRenderer); if (!isDisplayOpaque) { // hololens surfaceRenderer = objRenderer.AddComponent <SpatialMappingRenderer>(); surfaceRenderer.surfaceParent = objRenderer; switch (arManager.useOverlaySurface) { case MultiARManager.SurfaceRenderEnum.None: surfaceRenderer.renderState = SpatialMappingRenderer.RenderState.None; break; case MultiARManager.SurfaceRenderEnum.Visualization: surfaceRenderer.renderState = SpatialMappingRenderer.RenderState.Visualization; break; case MultiARManager.SurfaceRenderEnum.Occlusion: case MultiARManager.SurfaceRenderEnum.OcclusionWithShadows: surfaceRenderer.renderState = SpatialMappingRenderer.RenderState.Occlusion; break; } if (arManager.useOverlaySurface != MultiARManager.SurfaceRenderEnum.None) { surfaceRenderer.visualMaterial = arManager.surfaceVisualizationMaterial; surfaceRenderer.occlusionMaterial = arManager.useOverlaySurface == MultiARManager.SurfaceRenderEnum.OcclusionWithShadows ? arManager.surfaceOcclusionWithShadowsMaterial : arManager.surfaceOcclusionMaterial; } } else { // use special surface material on opaque displays Material visualMaterial = arManager.GetSurfaceMaterial(); if (arManager.useOverlaySurface == MultiARManager.SurfaceRenderEnum.Visualization && vrSurfaceMaterial) { visualMaterial = vrSurfaceMaterial; } // mr headsets CreateBoundaryPlane(objRenderer.transform, visualMaterial, arManager.surfaceCollider, arManager.colliderMaterial); boundaryMgr = objRenderer.AddComponent <HoloToolkit.Unity.Boundary.BoundaryManager>(); boundaryMgr.FloorQuad = boundaryPlane; boundaryMgr.AwakeBoundaryManager(); } } // create surface collider if (arManager.surfaceCollider) { GameObject objCollider = new GameObject(); objCollider.name = "SurfaceCollider"; objCollider.layer = MultiARInterop.GetSurfaceLayer(); DontDestroyOnLoad(objCollider); if (!isDisplayOpaque) { // hololens surfaceCollider = objCollider.AddComponent <SpatialMappingCollider>(); surfaceCollider.surfaceParent = objCollider; surfaceCollider.lodType = SpatialMappingBase.LODType.Low; surfaceCollider.layer = MultiARInterop.GetSurfaceLayer(); if (arManager.colliderMaterial) { surfaceCollider.material = arManager.colliderMaterial; } } else { // mr headsets if (boundaryPlane == null) { // there was no boundary rendering CreateBoundaryPlane(objCollider.transform, null, true, arManager.colliderMaterial); boundaryMgr = objCollider.AddComponent <HoloToolkit.Unity.Boundary.BoundaryManager>(); boundaryMgr.FloorQuad = boundaryPlane; boundaryMgr.AwakeBoundaryManager(); } } } // // if camera is too near to the floor, lower the floor 1.5 meter below the camera // if(currentCamera && boundaryMgr) // { // if(currentCamera.transform.position.y < 0.1f) // { // boundaryMgr.CurrentFloorHeightOffset = currentCamera.transform.position.y - 1.5f; // Debug.Log(string.Format("FloorHeightOffset set below the camera at {0:F2}m.", boundaryMgr.CurrentFloorHeightOffset)); // } // } // starts co-routine to check rendered surfaces StartCoroutine(CheckSurfacesRoutine()); Debug.Log("TrackingSpaceType: " + XRDevice.GetTrackingSpaceType()); Debug.Log("Screen size: " + Screen.width + " x " + Screen.height); int surfaceLayer = MultiARInterop.GetSurfaceLayer(); // LayerMask.NameToLayer("SpatialSurface"); Debug.Log("SpatialSurfaceLayer: " + surfaceLayer); // interface is initialized isInitialized = true; }
void OnEnable() { _collider = target as SpatialMappingCollider; }
protected override void Awake() { base.Awake(); #if !UNITY_EDITOR if (Windows.Graphics.Holographic.HolographicDisplay.GetDefault()?.IsOpaque == false) { transform.ClearChildren(); } #endif var gr = this.Ensure <SpatialMappingRenderer>(); gr.Value.occlusionMaterial = OcclusionMaterial; gr.Value.visualMaterial = VisualizationMaterial; var gc = this.Ensure <SpatialMappingCollider>(); gCollider = gc; gRenderer = gr; if (gc.IsNew) { gc.Value.enableCollisions = true; gc.Value.layer = GroundLayer; gc.Value.material = Roughness; if (gr.IsNew) { gc.Value.surfaceParent = surfaceParent; gc.Value.freezeUpdates = freezeUpdates; gc.Value.secondsBetweenUpdates = secondsBetweenSpatialMappingUpdates; gc.Value.numUpdatesBeforeRemoval = updateCountBeforeSpatialMappingCleanup; gc.Value.lodType = LODType; gc.Value.volumeType = volumeType; gc.Value.halfBoxExtents = HalfBoxExtents; } else { gc.Value.surfaceParent = gr.Value.surfaceParent; gc.Value.freezeUpdates = gr.Value.freezeUpdates; gc.Value.secondsBetweenUpdates = gr.Value.secondsBetweenUpdates; gc.Value.numUpdatesBeforeRemoval = gr.Value.numUpdatesBeforeRemoval; gc.Value.lodType = gr.Value.lodType; gc.Value.volumeType = gr.Value.volumeType; gc.Value.halfBoxExtents = gr.Value.halfBoxExtents; } } gr.Value.surfaceParent = gc.Value.surfaceParent; gr.Value.freezeUpdates = gc.Value.freezeUpdates; gr.Value.secondsBetweenUpdates = gc.Value.secondsBetweenUpdates; gr.Value.numUpdatesBeforeRemoval = gc.Value.numUpdatesBeforeRemoval; gr.Value.lodType = gc.Value.lodType; gr.Value.volumeType = gc.Value.volumeType; gr.Value.halfBoxExtents = gc.Value.halfBoxExtents; lastSurfaceParent = surfaceParent; lastUpdateCount = updateCountBeforeSpatialMappingCleanup; lastUpdateTime = secondsBetweenSpatialMappingUpdates; lastFreezeUpdates = freezeUpdates; lastHalfBox = HalfBoxExtents; lastLODType = LODType; lastVolumeType = volumeType; }
// -- // -- // -- // -- // -- // -- // -- // -- // -- // -- // void Start() { if (!isInterfaceEnabled) { return; } if (!metaCameraRigPrefab) { Debug.LogError("Meta2-interface cannot start: MetaCameraRig-prefab is not set."); return; } // disable the main camera, if any Camera currentCamera = MultiARInterop.GetMainCamera(); if (currentCamera) { currentCamera.gameObject.SetActive(false); } // create ARCore-Device in the scene GameObject arCoreDeviceObj = Instantiate(metaCameraRigPrefab, Vector3.zero, Quaternion.identity); arCoreDeviceObj.name = "ARCore Device"; DontDestroyOnLoad(arCoreDeviceObj); // reference to the AR main camera mainCamera = arCoreDeviceObj.GetComponentInChildren <Camera>(); // // add camera parent // if(currentCamera.transform.parent == null) // { // GameObject cameraParent = new GameObject("CameraParent"); // currentCamera.transform.SetParent(cameraParent.transform); // } // modify the directional light Light currentLight = MultiARInterop.GetDirectionalLight(); if (!currentLight) { GameObject currentLightObj = new GameObject("Directional light"); currentLight = currentLightObj.AddComponent <Light>(); currentLight.type = LightType.Directional; } // reset light position & rotation currentLight.transform.position = Vector3.zero; currentLight.transform.rotation = Quaternion.Euler(40f, 40f, 0f); // set light parameters currentLight.color = new Color32(255, 254, 244, 255); // add the ar-light component //currentLight.gameObject.AddComponent<MultiARDirectionalLight>(); // reference to the AR directional light //directionalLight = currentLight; // don't destroy the light between scenes DontDestroyOnLoad(currentLight.gameObject); // there is no point cloud in WinMR MultiARInterop.MultiARData arData = arManager.GetARData(); // check for point cloud getter if (arManager.pointCloudPrefab != null) { arData.pointCloudData = new Vector3[0]; arData.pointCloudLength = 0; arData.pointCloudTimestamp = 0.0; } // set tracking state cameraTrackingState = WorldManager.state; WorldManager.OnPositionalLocatorStateChanged += WorldManager_OnPositionalLocatorStateChanged; // // set tracking space type // Debug.Log("Before: " + XRDevice.GetTrackingSpaceType()); // if(XRDevice.GetTrackingSpaceType() != TrackingSpaceType.Stationary) // { // if(!XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary)) // { // Debug.LogError("Cannot set stationary space type!"); // } // } // create gesture input if (!isDisplayOpaque) { gestureRecognizer = new GestureRecognizer(); gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap | GestureSettings.Hold | GestureSettings.NavigationX | GestureSettings.NavigationY | GestureSettings.NavigationZ); gestureRecognizer.Tapped += GestureRecognizer_Tapped; // gestureRecognizer.HoldStarted += GestureRecognizer_HoldStarted; // gestureRecognizer.HoldCompleted += GestureRecognizer_HoldCompleted; // gestureRecognizer.HoldCanceled += GestureRecognizer_HoldCanceled; gestureRecognizer.NavigationStarted += GestureRecognizer_NavigationStarted; gestureRecognizer.NavigationUpdated += GestureRecognizer_NavigationUpdated; gestureRecognizer.NavigationCompleted += GestureRecognizer_NavigationCompleted; gestureRecognizer.NavigationCanceled += GestureRecognizer_NavigationCanceled; gestureRecognizer.StartCapturingGestures(); Debug.Log("Gesture recognizer inited and started."); } else { InteractionManager.InteractionSourcePressed += InteractionManager_InteractionSourcePressed; InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated; InteractionManager.InteractionSourceReleased += InteractionManager_InteractionSourceReleased; Debug.Log("Interaction manager inited."); } // create surface renderer if (arManager.useOverlaySurface != MultiARManager.SurfaceRenderEnum.None) { GameObject objRenderer = new GameObject(); objRenderer.name = "SurfaceRenderer"; objRenderer.layer = MultiARInterop.GetSurfaceLayer(); arData.surfaceRendererRoot = objRenderer; surfaceRootTransform = objRenderer.transform; DontDestroyOnLoad(objRenderer); if (!isDisplayOpaque) { // hololens surfaceRenderer = objRenderer.AddComponent <SpatialMappingRenderer>(); surfaceRenderer.surfaceParent = objRenderer; surfaceRenderer.renderState = (SpatialMappingRenderer.RenderState)arManager.useOverlaySurface; if (arManager.useOverlaySurface != MultiARManager.SurfaceRenderEnum.None) { surfaceRenderer.visualMaterial = arManager.surfaceVisualizationMaterial; surfaceRenderer.occlusionMaterial = arManager.surfaceOcclusionMaterial; } } else { // mr headsets CreateBoundaryPlane(objRenderer.transform, arManager.GetSurfaceMaterial(), arManager.surfaceCollider, arManager.colliderMaterial); boundaryMgr = objRenderer.AddComponent <HoloToolkit.Unity.Boundary.BoundaryManager>(); boundaryMgr.FloorQuad = boundaryPlane; boundaryMgr.AwakeBoundaryManager(); } } // create surface collider if (arManager.surfaceCollider) { GameObject objCollider = new GameObject(); objCollider.name = "SurfaceCollider"; objCollider.layer = MultiARInterop.GetSurfaceLayer(); DontDestroyOnLoad(objCollider); if (!isDisplayOpaque) { // hololens surfaceCollider = objCollider.AddComponent <SpatialMappingCollider>(); surfaceCollider.surfaceParent = objCollider; surfaceCollider.lodType = SpatialMappingBase.LODType.Low; surfaceCollider.layer = MultiARInterop.GetSurfaceLayer(); if (arManager.colliderMaterial) { surfaceCollider.material = arManager.colliderMaterial; } } else { // mr headsets if (boundaryPlane == null) { // there was no boundary rendering CreateBoundaryPlane(objCollider.transform, null, true, arManager.colliderMaterial); boundaryMgr = objCollider.AddComponent <HoloToolkit.Unity.Boundary.BoundaryManager>(); boundaryMgr.FloorQuad = boundaryPlane; boundaryMgr.AwakeBoundaryManager(); } } } // // if camera is too near to the floor, lower the floor 1.5 meter below the camera // if(currentCamera && boundaryMgr) // { // if(currentCamera.transform.position.y < 0.1f) // { // boundaryMgr.CurrentFloorHeightOffset = currentCamera.transform.position.y - 1.5f; // Debug.Log(string.Format("FloorHeightOffset set below the camera at {0:F2}m.", boundaryMgr.CurrentFloorHeightOffset)); // } // } // starts co-routine to check rendered surfaces StartCoroutine(CheckSurfacesRoutine()); Debug.Log("TrackingSpaceType: " + XRDevice.GetTrackingSpaceType()); Debug.Log("Screen size: " + Screen.width + " x " + Screen.height); int surfaceLayer = MultiARInterop.GetSurfaceLayer(); // LayerMask.NameToLayer("SpatialSurface"); Debug.Log("SpatialSurfaceLayer: " + surfaceLayer); // interface is initialized isInitialized = true; }