public void Update() { if (null == m_anchor) { gameObject.SetActive(false); return; } switch (m_anchor.GetTrackingState()) { case ARTrackable.TrackingState.TRACKING: Pose p = m_anchor.GetPose(); gameObject.transform.position = p.position; gameObject.transform.rotation = p.rotation; gameObject.transform.Rotate(0f, 225f, 0f, Space.Self); gameObject.SetActive(true); break; case ARTrackable.TrackingState.PAUSED: gameObject.SetActive(false); break; case ARTrackable.TrackingState.STOPPED: default: gameObject.SetActive(false); Destroy(gameObject); break; } }
public void Update() { if (null == m_anchor) { m_MeshRenderer.enabled = false; return; } switch (m_anchor.GetTrackingState()) { case ARTrackable.TrackingState.TRACKING: Pose p = m_anchor.GetPose(); gameObject.transform.position = p.position; gameObject.transform.rotation = p.rotation; gameObject.transform.Rotate(0f, 225f, 0f, Space.Self); m_MeshRenderer.enabled = true; break; case ARTrackable.TrackingState.PAUSED: m_MeshRenderer.enabled = false; break; case ARTrackable.TrackingState.STOPPED: default: m_MeshRenderer.enabled = false; Destroy(gameObject); break; } }
private void trackTest() { if (null == m_beginAnchor) { m_MeshRenderer.enabled = false; return; } switch (m_beginAnchor.GetTrackingState()) { case ARTrackable.TrackingState.TRACKING: m_MeshRenderer.enabled = true; break; case ARTrackable.TrackingState.PAUSED: m_MeshRenderer.enabled = false; return; case ARTrackable.TrackingState.STOPPED: default: m_MeshRenderer.enabled = false; m_beginAnchor = null; return; } List <ARHitResult> hitResults = ARFrame.HitTest(m_touchScreenPos.x, m_touchScreenPos.y); ARDebug.LogInfo("GridARScript:trackTest hitResults count {0}", hitResults.Count); foreach (ARHitResult singleHit in hitResults) { ARTrackable trackable = singleHit.GetTrackable(); ARDebug.LogInfo("GridARScript:trackTest GetTrackable {0}", singleHit.GetTrackable()); if ((trackable is ARPlane && ((ARPlane)trackable).IsPoseInPolygon(singleHit.HitPose)) || (trackable is ARPoint)) { ARAnchor anchor = singleHit.CreateAnchor(); //ARDebug.LogInfo("GridARScript:trackTest anchor world position {0}", anchor.GetPose().position); renderMesh(m_beginAnchor.GetPose().position, anchor.GetPose().position); break; } } }