protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose initialPose) { DebugLogExtra($"Creating anchor {id.FormatStr()}"); initialPose = AnchorFromSpongy.Multiply(initialPose); SpongyAnchorARF newAnchor = null; #if WLT_ADD_ANCHOR_COMPONENT GameObject go = new GameObject(id.FormatStr()); go.transform.SetParent(parent); go.transform.SetGlobalPose(initialPose); ARAnchor arAnchor = go.AddComponent <ARAnchor>(); newAnchor = WrapARAnchor(id, arAnchor.trackableId, go); #else // WLT_ADD_ANCHOR_COMPONENT var arAnchor = arAnchorManager.AddAnchor(initialPose); if (arAnchor == null) { Debug.LogError($"ARAnchorManager failed to create ARAnchor {id}"); return(null); } arAnchor.gameObject.name = id.FormatStr(); newAnchor = WrapARAnchor(id, arAnchor.trackableId, arAnchor.gameObject); #endif // WLT_ADD_ANCHOR_COMPONENT Debug.Assert(newAnchor != null); return(newAnchor); }
protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose initialPose) { Debug.Log($"Creating anchor {id.FormatStr()}"); var referencePoint = arReferencePointManager.AddReferencePoint(initialPose); referencePoint.gameObject.name = id.FormatStr(); SpongyAnchorARF newAnchor = referencePoint.gameObject.AddComponent <SpongyAnchorARF>(); return(newAnchor); }
private SpongyAnchor CreateAnchor(AnchorId id) { var newAnchorObject = new GameObject(id.FormatStr()); newAnchorObject.transform.parent = worldAnchorParent; return(newAnchorObject.AddComponent <SpongyAnchor>()); }
/// <summary> /// Create a frozen anchor visual in the indicated fragment. /// </summary> /// <param name="source">Source data to create from.</param> /// <param name="resource">The created resource.</param> /// <returns></returns> public bool CreateFrozenVisual(AnchorFragmentPose source, out IdPair <AnchorId, FrozenAnchorVisual> resource) { // Already ensured this fragment exists. FragmentId fragmentId = source.fragmentPose.fragmentId; AnchorId anchorId = source.anchorId; FrameVisual frozenFragmentViz; if (!frozenFragmentVisuals.TryGetValue(fragmentId, out frozenFragmentViz)) { resource = new IdPair <AnchorId, FrozenAnchorVisual>() { id = AnchorId.Invalid, target = null }; return(false); } // If there isn't a visualization for this anchor, add one. FrozenAnchorVisual frozenAnchorVisual; frozenAnchorVisual = Prefab_FrozenAnchorViz.Instantiate(anchorId.FormatStr(), frozenFragmentViz); //frozenAnchorVisual.gameObject.AddComponent<AdjusterMoving>(); // Put the frozen anchor vis at the world locked transform of the anchor SetPose(source, frozenAnchorVisual); resource = new IdPair <AnchorId, FrozenAnchorVisual>() { id = source.anchorId, target = frozenAnchorVisual }; return(true); }
protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose initialPose) { SpongyAnchorXR spongyAnchorXR = null; if (IsTracking()) { DebugLogExtra($"Creating refPt at initial ({initialPose.position.x:0.000}, {initialPose.position.y:0.000}, {initialPose.position.z:0.000})"); XRReferencePoint xrReferencePoint; bool created = xrReferencePointManager.TryAddReferencePoint(initialPose, out xrReferencePoint); if (created) { Pose xrPose = xrReferencePoint.pose; DebugLogExtra($"Created refPt {id} at ({xrPose.position.x:0.000}, {xrPose.position.y:0.000}, {xrPose.position.z:0.000}) is {xrReferencePoint.trackingState}"); var newAnchorObject = new GameObject(id.FormatStr()); newAnchorObject.transform.parent = parent; newAnchorObject.transform.SetGlobalPose(initialPose); spongyAnchorXR = newAnchorObject.AddComponent <SpongyAnchorXR>(); anchorsByTrackableId[xrReferencePoint.trackableId] = spongyAnchorXR; spongyAnchorXR.TrackableId = xrReferencePoint.trackableId; DebugLogExtra($"{id} {DebugVector3("P=", initialPose.position)}, {DebugQuaternion("Q=", initialPose.rotation)}"); } } return(spongyAnchorXR); }
protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose initialPose) { #if WLT_EXTRA_LOGGING Debug.Log($"Creating anchor {id.FormatStr()}"); #endif // WLT_EXTRA_LOGGING initialPose = AnchorFromSpongy.Multiply(initialPose); var arAnchor = arReferencePointManager.AddReferencePoint(initialPose); if (arAnchor == null) { Debug.LogError($"ARReferencePoinManager failed to create ARAnchor {id}"); return(null); } arAnchor.gameObject.name = id.FormatStr(); SpongyAnchorARF newAnchor = arAnchor.gameObject.AddComponent <SpongyAnchorARF>(); return(newAnchor); }
protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose initialPose) { var newAnchorObject = new GameObject(id.FormatStr()); newAnchorObject.transform.parent = parent; newAnchorObject.transform.SetGlobalPose(initialPose); return(newAnchorObject.AddComponent <SpongyAnchorWSA>()); }
private SpongyAnchorXR PrepAnchor(AnchorId anchorId, Transform parent, TrackableId trackableId, Pose xrPose) { var newAnchorObject = new GameObject(anchorId.FormatStr()); newAnchorObject.transform.parent = parent; newAnchorObject.transform.SetGlobalPose(xrPose); SpongyAnchorXR spongyAnchorXR = newAnchorObject.AddComponent <SpongyAnchorXR>(); anchorsByTrackableId[trackableId] = spongyAnchorXR; spongyAnchorXR.TrackableId = trackableId; spongyAnchorXR.IsReliablyLocated = false; DebugLogExtra($"{anchorId} {DebugVector3("P=", xrPose.position)}, {DebugQuaternion("Q=", xrPose.rotation)}"); return(spongyAnchorXR); }