public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (!m_GroundPlaneUI.IsCanvasButtonPressed()) { Debug.Log("HandleInteractiveHitTest() called."); // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true); // Astronaut should rotate toward camera with each placement m_PlaneAugmentation.transform.localPosition = Vector3.zero; UtilityHelper.RotateTowardCamera(m_PlaneAugmentation); AstronautIsPlaced = true; } }
public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (m_StatusInfo == TrackableBehaviour.StatusInfo.NORMAL || (m_StatusInfo == TrackableBehaviour.StatusInfo.UNKNOWN && !VuforiaRuntimeUtilities.IsPlayMode())) { if (!m_GroundPlaneUI.IsCanvasButtonPressed()) { Debug.Log("HandleInteractiveHitTest() called."); // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode switch (planeMode) { case PlaneMode.GROUND: m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true); // Astronaut should rotate toward camera with each placement m_PlaneAugmentation.transform.localPosition = Vector3.zero; //UtilityHelper.RotateTowardCamera(m_PlaneAugmentation); break; case PlaneMode.PLACEMENT: if (!m_ProductPlacement.IsPlaced || TouchHandler.DoubleTap) { m_ContentPositioningBehaviour.AnchorStage = m_PlacementAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(m_PlacementAugmentation, true); } if (!m_ProductPlacement.IsPlaced) { m_ProductPlacement.SetProductAnchor(m_PlacementAnchor.transform); m_TouchHandler.enableRotation = true; } break; } } } }
void Update() { if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT) { //shadowRenderer.enabled = chairRenderer.enabled = (IsPlaced || PlaneManager.GroundPlaneHitReceived); chairRenderer.enabled = false; shadowRenderer.enabled = false; EnablePreviewModeTransparency(!IsPlaced); if (!IsPlaced) { UtilityHelper.RotateTowardCamera(gameObject); } } else { //shadowRenderer.enabled = chairRenderer.enabled = IsPlaced; } if (PlaneManager.planeMode == PlaneManager.PlaneMode.PLACEMENT && IsPlaced) { m_RotationIndicator.SetActive(Input.touchCount == 2); m_TranslationIndicator.SetActive( (TouchHandler.IsSingleFingerDragging || TouchHandler.IsSingleFingerStationary) && !m_GroundPlaneUI.IsCanvasButtonPressed()); if (TouchHandler.IsSingleFingerDragging || (VuforiaRuntimeUtilities.IsPlayMode() && Input.GetMouseButton(0))) { if (!m_GroundPlaneUI.IsCanvasButtonPressed()) { cameraToPlaneRay = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(cameraToPlaneRay, out cameraToPlaneHit)) { if (cameraToPlaneHit.collider.gameObject.name == (VuforiaRuntimeUtilities.IsPlayMode() ? EmulatorGroundPlane : Floor.name)) { gameObject.PositionAt(cameraToPlaneHit.point); } } } } } else { m_RotationIndicator.SetActive(false); m_TranslationIndicator.SetActive(false); } }
public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (!m_GroundPlaneUI.IsCanvasButtonPressed() && allowInterActive) { Debug.Log("HandleInteractiveHitTest() called."); // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode switch (planeMode) { case PlaneMode.GROUND: m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(m_PlaneAugmentation, true); // Astronaut should rotate toward camera with each placement m_PlaneAugmentation.transform.localPosition = Vector3.zero; UtilityHelper.RotateTowardCamera(m_PlaneAugmentation); CityIsPlaced = true; allowInterActive = false; if (CommonData.currentUser == null) { CommonData.currentUser = new DBStruct <UserData>("player"); } // CommonData.currentUser.data.Plus += 300; // CommonData.currentUser.data.Minus -= 200; CommonData.mainManager.stateManager.PushState(new ShowTitle()); CommonData.prefabs.gameobjectLookup[StringConstants.ARCamera].GetComponent <AudioSource>().Play(); // CommonData.StateAnimal = true; setOblect = true; break; } } }
public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (!groundPlaneUI.IsCanvasButtonPressed()) { Debug.Log("HandleInteractiveHitTest() called."); // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour this.contentPositioningBehaviour = this.planeFinder.GetComponent <ContentPositioningBehaviour>(); this.contentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode switch (CurrentPlaneMode) { case PlaneMode.GROUND: // With each tap, the Astronaut is moved to the position of the // newly created anchor. Before we set any anchor, we first want // to verify that the Status=TRACKED/EXTENDED_TRACKED and StatusInfo=NORMAL. if (TrackingStatusIsTrackedAndNormal) { this.contentPositioningBehaviour.AnchorStage = this.planeAnchor; this.contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(this.planeAugmentation, true); // Astronaut should rotate toward camera with each placement this.planeAugmentation.transform.localPosition = Vector3.zero; UtilityHelper.RotateTowardCamera(this.planeAugmentation); //this.touchHandler.enableRotation = true; } break; case PlaneMode.PLACEMENT: // With initial tap or a double-tap, a new anchor is created, // so we first check that Status=TRACKED/EXTENDED_TRACKED and StatusInfo=NORMAL // before proceeding. if (TrackingStatusIsTrackedAndNormal) { // If the product is yet to be placed when a tap occurs, // we assign our stage content, set an anchor and enable the // content. If a double-tap occurs, for instance when the content // has already been placed and positioned, then a new anchor // is placed and the stage is centered to it, but the content // retains its offset in relation to the stage. if (!this.productPlacement.IsPlaced || TouchHandler.DoubleTap) { this.contentPositioningBehaviour.AnchorStage = this.placementAnchor; this.contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(placementAugmentation, true); } // Immediately following the steps above, we again confirm that the // IsPlaced flag has not been set and call SetProductAnchor to // reset the transform and rotation of the content in relation to the // stage collision plane. This only happens when setting the first // anchor or when reseting the scene. When double-tapping to simply // create a new anchor, the content retains its positional offset in // relation to the stage collision plane as well as its rotation. // The SetProductAnchor() will set the IsPlaced flag to true if the // transform argument is valid and to false if it is null. if (!this.productPlacement.IsPlaced) { this.productPlacement.SetProductAnchor(this.placementAnchor.transform); this.touchHandler.enableRotation = true; } } break; } } }
public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (!groundPlaneUI.IsCanvasButtonPressed()) { Debug.Log("HandleInteractiveHitTest() called."); // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour this.contentPositioningBehaviour = this.planeFinder.GetComponent <ContentPositioningBehaviour>(); this.contentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode switch (CurrentPlaneMode) { case PlaneMode.GROUND: // With each tap, the Astronaut is moved to the position of the // newly created anchor. Before we set any anchor, we first want // to verify that the Status=TRACKED/EXTENDED_TRACKED and StatusInfo=NORMAL. if (TrackingStatusIsTrackedAndNormal) { this.contentPositioningBehaviour.AnchorStage = this.planeAnchor; this.contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(this.planeAugmentation, true); // Astronaut should rotate toward camera with each placement this.planeAugmentation.transform.localPosition = Vector3.zero; UtilityHelper.RotateTowardCamera(this.planeAugmentation); } break; case PlaneMode.PLACEMENT: // With a tap a new anchor is created, so we first check that // Status=TRACKED/EXTENDED_TRACKED and StatusInfo=NORMAL before proceeding. if (TrackingStatusIsTrackedAndNormal) { // We assign our stage content, set an anchor and enable the // content. this.contentPositioningBehaviour.AnchorStage = this.placementAnchor; this.contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelper.EnableRendererColliderCanvas(placementAugmentation, true); // If the product has not been placed in the scene yet, we attach it to the anchor // while rotating it to face the camera. Then we activate the content, also // enabling rotation input detection. // Otherwise, we simply attach the content to the new anchor, preserving its rotation. // The placement methods will set the IsPlaced flag to true if the // transform argument is valid and to false if it is null. if (!this.productPlacement.IsPlaced) { this.productPlacement.PlaceProductAtAnchorFacingCamera(this.placementAnchor.transform); this.touchHandler.enableRotation = true; } else { this.productPlacement.PlaceProductAtAnchor(this.placementAnchor.transform); } } break; } } }
public virtual void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (!m_GroundPlaneUI.IsCanvasButtonPressed()) { Debug.Log("HandleInteractiveHitTest() called."); // If the PlaneFinderBehaviour's Mode is Automatic, then the Interactive HitTestResult will be centered. // PlaneMode.Ground and PlaneMode.Placement both use PlaneFinder's ContentPositioningBehaviour m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode if (showGameObject != null && lastName != showGameObjectName) { lastName = showGameObjectName; showGameObject.gameObject.SetActive(true); isPlaced = true; if (showGameObjectName == "haiou") { showGameObject.GetComponent <Haiou>().Init(); } else { FingerTouchEL.Instance.targetGameObject = showGameObject; } UtilityHelper.EnableRendererColliderCanvas(showGameObject, true); switch (showGameObject.GetComponent <WriteItem>().goodsPositionEnum) { case PlaneMode.None: break; case PlaneMode.GROUND: m_ContentPositioningBehaviour.AnchorStage = m_PlaneAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); showGameObject.transform.parent = planeAnchor.transform; break; case PlaneMode.MIDAIR: m_ContentPositioningBehaviour.AnchorStage = m_MidAirAnchor; m_ContentPositioningBehaviour.PositionContentAtMidAirAnchor(showGameObject.transform); showGameObject.transform.parent = midAirAnchor.transform; break; default: break; } showGameObject.transform.localPosition = Vector3.zero; showGameObject.transform.localEulerAngles = Vector3.zero; if (showGameObject.name == "wurenji") { showGameObject.GetComponentInChildren <Cloth>().enabled = false; } showGameObject.transform.localScale = Vector3.one * 0.5f; if (showGameObject.name == "wurenji") { showGameObject.GetComponentInChildren <Cloth>().enabled = true; } UtilityHelper.RotateTowardCameraVuforia(showGameObject); // YiyouStaticDataManager.Instance.ShowModel = showGameObject; FirstUseTipManager.Instance.ShowNextTip(TipType.WriteTip); WriteItem writeItem = showGameObject.GetComponent <WriteItem>(); if (writeItem != null && writeItem.goodsEnum != GoodsWriteEnum.None) { ShowInput(); GroundPlaneUI.Instance.SetIntroductionText("请选择字体并输入文字"); } else { GroundPlaneUI.Instance.SetIntroductionText("", false); ShowButtonPanel(); } ShowEffectPanel(); GroundPlaneUI.Instance.SetReticleVisiblity(false); WriteManager.Instance.SetGoodsEnum(showGameObject.GetComponent <WriteItem>().goodsEnum); InitLight(showGameObject.name); } else { if (showGameObject == null) { GroundPlaneUI.Instance.SetIntroductionText("请先选择合影道具"); } } } }