private bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); result = UnityARMatrixOps.GetPosition(hitResult.worldTransform); //m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count == 1) { foreach (var hitResult in hitResults) { Vector3 pos = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.position = pos * m_ContentScale; m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
//static private bool TryHitWithResultType(ARPoint point, ARHitTestResultType resultTypes) { var hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { pose.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); pose.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { selectedModel.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Debug.Log("Hit position: " + selectedModel.transform.position); selectedModel.transform.rotation = Quaternion.identity; return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Vector3 hitPosition = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Quaternion rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); spawnedObjects.Add(Instantiate(hitPrefab, hitPosition, rotation)); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { foundSquare.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); foundSquare.transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); // Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", foundSquare.transform.position.x, foundSquare.transform.position.y, foundSquare.transform.position.z)); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { hitPoint = UnityARMatrixOps.GetPosition(hitResult.worldTransform); foundSquare.transform.position = hitPoint; foundSquare.transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); //note we have not converted to Unity coord system yet - since we are going to pass this back to ARKit CreateEnvironmentProbe(hitResult.worldTransform); return(true); } } return(false); }
private bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { Debug.Log("hitResults.Count=" + hitResults.Count); foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); HitResultFunction(hitResult); return(true); } } return(false); }
public LayerMask collisionLayer = 1 << 10; //ARKitPlane layer bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { GetComponent <MainManager>().ReceivedTouch(UnityARMatrixOps.GetPosition(hitResult.worldTransform), UnityARMatrixOps.GetRotation(hitResult.worldTransform)); //m_HitTransform.position = UnityARMatrixOps.GetPosition (hitResult.worldTransform); //m_HitTransform.rotation = UnityARMatrixOps.GetRotation (hitResult.worldTransform); //Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Unity: Got hit!"); controller.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); //controller.transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); Debug.Log("Unity: " + controller.transform.position + " ; " + controller.transform.eulerAngles); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); ResetRotateAnim(); rb.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); rb.rotation = Quaternion.LookRotation(GetLookVector()); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { hitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); hitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); catControl.MoveTo(hitTransform.position, -0.15f); Show(); return(true); } } return(false); }
bool HitTestWithResultType1(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { //TODO: get the position and rotations to spawn the hat. Done: Vector3 pos = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Quaternion rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); spawnedObjects.Add(Instantiate(Terrain, pos, rotation)); // in order to use for shuffling return(true); } } return(false); }
public List <ARHitTestResult> HitTest(ARPoint point, ARHitTestResultType types, List <ARHitTestResult> results) { results.Clear(); #if !UNITY_EDITOR && UNITY_IOS int numResults = HitTest(m_NativeARSession, point, types); for (int i = 0; i < numResults; ++i) { var result = GetLastHitTestResult(i); results.Add(GetHitTestResultFromResultData(result)); } return(results); #else return(results); #endif }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { var overScene = CanvasManager.SCENE_UNDER_CANVAS; List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0 && !mapWasShown && planeAppeared && !overScene) { mapWasShown = true; foreach (var hitResult in hitResults) { m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); m_HitTransform.localScale = new Vector3(resultScale, resultScale, resultScale); Vector3 currAngle = m_HitTransform.eulerAngles; m_HitTransform.LookAt(Camera.main.transform); m_HitTransform.eulerAngles = new Vector3(currAngle.x, m_HitTransform.eulerAngles.y + 180f, currAngle.z); Transform map; for (int i = 0; i < m_HitTransform.childCount; i++) { map = m_HitTransform.GetChild(i); if (map.name == "Map") { MAP = map.gameObject; MAP.GetComponent <Animator>().SetInteger("mapAnimTransition", SHOW_MAP_ANIM); spawnScript = MAP.GetComponent <SpawnOnMap> (); m_HitTransform.gameObject.GetComponent <LeanScale>().enabled = true; if (CanvasController.isFirstSession) { ccontroller.show_info_Button(); } } } generate_script.getManager().HidePrefabs(); ccontroller.hide_about_map_text(); ccontroller.show_screenShot_btn(); ccontroller.show_reload_btn(); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); GameObject newFood = GameObject.Instantiate(foodTemplate); newFood.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); foods.Add(newFood); return(true); } } return(false); }
bool ARKitHitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); hitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); hitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); hitTransform.LookAt(new Vector3(mainCamera.transform.position.x, hitTransform.position.y, mainCamera.transform.position.z)); Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", hitTransform.position.x, hitTransform.position.y, hitTransform.position.z)); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { //Debug.Log ("Got hit!"); m_HitTransform.gameObject.SetActive(!m_HitTransform.gameObject.activeSelf); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); //Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
public List <ARHitTestResult> HitTest(ARPoint point, ARHitTestResultType types) { #if !UNITY_EDITOR int numResults = HitTest(m_NativeARSession, point, types); Debug.Log(string.Format("HitTest results: {0}", numResults)); List <ARHitTestResult> results = new List <ARHitTestResult>(); for (int i = 0; i < numResults; ++i) { var result = GetLastHitTestResult(i); results.Add(GetHitTestResultFromResultData(result)); } return(results); #else return(new List <ARHitTestResult>()); #endif }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { Camera camera = Camera.main; List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { anchor.position = UnityARMatrixOps.GetPosition(hitResults[0].worldTransform); //anchor.rotation = UnityARMatrixOps.GetRotation (hitResult.worldTransform); anchor.LookAt(anchor.position + camera.transform.rotation * Vector3.forward, camera.transform.rotation * Vector3.up); Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", anchor.position.x, anchor.position.y, anchor.position.z)); return(true); } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { //TODO: get the position and rotations to spawn the hat Vector3 pos = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Quaternion rot = UnityARMatrixOps.GetRotation(hitResult.worldTransform); GameObject go = Instantiate(hitPrefab, pos, rot); spawnedObjects.Add(go); return(true); } } return(false); }
bool GetGroundPlane(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { groundPlaneAnchorIdentifier = hitResult.anchorIdentifier; groundPlanePosition = new Vector3(0f, UnityARMatrixOps.GetPosition(hitResult.worldTransform).y, 0f); CreateGroundPlane(groundPlanePosition); aimTarget.SetActive(true); return(true); } } return(false); }
public LayerMask collisionLayer = 1 << 10; //ARKitPlane layer bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); // m_HitTransform.rotation = UnityARMatrixOps.GetRotation (hitResult.worldTransform); transform.LookAt(m_Cam); transform.rotation = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, 0f); Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
private bool HitTestWithResultType(ARPoint point, ARHitTestResultType arHitTestResultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, arHitTestResultTypes); if (hitResults.Count > 0) { anchorSet = true; ChildrenSetActive(parentGameObject, true); parentGameObject.transform.position = UnityARMatrixOps.GetPosition(hitResults[0].worldTransform); parentGameObject.transform.rotation = UnityARMatrixOps.GetRotation(hitResults[0].worldTransform); parentGameObject.transform.LookAt(new Vector3(mainCamera.transform.position.x, parentGameObject.transform.position.y, mainCamera.transform.position.z)); return(true); } return(false); }
public LayerMask collisionLayer = 1 << 10; //ARKitPlane layer bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); // see if any valid places nearby to put kitten if (hitResults.Count > 0) // if there's a valid place to put the kitten { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); // move the kitten to the first valid position where the user dragged to m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); // adjust rotation as necessary m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); //Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); transform.position = (idealCameraPosition - transform.GetChild(0).position) / transform.localScale.x; scene.SetActive(true); //m_HitTransform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); //m_HitTransform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); //Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z)); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Vector3 pos = UnityARMatrixOps.GetPosition(hitResult.worldTransform); placementPrompt.SetHit(pos); placementPrompt.gameObject.SetActive(true); introText.gameObject.SetActive(false); introTextPanel.gameObject.SetActive(false); MenuBTN.gameObject.SetActive(true); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes, GameObject target) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); target.transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); Vector3 up = Vector3.up; Vector3 right = Vector3.Cross(up, Camera.main.transform.forward).normalized; Vector3 forward = -Vector3.Cross(right, up).normalized; target.transform.rotation = Quaternion.LookRotation(forward, up); return(true); } } return(false); }
bool HitTestWithResultType(ARPoint point, ARHitTestResultType resultTypes) { List <ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point, resultTypes); if (hitResults.Count > 0) { foreach (var hitResult in hitResults) { Debug.Log("Got hit!"); transform.position = UnityARMatrixOps.GetPosition(hitResult.worldTransform); transform.rotation = UnityARMatrixOps.GetRotation(hitResult.worldTransform); // make new placement face camera transform.LookAt(Camera.main.transform.position); // transform.eulerAngles = new Vector3 (0, transform.eulerAngles.y, 0); Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", transform.position.x, transform.position.y, transform.position.z)); return(true); } } return(false); }