void OnTrackerFound() { foreach (var item in avenger_Vumark.GetActiveBehaviours()) { int targetObj = System.Convert.ToInt32(item.VuMarkTarget.InstanceId.NumericValue - 1); if (IndexManager.instance.Contains(targetObj)) { continue; } transform.GetChild(targetObj).gameObject.SetActive(true); DeactiveOthers(); IndexManager.instance.Add(targetObj); } }
void Update() { foreach (var marker in _vuMarkManager.GetActiveBehaviours()) { if (HololensCamera && _rotationValues.Count < 20 && !_offsetSetted) { _rotationValues.Add(marker.transform.rotation.eulerAngles.y); Debug.Log(marker.transform.rotation.eulerAngles.y + " " + HololensCamera.transform.rotation.eulerAngles.y); } else if (!_offsetSetted) { //use median instead of average _rotationValues.Sort(); var playerRotation = _rotationValues[_rotationValues.Count / 2]; playerRotation = 360 - playerRotation; MarkerRotation = playerRotation; MarkerPosition = marker.transform.position; if (VuMarkDetected != null) { VuMarkDetected(marker.transform, HololensCamera.transform, playerRotation); } _offsetSetted = true; //turn off the marker tracking/detecting VuforiaBehaviour.Instance.enabled = false; } } }
void Update() { foreach (var bhvr in mVuMarkManager.GetActiveBehaviours()) { //_gameObjectManager.CreateNewGameObjectFromVumark(bhvr); } }
void UpdateClosestTarget() { Camera cam = DigitalEyewearBehaviour.Instance.PrimaryCamera ?? Camera.main; float closestDistance = Mathf.Infinity; foreach (var bhvr in mVuMarkManager.GetActiveBehaviours()) { Vector3 worldPosition = bhvr.transform.position; Vector3 camPosition = cam.transform.InverseTransformPoint(worldPosition); float distance = Vector3.Distance(Vector2.zero, camPosition); if (distance < closestDistance) { closestDistance = distance; mClosestVuMark = bhvr.VuMarkTarget; } } if (mClosestVuMark != null && mCurrentVuMark != mClosestVuMark) { var vuMarkId = GetVuMarkString(mClosestVuMark); var vuMarkTitle = GetVuMarkDataType(mClosestVuMark); var vuMarkImage = GetVuMarkImage(mClosestVuMark); mCurrentVuMark = mClosestVuMark; mIdPanel.Hide(); StartCoroutine(ShowPanelAfter(0.5f, vuMarkTitle, vuMarkId, vuMarkImage)); } }
void FixedUpdate() { Plants plant; int targetID; var ds = new DataService("tempDatabase.db"); //Start a connection with the DB //Get the current Target ID from the target has been tracked // Get the information of the plant based on the tracked Target ID foreach (var vmark in mVuMarkManager.GetActiveBehaviours()) { targetID = System.Convert.ToInt32(vmark.VuMarkTarget.InstanceId.NumericValue); plant = ds.GetPlantByID(targetID); // Write to UI Elements WriteMainMenuTitle(plant); WritePlantInfo(plant); WriteSoilInfo(plant); WriteSunInfo(plant); WriteWaterInfo(plant); // Debug Data //Debug.Log(message: "Target ID: " + targetID); //Debug.Log( "Plant ID: " + System.Convert.ToString(plant.Id)); //Debug.Log("Popular Name: " + plant.Nome_Popular); //Debug UI //ToConsole(plant.ToString()); } }
void Update() { foreach (var bhvr in mVuMarkManager.GetActiveBehaviours()) { Vector3 worldPosition = bhvr.transform.position; } }
void Update() { ulong id; foreach (var behaviour in _vuMarkManager.GetActiveBehaviours()) { id = behaviour.VuMarkTarget.InstanceId.NumericValue; if (!_gameObjectManager.ContainsID(id) || MarkerCanBeScannedMultipleTimes) { _gameObjectManager.SpawnObject(behaviour, !MarkerCanBeScannedMultipleTimes); } else { if (UpdateObjectRotation) { _gameObjectManager[id].transform.rotation = behaviour.transform.rotation; } if (UpdateObjectPosition) { _gameObjectManager[id].transform.position = behaviour.transform.position; } } } }
// Update is called once per frame void Update() { // Get list of active trackables StateManager sm = TrackerManager.Instance.GetStateManager(); VuMarkManager vm = sm.GetVuMarkManager(); activeVuMarks = vm.GetActiveBehaviours().ToList(); }
private void OnTrackerFound() { foreach (var items in VuMark.GetActiveBehaviours()) { id = Convert.ToInt32(items.VuMarkTarget.InstanceId.NumericValue); Debug.Log("id : " + id); FetchData(); } }
protected virtual void OnTrackingFound() { if (mTrackableBehaviour) { var rendererComponents = mTrackableBehaviour.GetComponentsInChildren <Renderer>(true); var colliderComponents = mTrackableBehaviour.GetComponentsInChildren <Collider>(true); var canvasComponents = mTrackableBehaviour.GetComponentsInChildren <Canvas>(true); // Enable rendering: foreach (var component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (var component in colliderComponents) { component.enabled = true; } // Enable canvas': foreach (var component in canvasComponents) { component.enabled = true; } mVuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager(); if (mVuMarkManager.GetActiveBehaviours() != null) { foreach (var bhvr in mVuMarkManager.GetActiveBehaviours()) { if (bhvr.gameObject.Equals(this.gameObject)) { TextMesh t = this.gameObject.GetComponentInChildren <TextMesh>(); t.text = bhvr.VuMarkTarget.InstanceId.StringValue; } } } } }
public VuMarkTarget GetVuMarkObj() { /* By design, grabs the first VuMarkObj available */ mVuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager(); foreach (var bhvr in mVuMarkManager.GetActiveBehaviours()) { return(bhvr.VuMarkTarget); } return(null); }
private int GetTargetsSize() { int targets = 0; mVuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager(); foreach (var bhvr in mVuMarkManager.GetActiveBehaviours()) { //Debug.Log("Sorting through VuMark Manager"); targets += 1; } return(targets); }
void OnTrackerFound() { PointsController.lastAction = "Scan"; foreach (var item in resource_Vumark.GetActiveBehaviours()) { PointsController.currentLocation = item.VuMarkTarget.InstanceId.StringValue; } if (PointsController.visited.Contains(PointsController.currentLocation)) { SceneManager.LoadScene("AlreadyVisited"); } else { PointsController.visited.Add(PointsController.currentLocation); SceneManager.LoadScene("ResultScreen"); } /* * foreach (var item in resource_Vumark.GetActiveBehaviours()) * { * Transform parent = transform.parent.gameObject.transform; * GameObject scanWindow = parent.GetChild(0).gameObject; * GameObject slider = parent.GetChild(3).gameObject; * GameObject button = parent.GetChild(4).gameObject; * GameObject livingFish = parent.GetChild(5).gameObject; * GameObject deadFish = parent.GetChild(6).gameObject; * * Debug.Log("Found!"); * //int targetObj = System.Convert.ToInt32(item.VuMarkTarget.InstanceId.NumericValue); * scanWindow.SetActive(false); * slider.SetActive(true); * button.SetActive(true); * livingFish.SetActive(true); * deadFish.SetActive(true); * //Debug.Log(transform.GetChild((int)0).gameObject.activeInHierarchy); * //GUI.SetActive(false); * }*/ }
void OnVumarkDetected(VuMarkTarget target) { GameObject hologram; if (hologramDictionary.TryGetValue(target.InstanceId.StringValue, out hologram)) { foreach (var vumark in vuMarkManager.GetActiveBehaviours(target)) { hologram.transform.position = vumark.transform.position; hologram.transform.rotation = vumark.transform.rotation; } hologram.SetActive(true); } }
void UpdateClosestTarget() { foreach (var bhvr in mVuMarkManager.GetActiveBehaviours()) { //得到扫描到的vumark mClosestVuMark = bhvr.VuMarkTarget; } if (mClosestVuMark != null) { id = mClosestVuMark.InstanceId.NumericValue.ToString(); print(id); } else { id = ""; } }
void Update() { foreach (var bhvr in vmm.GetActiveBehaviours()) { vm = bhvr.VuMarkTarget; Debug.Log("Found ID number " + vm.InstanceId); foreach (Transform child in gameObject.GetComponentInChildren <Transform>()) { if (child.name == vm.InstanceId.ToString()) { child.gameObject.SetActive(true); } else { child.gameObject.SetActive(false); } } } }
void LateUpdate() { // Use all active registered trackers to determine world-space camera position. Quaternion averageCameraRotation = Quaternion.identity; List <Vector3> predictedCameraPositions = new List <Vector3>(2 * MAX_TRACKER_ID); int n = 0; foreach (var marker in vuMarkManager.GetActiveBehaviours()) { var tracker = GetTrackerFromTarget(marker.VuMarkTarget); if (tracker == null) { continue; } if (!tracker.isRegistered) { continue; } Quaternion trackerRotation = tracker.knownWorldRotation * Quaternion.Inverse(marker.transform.localRotation); Vector3 trackerPosition = tracker.knownWorldPosition + trackerRotation * -marker.transform.localPosition; averageCameraRotation = AverageQuaternionStepwise(n, averageCameraRotation, trackerRotation); predictedCameraPositions.Add(trackerPosition); n++; } bool hasTracking = n > 0; float trackingAccuracy = float.NaN; if (hasTracking) { Vector3 averageCameraPosition = Vector3.zero; foreach (Vector3 pos in predictedCameraPositions) { averageCameraPosition += pos / n; } transform.localRotation = averageCameraRotation; transform.localPosition = averageCameraPosition; trackingAccuracy = Mathf.Sqrt(predictedCameraPositions.Select(pos => (pos - averageCameraPosition).sqrMagnitude).Max()); } debug.text = "Tracking: " + n + ", Trackers: " + string.Join(", ", vuMarkManager.GetActiveBehaviours() .Select(marker => GetTrackerFromTarget(marker.VuMarkTarget)) .Where(tracker => tracker != null) .Select(tracker => string.Format("#{0}::{1}", tracker.id, tracker.isRegistered ? "R" : "?"))) + "\nAccuracy: " + (trackingAccuracy * 100).ToString("0") + " cm"; if (hasTracking) { ProcessUnregisteredTrackers(); } if (onlyWithTrackingTarget != null && onlyWithTrackingTarget.activeSelf != hasTracking) { onlyWithTrackingTarget.SetActive(hasTracking); } // Debug: Reset with keyboard. if (Input.GetKeyDown(KeyCode.R)) { ResetTrackers(); } }
void UpdateActiveObjects() { foreach (var bhvr in m_VuMarkManager.GetActiveBehaviours()) { string vuMarkId = GetVuMarkId(bhvr.VuMarkTarget); float xOffset; float yOffset; float zOffset; GameObject associatedObject = FindObjectAndOffsetsForVuMark(vuMarkId, out xOffset, out yOffset, out zOffset); if (associatedObject != null) { associatedObject.SetActive(true); // Position Vector3 vuMarkPosition; if (filterPosition) { if (vuMarkPositionFilters.ContainsKey(vuMarkId)) { LowPassFilter <Vector3> positionFilter = vuMarkPositionFilters[vuMarkId]; vuMarkPosition = positionFilter.Append(bhvr.transform.position); } else { LowPassFilter <Vector3> positionFilter = new LowPassFilter <Vector3>(FILTER_ALPHA, transform.position); vuMarkPositionFilters[vuMarkId] = positionFilter; vuMarkPosition = bhvr.transform.position; } } else { vuMarkPosition = bhvr.transform.position; } vuMarkPosition.x += xOffset; vuMarkPosition.y += yOffset; vuMarkPosition.z += zOffset; associatedObject.transform.position = vuMarkPosition; // Rotation if (adjustRotation) { Quaternion zInverted = Quaternion.AngleAxis(-180.0f, Vector3.up); if (filterRotation) { if (vuMarkRotationFilters.ContainsKey(vuMarkId)) { LowPassFilter <Quaternion> rotationFilter = vuMarkRotationFilters[vuMarkId]; associatedObject.transform.rotation = rotationFilter.Append(bhvr.transform.rotation); } else { LowPassFilter <Quaternion> rotationFilter = new LowPassFilter <Quaternion>(FILTER_ALPHA, bhvr.transform.rotation); vuMarkRotationFilters[vuMarkId] = rotationFilter; associatedObject.transform.rotation = bhvr.transform.rotation; } } else { associatedObject.transform.rotation = bhvr.transform.rotation;// * zInverted; Don't seem to want this } } } else { Debug.Log("ERROR: Can't find object for VuMark: " + vuMarkId); } } }