/// <summary> /// Function called when the manipulation is ended. /// </summary> /// <param name="gesture">The current gesture.</param> protected override void OnEndManipulation(TapGesture gesture) { if (gesture.WasCancelled) { return; } // If gesture is targeting an existing object we are done. if (gesture.TargetObject != null) { //Debug.Log("\nTarget Object != null"); return; } if (IsPointerOverUIObject()) { //Debug.Log("\n\nIsPointerOverUIObject"); return; } // Raycast against the location the player touched to search for planes. TrackableHit hit; TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon; if (Frame.Raycast( gesture.StartPosition.x, gesture.StartPosition.y, raycastFilter, out hit)) { // Use hit pose and camera pose to check if hittest is from the // back of the plane, if it is, no need to create the anchor. if ((hit.Trackable is DetectedPlane) && Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position, hit.Pose.rotation * Vector3.up) < 0) { Debug.Log("Hit at back of the current DetectedPlane"); } else { // Instantiate game object at the hit pose. DetectedPlane detectedPlane = hit.Trackable as DetectedPlane; //Debug.Log("\n\n\n\n\ndetectedPlane.PlaneType=" + detectedPlane.PlaneType.ToString()); //Debug.Log("DetectedPlaneType.HorizontalUpwardFacing=" + DetectedPlaneType.HorizontalUpwardFacing.ToString()); //Debug.Log("currentNumberOfObjects=" + currentNumberOfObjects.ToString()); //Debug.Log("numberOfObjectsAllowed=" + numberOfObjectsAllowed.ToString()); //Debug.Log("===>Condition=" + (detectedPlane.PlaneType == DetectedPlaneType.HorizontalUpwardFacing && currentNumberOfObjects < numberOfObjectsAllowed).ToString()); //if (detectedPlane.PlaneType == DetectedPlaneType.Vertical && currentNumberOfVerticalObjects < numberOfObjectsAllowed) // { //GameObject modelprefab = Instantiate(GameObjectVerticalPlanePrefab, hit.Pose.position, hit.Pose.rotation); // GenerateModels(modelprefab, hit); // currentNumberOfVerticalObjects++; //} //else if (detectedPlane.PlaneType == DetectedPlaneType.HorizontalUpwardFacing && currentNumberOfObjects < numberOfObjectsAllowed ) //{ //floor //Debug.Log("\n\n hit horizontal !!!!!"); //int prefabval = SetValue.getprefab(); //if (prefabval == 0) //{ //GameObject modelprefab = Instantiate(tablePrefab, hit.Pose.position, hit.Pose.rotation); //GenerateModels(modelprefab, hit); //} //else //{ if (detectedPlane.PlaneType == DetectedPlaneType.Vertical || detectedPlane.PlaneType == DetectedPlaneType.HorizontalDownwardFacing || detectedPlane.PlaneType == DetectedPlaneType.HorizontalUpwardFacing) { Vector3 pos = hit.Pose.position; GameObject currGameObject = ItemListener.getSelectedGameObject(); if (currGameObject != null) { //hit.Pose.rotation GameObject modelprefab = Instantiate(currGameObject, pos, hit.Pose.rotation); //modelprefab.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); //modelprefab.AddComponent<BoxCollider>(); GenerateModels(modelprefab, hit); } } //} //currentNumberOfObjects++; //} //else if (detectedPlane.PlaneType == DetectedPlaneType.HorizontalDownwardFacing && currentNumberOfUpObjects < numberOfObjectsAllowed) //{ // GameObject modelprefab = Instantiate(GameObjectHorizontalUpwardPlanePrefab, hit.Pose.position, hit.Pose.rotation); // GenerateModels(modelprefab, hit); // currentNumberOfUpObjects++; //} } } }
public void setAsSelected() { selectedGameObject = currGameObject; Debug.Log("SELECTED: " + ItemListener.getSelectedGameObject().name); }