private void _DrawPlane() { newPlanes.Clear(); ARFrame.GetTrackables <ARPlane>(newPlanes, ARTrackableQueryFilter.NEW); for (int i = 0; i < newPlanes.Count; i++) { GameObject planeObject = Instantiate(planePrefabs, Vector3.zero, Quaternion.identity, transform); planeObject.GetComponent <TrackedPlaneVisualizer>().Initialize(newPlanes[i]); } }
private void _DrawHand() { newHands.Clear(); ARFrame.GetTrackables <ARHand>(newHands, ARTrackableQueryFilter.NEW); for (int i = 0; i < newHands.Count; i++) { GameObject handObject = Instantiate(handPrefabs, Vector3.zero, Quaternion.identity, transform); handObject.GetComponent <HandVisualizer>().Initialize(newHands[i]); } }
private void _DrawFace() { m_newFaces.Clear(); ARFrame.GetTrackables <ARFace>(m_newFaces, ARTrackableQueryFilter.NEW); for (int i = 0; i < m_newFaces.Count; i++) { GameObject faceObject = Instantiate(facePrefabs, Vector3.zero, Quaternion.identity, transform); faceObject.GetComponent <FaceVisualizer>().Initialize(m_newFaces[i]); } }
private void _DrawBody() { newBodys.Clear(); ARFrame.GetTrackables <ARBody>(newBodys, ARTrackableQueryFilter.NEW); for (int i = 0; i < newBodys.Count; i++) { GameObject planeObject = Instantiate(bodyPrefabs, Vector3.zero, Quaternion.identity, transform); planeObject.GetComponent <BodySkeletonVisualizer>().Initialize(newBodys[i]); } }
public void Update() { // Exit the app when the 'back' button is pressed. if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } // Check that motion tracking is tracking. if (ARFrame.GetTrackingState() != ARTrackable.TrackingState.TRACKING) { ARDebug.LogInfo("GetTrackingState no tracing return <<"); return; } // Get updated augmented images for this frame. ARFrame.GetTrackables <ARAugmentedImage>(m_TempAugmentedImages, ARTrackableQueryFilter.UPDATED); ARDebug.LogInfo("m_TempAugmentedImages size {0}", m_TempAugmentedImages.Count); // Create visualizers and anchors for updated augmented images that are tracking and do not previously // have a visualizer. Remove visualizers for stopped images. foreach (var image in m_TempAugmentedImages) { AugmentedImageVisualizer visualizer = null; m_Visualizers.TryGetValue(image.GetDataBaseIndex(), out visualizer); ARDebug.LogInfo("GetTrackingState {0}", image.GetTrackingState()); if (image.GetTrackingState() == ARTrackable.TrackingState.TRACKING && visualizer != null) { visualizer.Image = image; ARDebug.LogInfo("update position {0} rotation {1}", image.GetCenterPose().position, image.GetCenterPose().rotation); } if (image.GetTrackingState() == ARTrackable.TrackingState.TRACKING && visualizer == null) { // Create an anchor to ensure that ARCore keeps tracking this augmented image. //ARAnchor anchor = image.CreateAnchor(image.GetCenterPose()); //visualizer = (AugmentedImageVisualizer)Instantiate(AugmentedImageVisualizerPrefab, anchor.GetPose().position, anchor.GetPose().rotation); visualizer = (AugmentedImageVisualizer)Instantiate(AugmentedImageVisualizerPrefab, image.GetCenterPose().position, image.GetCenterPose().rotation); ARDebug.LogInfo("create position {0} rotation {1}", image.GetCenterPose().position, image.GetCenterPose().rotation); visualizer.Image = image; m_Visualizers.Add(image.GetDataBaseIndex(), visualizer); } else if (image.GetTrackingState() == ARTrackable.TrackingState.STOPPED && visualizer != null) { m_Visualizers.Remove(image.GetDataBaseIndex()); GameObject.Destroy(visualizer.gameObject); } } // Show the fit-to-scan overlay if there are no images that are Tracking. foreach (var visualizer in m_Visualizers.Values) { if (visualizer.Image.GetTrackingState() == ARTrackable.TrackingState.TRACKING) { FitToScanOverlay.SetActive(false); return; } } //FitToScanOverlay.SetActive(true); }