private void Start() { DetermineParent(); if (SavedAnchorFriendlyName == string.Empty) { SavedAnchorFriendlyName = this.ObjectToPlace.name; } mainCamera = Camera.main; if (EnablePersistenceInWorldAnchor) { // Make sure we have all the components in the scene we need. anchorManager = WorldAnchorManager.Instance; if (anchorManager == null) { Debug.LogError("The EnablePersistenceInWorldAnchor flag expects that you have a WorldAnchorManager component in your scene."); } } if (EnablePersistenceInWorldAnchor || Placement == PlacementOptions.ForceSpatialMapping || Placement == PlacementOptions.FreeAndSpatialMapping) { // Make sure we have all the components in the scene we need. spatialMappingManager = SpatialMappingManager.Instance; if (spatialMappingManager == null) { Debug.LogError("The EnablePersistenceInWorldAnchor and Placement " + Placement.ToString() + " flags and expects that you have a SpatialMappingManager component in your scene."); } } if (anchorManager != null && spatialMappingManager != null) { anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName); } }
void Update() { switch (curentState) { case ControlState.CheckAnchorStatus: var cnt = anchorStore.anchorCount; if (cnt > 0) { var sb = new StringBuilder("Found Anchor" + (cnt == 1 ? " " : "s ")); foreach (var ids in anchorStore.GetAllIds()) { sb.Append(ids); } Debug.Log(sb.ToString()); ttsMgr.SpeakText(sb.ToString()); DisplayUI.Instance.AppendText(sb.ToString()); } else { ttsMgr.SpeakText("No Anchors Found, Creating Anchor"); Debug.Log("No Anchors Found, Creating Anchor"); } anchorManager.AttachAnchor(PlacementObject, SavedAnchorFriendlyName); curentState = ControlState.Ready; break; case ControlState.Ready: break; case ControlState.PlaceAnchor: // TODO: Use GazeManager + Cursor Tracking instead of another Raycast var headPosition = Camera.main.transform.position; var gazeDirection = Camera.main.transform.forward; RaycastHit hitInfo; if (Physics.Raycast(headPosition, gazeDirection, out hitInfo, 30.0f, spatialMappingManager.LayerMask)) { PlacementObject.transform.position = hitInfo.point; // Rotate this object to face the user. //Quaternion toQuat = Camera.main.transform.localRotation; //toQuat.x = 0; //toQuat.z = 0; //this.transform.rotation = toQuat; } break; } }
private void Start() { // Make sure we have all the components in the scene we need. anchorManager = WorldAnchorManager.Instance; if (anchorManager == null) { Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene."); } spatialMappingManager = SpatialMappingManager.Instance; if (spatialMappingManager == null) { Debug.LogError("This script expects that you have a SpatialMappingManager component in your scene."); } if (anchorManager != null && spatialMappingManager != null) { anchorManager.AttachAnchor(this.gameObject, SavedAnchorFriendlyName); } else { // If we don't have what we need to proceed, we may as well remove ourselves. Destroy(this); } }
public virtual void OnInputClicked(InputClickedEventData eventData) { // On each tap gesture, toggle whether the user is in placing mode. IsBeingPlaced = !IsBeingPlaced; // If the user is in placing mode, display the spatial mapping mesh // and remove the frame menu. if (IsBeingPlaced) { canvas.gameObject.transform.GetChild(0).gameObject.SetActive(false); canvas.gameObject.transform.GetChild(1).gameObject.SetActive(false); spatialMappingManager.DrawVisualMeshes = true; Debug.Log(gameObject.name + " : Removing existing world anchor if any."); anchorManager.RemoveAnchor(gameObject); } // If the user is not in placing mode, hide the spatial mapping mesh // and add the frame menu. else { spatialMappingManager.DrawVisualMeshes = false; // Add world anchor when object placement is done. anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName); // Open up the frame menu canvas.gameObject.transform.GetChild(1).gameObject.SetActive(true); // TO DO: Adjust and anchor frame menu //canvas.gameObject.transform.GetChild(1).transform.SetPositionAndRotation(new Vector3() ) //this.gameObject.transform.GetChild(frame).gameObject.SetActive(true); } }
public virtual void OnInputClicked(InputEventData eventData) { GazeableColorPicker colorPicker = FindObjectOfType <GazeableColorPicker>(); if (colorPicker != null && colorPicker.IsColoring) { Color col = colorPicker.PickedColor; GetComponentInChildren <Renderer>().material.SetColor("_Color", colorPicker.PickedColor); colorPicker.IsColoring = false; return; } // On each tap gesture, toggle whether the user is in placing mode. IsBeingPlaced = !IsBeingPlaced; // If the user is in placing mode, display the spatial mapping mesh. if (IsBeingPlaced) { spatialMappingManager.DrawVisualMeshes = true; Debug.Log(gameObject.name + " : Removing existing world anchor if any."); anchorManager.RemoveAnchor(gameObject); } // If the user is not in placing mode, hide the spatial mapping mesh. else { spatialMappingManager.DrawVisualMeshes = false; // Add world anchor when object placement is done. anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName); } }
// Use this for initialization void Start() { ttsMgr = GetComponent <TextToSpeechManager>(); if (ttsMgr == null) { Debug.LogError("TextToSpeechManager Required"); } anchorManager = WorldAnchorManager.Instance; if (anchorManager == null) { Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene."); } spatialMappingManager = SpatialMappingManager.Instance; if (spatialMappingManager == null) { Debug.LogError("This script expects that you have a SpatialMappingManager component in your scene."); } if (anchorManager != null && spatialMappingManager != null) { anchorManager.AttachAnchor(this.gameObject, SavedAnchorFriendlyName); ttsMgr.SpeakText("Anchor Locked"); } else { ttsMgr.SpeakText("Cannot Lock Anchor"); } }
public void OnInputClicked(InputClickedEventData eventData) { if (eventData.used) { return; } eventData.Use(); // This debug statement helps to identify the scale in Unity of the augmented // columns and panels which we will need to accurate place the augmentations. // Debug.Log("Panel Object lossyScale: x: " + transform.lossyScale.x // + " y: " + transform.lossyScale.y // + " z: " + transform.lossyScale.z); // CustomAudioManager.Instance.PlayInputClicked(); WorldAnchorManager anchorManager = WorldAnchorManager.Instance; if (anchorManager == null) { Debug.Log("Anchor manager not found, please attach it to scene!"); return; } GameObject anchoredClone = null; anchoredClone = GameObject.Instantiate(PrefabsManager.Instance.fixedPanel , gameObject.transform.position , gameObject.transform.rotation); anchoredClone.transform.localScale = gameObject.transform.lossyScale; anchorManager.AttachAnchor(anchoredClone, gameObject.transform.parent.name); anchoredClone.GetComponent <FixedPanel>().RegisterImageTarget(gameObject.transform.parent.gameObject); }
public virtual void OnInputClicked(InputClickedEventData eventData) { if (GameStateManager.Instance.CurrentGameState != GameState.Configuration && IsBeingPlaced == false) { Debug.Log("Tap to place is NOT AVAILABLE in GameState.Playing mode"); return; } // On each tap gesture, toggle whether the user is in placing mode. IsBeingPlaced = !IsBeingPlaced; // If the user is in placing mode, display the spatial mapping mesh. if (IsBeingPlaced) { spatialMappingManager.DrawVisualMeshes = true; Debug.Log(gameObject.name + " : Removing existing world anchor if any."); anchorManager.RemoveAnchor(gameObject); } // If the user is not in placing mode, hide the spatial mapping mesh. else { InputManager.Instance.PopModalInputHandler(); spatialMappingManager.DrawVisualMeshes = false; IgnoreRaycasts(false); // Add world anchor when object placement is done. anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName); } }
protected virtual void Start() { // Make sure we have all the components in the scene we need. anchorManager = WorldAnchorManager.Instance; if (anchorManager == null) { Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene."); } spatialMappingManager = SpatialMappingManager.Instance; if (spatialMappingManager == null) { Debug.LogError("This script expects that you have a SpatialMappingManager component in your scene."); } if (anchorManager != null && spatialMappingManager != null) { anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName); } else { // If we don't have what we need to proceed, we may as well remove ourselves. Destroy(this); } if (PlaceParentOnTap) { if (ParentGameObjectToPlace != null && !gameObject.transform.IsChildOf(ParentGameObjectToPlace.transform)) { Debug.LogError("The specified parent object is not a parent of this object."); } DetermineParent(); } }
/// <summary> /// Stops adjusting the target object and reverts the changes applied to it. /// </summary> public void CancelChanges() { if (!IsAdjusting) { return; } StopAdjusting(); RevertTargetChanges(); if (anchorManager != null) { Debug.Log(string.Format("Attempting to attach anchor for GameObject {0} with ID {1}", TargetGameObject.name, AnchorId)); anchorManager.AttachAnchor(TargetGameObject, AnchorId); } AdjustingCanceled.RaiseEvent(); }
/*! * \brief Create a World Origin in (0,0,0), and anchor it. * * When the app starts the first time, a World Origin is create in (0,0,0) with a world anchor. */ void Start() { if (!isDefine) { gameObject.transform.position = new Vector3(0, 0, 0); gameObject.transform.rotation = Camera.main.transform.rotation; worldAnchorManager.AttachAnchor(this.gameObject); gameObject.GetComponent <Renderer>().material.color = Color.red; isDefine = true; } }
private void Calibrating() { // SetVuforiaActive(true); // HideActiveChildrenObjects(true, worldAnchor); worldAnchor.transform.position = centerMarker.transform.position; worldAnchor.transform.rotation = centerMarker.transform.rotation; //get directions from anchor to reference markers // // ROBOT // 11 ------------- 12 // | | // | | // 10 ------------- 13 Vector3 pp03 = rightMarker.transform.position - worldAnchor.transform.position; Vector3 pp01 = topMarker.transform.position - worldAnchor.transform.position; Vector3 n = Vector3.Cross(pp03, pp01); Matrix4x4 m = new Matrix4x4(new Vector4(pp03.x, pp01.x, n.x, 0), new Vector4(pp03.y, pp01.y, n.y, 0), new Vector4(pp03.z, pp01.z, n.z, 0), new Vector4(0, 0, 0, 1)); worldAnchor.transform.rotation = m.inverse.rotation; //rotate around x axis to inverse Y axis worldAnchor.transform.Rotate(-90f, 0f, 0f, Space.Self); //apply offset to anchor due to marker paper //worldAnchorVisualizationCube.transform.localPosition = new Vector3(-0.208f, 0.121f, 0f); worldAnchorVisualizationCube.transform.localPosition = new Vector3(0f, 0f, 0f); worldAnchor.transform.position = worldAnchorVisualizationCube.transform.position; Debug.Log("POsition WORLD ANCHOR" + worldAnchor.gameObject.transform.position); string name = worldAnchorManager.AttachAnchor(worldAnchor); Debug.Log("Added anchor: " + name); }
public void AttachAnchor() { if (Id == null) { Debug.LogError("attempting to attach anchor when its Id isn't set yet"); } worldAnchorManager.AttachAnchor(gameObject, Id); CapsuleRenderer.material = AnchorAttached; Debug.Log("+Anchor attached for: " + this.gameObject.name + " - AnchorID: " + Id); IsAttached = true; }
void Update() { switch (CurrentState) { case ControlState.CheckAnchorStatus: // Anchor Diagnostics var cnt = anchorStore.anchorCount; if (cnt > 0) { var sb = new StringBuilder("Found Anchor" + (cnt == 1 ? " " : "s ")); foreach (var ids in anchorStore.GetAllIds()) { sb.Append(ids); } //Debug.Log(sb.ToString()); //ttsMgr.SpeakText(sb.ToString()); DisplayUI.Instance.AppendText(sb.ToString()); } else { var msg = "No Anchors Found, Creating Anchor"; DisplayUI.Instance.AppendText(msg); //Debug.Log(msg); } // Creates new anchor (based on name) if needed or attach existing anchorManager.AttachAnchor(PlacementObject, SavedAnchorFriendlyName); CurrentState = ControlState.Ready; DisplayUI.Instance.AppendText("Anchor System READY"); break; case ControlState.Ready: break; case ControlState.PlaceAnchor: break; } }
public void OnInputClicked(InputClickedEventData eventData) { IsBeingPlaced = !IsBeingPlaced; if (IsBeingPlaced) { spatialMappingManager.DrawVisualMeshes = true; clonedObject = Instantiate(cloneObject); } else { spatialMappingManager.DrawVisualMeshes = false; anchorManager.AttachAnchor(clonedObject, "test"); } }
// Use this for initialization void Start() { anchorManager = WorldAnchorManager.Instance; anchorName = gameObject.name; if (anchorManager == null) { Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene."); } spatialMappingManager = SpatialMappingManager.Instance; if (spatialMappingManager == null) { Debug.LogError("This script expects that you have a SpatialMappingManager component in your scene."); } if (anchorManager != null && spatialMappingManager != null) { anchorManager.AttachAnchor(this.gameObject, anchorName); // ensures light UI is set at the proper position and rotation relative to parent foreach (Transform child in transform) { if (child.name == "HoloLightContainer(Clone)") { var defaultHeight = child.localPosition.y; child.localRotation = Quaternion.Euler(new Vector3(0, child.rotation.y, child.rotation.z)); child.localPosition = new Vector3(0, defaultHeight, 0); } } //if (gameObject.transform.GetChild(0)) { // var child = this.gameObject.transform.GetChild(0); // Debug.Log("here is child name: " + child.name); // var defaultHeight = child.localPosition.y; // child.localRotation = Quaternion.Euler(new Vector3(0, child.rotation.y, child.rotation.z)); // child.localPosition = new Vector3(0, defaultHeight, 0); //}; } else { // If we don't have what we need to proceed, we may as well remove ourselves. Destroy(this); } }
// Start is called before the first frame update void Start() { binAnchorName = string.Format("anchor_{0}", gameObject.name); worldAnchorManagerRef = WorldAnchorManager.Instance; if (PlayerPrefs.GetString("AR_exp_stop_aruwp_lib", "false").Equals("true")) { if (worldAnchorManagerRef != null) { worldAnchorManagerRef.AttachAnchor(gameObject, binAnchorName); } else { Destroy(this); } } }
public void OnManipulationEnded() { WorldAnchor anchor = this.gameObject.GetComponent <WorldAnchor>(); if (anchor == null) { string name = worldAnchorManager.AttachAnchor(this.gameObject); Debug.Log("Added anchor: " + name); } else { if (anchor.name != null) { Debug.Log("Updating anchor: " + anchor.name); } } SaveGame(); }
private void saveAnchor() { int data = SaveHandler.getFirstEmptyAnchorSpot(); name = SaveHandler.saveDataWrapper.anchorData[data].id + ""; SaveHandler.saveDataWrapper.anchorData[data].SpatialAnchorID = name; SaveHandler.saveDataWrapper.anchorData[data].unityLocation = transform.position; SaveHandler.allAnchors.Add(gameObject); SaveHandler.Save(); anchorData = SaveHandler.saveDataWrapper.anchorData[data]; if (worldAnchorManager == null) { worldAnchorManager = GameObject.Find("AnchorManager").GetComponent <WorldAnchorManager>(); } // add the anchor component #if !UNITY_EDITOR worldAnchorManager.AttachAnchor(gameObject, name); #endif }
public void OnInputClicked(InputClickedEventData eventData) { if (m_appState.CurrentState.Value == HololensAppState.State.Calibrating) { if (marker.CurrentStatus == TrackableBehaviour.Status.TRACKED) { if (m_fingerBeingCalibrated < m_appState.FingerTransforms.Count) { GameObject fingerMarker = m_fingerMarkers[m_fingerBeingCalibrated]; fingerMarker.SetActive(true); Transform fingerPosition = m_appState.FingerTransforms[m_fingerBeingCalibrated]; Vector3 newPosition = marker.transform.position; newPosition.y -= 0.03f; fingerPosition.position = newPosition; m_worldAnchorManager.AttachAnchor(fingerPosition.gameObject); m_fingerBeingCalibrated++; if (m_fingerBeingCalibrated == m_appState.FingerTransforms.Count) { coordinatesObject.SetActive(false); CameraDevice.Instance.Stop(); m_appState.CurrentState.Value = HololensAppState.State.ConfirmCalibration; } } } } else if (m_appState.CurrentState.Value == HololensAppState.State.ConfirmCalibration) { for (int i = 0; i < m_fingerMarkers.Count; i++) { m_fingerMarkers[i].SetActive(false); } m_appState.CurrentState.Value = HololensAppState.State.Running; } }
public virtual void OnInputClicked(InputEventData eventData) { // On each tap gesture, toggle whether the user is in placing mode. IsBeingPlaced = !IsBeingPlaced; // If the user is in placing mode, display the spatial mapping mesh. if (IsBeingPlaced) { spatialMappingManager.DrawVisualMeshes = true; Debug.Log(gameObject.name + " : Removing existing world anchor if any."); anchorManager.RemoveAnchor(gameObject); } // If the user is not in placing mode, hide the spatial mapping mesh. else { spatialMappingManager.DrawVisualMeshes = false; // Add world anchor when object placement is done. anchorManager.AttachAnchor(gameObject, SavedAnchorFriendlyName); } }
public void OnManipulationEnded() { worldAnchorManager.AttachAnchor(gameObject, name); UpdateAnchor(); }
private void AddAnchor(InteractionSourceKind sourceKind) { gameObject.transform.localRotation = Quaternion.identity; anchorManager.AttachAnchor(gameObject, anchorName); }
public override void OnManipulateStop() { _anchorStore.AttachAnchor(target.gameObject, _anchorName); }
void Awake() { myWAM.AttachAnchor(this.gameObject, "me"); }
public void SaveAnchor() { anchorManager.AttachAnchor(gameObject, anchorName); }
private void Update() { if (m_appState.CurrentState.Value == HololensAppState.State.Start) { UpdateStatusText("Initialized finger transforms..."); for (int i = 0; i < 5; i++) { GameObject fingerLocationAnchor = new GameObject(FingerAnchorNames[i]); fingerLocationAnchor.transform.position = Vector3.zero; fingerLocationAnchor.transform.rotation = Quaternion.identity; fingerLocationAnchor.AddComponent <DontDestroyOnLoad>(); m_appState.FingerTransforms.Add(fingerLocationAnchor.transform); } #if !UNITY_EDITOR && UNITY_WSA UpdateStatusText("Waiting for WorldAnchorStore..."); m_appState.CurrentState.Value = HololensAppState.State.WaitingForAnchor; #else m_appState.CurrentState.Value = HololensAppState.State.Running; UpdateStatusText("Loading main scene..."); // Load main scene SceneManager.LoadScene("HololensMainScene"); #endif } else if (m_appState.CurrentState.Value == HololensAppState.State.WaitingForAnchor) { if (m_worldAnchorManager.AnchorStore != null) { UpdateStatusText("WorldAnchorStore available! Loading anchors..."); // Load anchors for the finger transforms for (int i = 0; i < FingerAnchorNames.Count; i++) { m_worldAnchorManager.AttachAnchor(m_appState.FingerTransforms[i].gameObject); } m_appState.CurrentState.Value = HololensAppState.State.InitializingVuforia; } } else if (m_appState.CurrentState.Value == HololensAppState.State.InitializingVuforia) { VuforiaRuntime.InitState vuforiaInitState = VuforiaRuntime.Instance.InitializationState; if (vuforiaInitState == VuforiaRuntime.InitState.NOT_INITIALIZED) { VuforiaRuntime.Instance.InitVuforia(); UpdateStatusText("Initializing Vuforia..."); } else if (vuforiaInitState == VuforiaRuntime.InitState.INITIALIZED) { UpdateStatusText("Vuforia initialized!"); CameraDevice.Instance.Stop(); m_appState.CurrentState.Value = HololensAppState.State.Running; } } else if (m_appState.CurrentState.Value == HololensAppState.State.Running) { UpdateStatusText("Loading main scene..."); // Load main scene SceneManager.LoadScene("HololensMainScene"); } }
public void AnchorIt() { worldAnchorManager.AttachAnchor(this.gameObject); this.gameObject.GetComponent <Renderer>().material.color = Color.red; }
public void onPlace() //when the art is placed a spatial anchor is created or updated at the store { MyManager.AttachAnchor(gameObject); Debug.Log("AnchorAttached"); }