private void Update() { if (_planes.Length == 0) { return; } for (var i = 0; i < TrackerBehaviours.Length; i++) { GameObject obj = TrackerBehaviours[i]; MLWorldPlane closestPlane = _planes[0]; foreach (MLWorldPlane plane in _planes) { if (Vector3.Distance(plane.Center, obj.transform.position) < Vector3.Distance(closestPlane.Center, obj.transform.position)) { closestPlane = plane; } } debugCube.transform.position = closestPlane.Center; debugCube.transform.rotation = closestPlane.Rotation; Vector3 proposedPosition = debugCube.transform.position - 0.25f * debugCube.transform.forward; if (Vector3.Distance(proposedPosition, trackedObjectPositions[i]) > 0.75f) { trackedObjectPositions[i] = proposedPosition; } Vector3 forwardPoint = debugCube.transform.position + new Vector3(debugCube.transform.forward.x, 0, debugCube.transform.forward.z); obj.transform.rotation = new Quaternion(0, 0, 0, 0); obj.GetComponent <ImageTrackingVisualizer>()._demo.transform.position = trackedObjectPositions[i]; obj.SetActive(true); } }
/// <summary> /// Utility function used to determine if the passed in MLWorldPlane object's /// flags contain the passed in OrientationFlags. /// </summary> /// <param name="plane">The MLWorldPlane object to be checked</param> /// <param name="flag">The OrientationFlags to be checked</param> public static bool DoesPlaneHaveFlag(MLWorldPlane plane, OrientationFlags flag) { return((plane.Flags & (uint)flag) == (uint)flag); }
/// <summary> /// Utility function used to determine if the passed in MLWorldPlane object's /// flags contain the passed in SemanticFlags. /// </summary> /// <param name="plane">The MLWorldPlane object to be checked</param> /// <param name="flag">The SemanticFlags to be checked</param> public static bool DoesPlaneHaveFlag(MLWorldPlane plane, SemanticFlags flag) { return((plane.Flags & (uint)flag) == (uint)flag); }