public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { //Debug.LogError("Invalid hit test result!"); return; } if (!m_GroundPlaneUI.IsCanvasUIPressed()) { if (indicator.activeSelf) { indicator.SetActive(false); } m_ContentPositioningBehaviour = m_PlaneFinderBehaviour.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; 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; } } }
public void PlaceObjectInMidAir(Transform midAirTransform) { if (planeMode != PlaneMode.MIDAIR) { Debug.Log("Invalid Ground Plane Mode:" + planeMode); return; } Debug.Log("PlaceObjectInMidAir() called."); if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive) { DestroyAnchors(); contentPositioningBehaviour = m_MidAirPositioner.GetComponent <ContentPositioningBehaviour>(); contentPositioningBehaviour.PositionContentAtMidAirAnchor(midAirTransform); if (!m_MidAirAugmentation.activeInHierarchy) { Debug.Log("Setting Mid-Air Augmentation to Active"); // On initial run, unhide the augmentation m_MidAirAugmentation.SetActive(true); } Debug.Log("Positioning Mid-Air Augmentation at: " + midAirTransform.position.ToString()); m_MidAirAugmentation.PositionAt(midAirTransform.position); RotateTowardCamera(m_MidAirAugmentation); } }
public void HandleInteractiveHitTest(HitTestResult result) { Debug.Log("HandleInteractiveHitTest() called."); if (result == null) { Debug.LogError("Invalid hit test result!"); return; } if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive) { DestroyAnchors(); contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); m_ResetButton.interactable = true; } if (!m_PlaneAugmentation.activeInHierarchy) { Debug.Log("Setting Plane Augmentation to Active"); // On initial run, unhide the augmentation m_PlaneAugmentation.SetActive(true); } Debug.Log("Positioning Plane Augmentation at: " + result.Position); m_PlaneAugmentation.PositionAt(result.Position); RotateTowardCamera(m_PlaneAugmentation); }
// Use this for initialization void Start() { m_planeManagerA = ARContentA.GetComponentInChildren <PlaneManager>(); m_planeManagerB = ARContentB.GetComponentInChildren <PlaneManager>(); m_anchorInputListenerBehaviourA = ARContentA.GetComponentInChildren <AnchorInputListenerBehaviour>(); m_anchorInputListenerBehaviourB = ARContentB.GetComponentInChildren <AnchorInputListenerBehaviour>(); m_planeFinderBehaviourA = ARContentA.GetComponentInChildren <PlaneFinderBehaviour>(); m_planeFinderBehaviourB = ARContentB.GetComponentInChildren <PlaneFinderBehaviour>(); m_contentPositioningBehaviourA = ARContentA.GetComponentInChildren <ContentPositioningBehaviour>(); m_contentPositioningBehaviourB = ARContentB.GetComponentInChildren <ContentPositioningBehaviour>(); m_anchorBehaviourA = ARContentA.GetComponentInChildren <AnchorBehaviour>(); m_anchorBehaviourB = ARContentB.GetComponentInChildren <AnchorBehaviour>(); m_productPlacementA = ARContentA.GetComponentInChildren <ProductPlacement>(); m_productPlacementB = ARContentB.GetComponentInChildren <ProductPlacement>(); m_touchHandlerA = ARContentA.GetComponentInChildren <TouchHandler>(); m_touchHandlerB = ARContentB.GetComponentInChildren <TouchHandler>(); TurnOffBehaviour(false); TurnOffBehaviour(true); TurnOffBehaviour(false); }
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) { //Debug.Log("WE ARE INSIDE HandleInteractiveHitTest"); 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. m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; // Place object based on Ground Plane mode switch (planeMode) { case PlaneMode.TGO: if (!m_TGOProductPlacement.IsPlaced || TGOTouchHandlerTest.DoubleTap) { m_ContentPositioningBehaviour.AnchorStage = m_TGOAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelperTest.EnableRendererColliderCanvas(m_TGOAugmentation, true); } if (!m_TGOProductPlacement.IsPlaced) { m_TGOProductPlacement.SetProductAnchor(m_TGOAnchor.transform); m_TGOTouchHandler.enableRotation = true; m_BEPITouchHandler.enableRotation = false; } break; case PlaneMode.BEPI: if (!m_BEPIProductPlacement.IsPlaced || BEPITouchHandlerTest.DoubleTap) { m_ContentPositioningBehaviour.AnchorStage = m_BEPIAnchor; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); UtilityHelperTest.EnableRendererColliderCanvas(m_BEPIAugmentation, true); } if (!m_BEPIProductPlacement.IsPlaced) { m_BEPIProductPlacement.SetProductAnchor(m_BEPIAnchor.transform); m_BEPITouchHandler.enableRotation = true; m_TGOTouchHandler.enableRotation = false; } break; } } }
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; } } } }
/* public void HandleAutomaticHitTest(HitTestResult result) * { * AutomaticHitTestFrameCount = Time.frameCount; * * if (!uiHasBeenInitialized) * { * uiHasBeenInitialized = m_GroundPlaneUI.InitializeUI(); * } * * if (planeMode == PlaneMode.PLACEMENT && !m_ProductPlacement.IsPlaced) * { * SetSurfaceIndicatorVisible(false); * m_ProductPlacement.SetProductAnchor(null); * m_PlacementAugmentation.PositionAt(result.Position); * } * } */ public void HandleInteractiveHitTest(HitTestResult result) { if (result == null) { Debug.LogError("Invalid hit test result!"); return; } //if (!m_GroundPlaneUI.IsCanvasButtonPressed()) WILL BE VERY USEFUL IN FUTURE //{ 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); * * AstronautIsPlaced = true; * * 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; * }*/ //} }
// Use this for initialization void Start() { pivotAdjuster = FindObjectOfType <PivotAdjuster>(); planeFinder = FindObjectOfType <PlaneFinderBehaviour>(); contentPositioning = planeFinder.GetComponent <ContentPositioningBehaviour>(); //debugText.text = Application.persistentDataPath; //selectedModel = test; ////modelSelected = true; //selectedModel = tobasco; //modelSelected = true; }
public void HandleAutomaticHitTest(HitTestResult result) { AutomaticHitTestFrameCount = Time.frameCount; if (!m_Playmat.IsPlaced) { //m_Playmat.SetPlaymatAnchor(m_PlaymatAnchor.transform); m_Playmat.SetPlaced(); m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); } }
public void HandleInteractiveHitTest(HitTestResult result) { Debug.Log("HandleInteractiveHitTest() called."); if (result == null && primo) { Debug.LogError("Invalid hit test result!"); return; } // Place object based on Ground Plane mode switch (planeMode) { case PlaneMode.GROUND: // Debug.Log("case PlaneGround"); if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive) { DestroyAnchors(); contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); // m_ResetButton.interactable = true; } if (!m_PlaneAugmentation.activeInHierarchy && !primo) { Debug.Log("Setting Plane Augmentation to Active"); // On initial run, unhide the augmentation m_PlaneAugmentation.SetActive(true); primo = true; } Debug.Log("Positioning Plane Augmentation at: " + cube.transform.position); m_PlaneAugmentation.PositionAt(cube.transform.position); RotateTowardImageTarget(m_PlaneAugmentation); break; default: Debug.LogError("Invalid Ground Plane state: " + planeMode); break; } }
public void HandleInteractiveHitTest(HitTestResult result) { Debug.Log("HandleInteractiveHitTest() called."); if (result == null) { Debug.LogError("Invalid hit test result!"); return; } // Place object based on Ground Plane mode switch (planeMode) { case PlaneMode.GROUND: if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive) { DestroyAnchors(); contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); // if (!m_MidAirToggle.interactable) // { // Runs only once after first successful Ground Anchor is created // m_MidAirToggle.interactable = true; // m_ResetButton.interactable = true; // } } if (blockToggle.isOn) { Vector2d geoloc = result.Position.GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale); BlocksSpawner.Instance.SaveMessage("test", result.Position.y, geoloc.x, geoloc.y, Input.location.lastData.altitude, 1, 1); BlocksSpawner.Instance.CleanPool(true); } //Debug.Log("Positioning Plane Augmentation at: " + result.Position); //m_PlaneAugmentation.PositionAt(result.Position); //RotateTowardCamera(m_PlaneAugmentation); break; default: Debug.LogError("Invalid Ground Plane state: " + planeMode); break; } }
public void HandleInteractiveHitTest(HitTestResult result) { Debug.Log("HandleInteractiveHitTest() called."); if (result == null) { Debug.LogError("Invalid hit test result!"); return; } // Place object based on Ground Plane mode switch (planeMode) { case PlaneMode.GROUND: if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive) { DestroyAnchors(); contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); contentPositioningBehaviour.PositionContentAtPlaneAnchor(result); if (!m_MidAirToggle.interactable) { // Runs only once after first successful Ground Anchor is created m_MidAirToggle.interactable = true; m_ResetButton.interactable = true; } } if (!m_PlaneAugmentation.activeInHierarchy) { Debug.Log("Setting Plane Augmentation to Active"); // On initial run, unhide the augmentation m_PlaneAugmentation.SetActive(true); } Debug.Log("Positioning Plane Augmentation at: " + result.Position); m_PlaneAugmentation.PositionAt(result.Position); RotateTowardCamera(m_PlaneAugmentation); break; default: Debug.LogError("Invalid Ground Plane state: " + planeMode); break; } }
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; } } }
private void Start() { m_nowState = GameState.AddingMarkers; //TODO: Initalise the class members and event listeners. GameObject myPlaneFinder = GameObject.FindGameObjectWithTag("Plane"); myLineRend = GameObject.FindGameObjectWithTag("Lines"); myTextMesh = GameObject.FindGameObjectWithTag("Text"); m_ClearBttn = Button.FindObjectOfType <Button>(); m_AnchorInputLstnrBhvr = myPlaneFinder.GetComponent <AnchorInputListenerBehaviour>(); m_ContentPositioningBhvr = myPlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_LineRenderer = myLineRend.GetComponent <LineRenderer>(); m_DistanceTextHldr = myTextMesh.GetComponent <TextMesh>(); m_ContentPositioningBhvr.OnContentPlaced.AddListener(SpawnNewMarker); m_ClearBttn.onClick.AddListener(Clear); Debug.Log("count=" + count); }
public void HandleInteractiveHitTest(HitTestResult result) { if (PlaymatIsPlaced) { return; } if (result == null) { Debug.LogError("Invalid hit test result!"); return; } m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; m_ContentPositioningBehaviour.PositionContentAtPlaneAnchor(result); m_PlaneFinder.enabled = false; PlaymatIsPlaced = true; }
} //END CheckIfAnchorBehaviourExists //-------------------------------// private void CheckIfContentPositioningBehaviourExists() //-------------------------------// { #if VUFORIA //If the PlaneFinderBehaviour doesn't exist, create it and link to it if( GetComponent<ContentPositioningBehaviour>() == null ) { contentPositioningBehaviour = gameObject.AddComponent<ContentPositioningBehaviour>(); } //Otherwise if the script exists, link to it if( contentPositioningBehaviour == null && GetComponent<ContentPositioningBehaviour>() != null ) { contentPositioningBehaviour = GetComponent<ContentPositioningBehaviour>(); } #endif } //END CheckIfContentPositioningBehaviourExists
void OnVuforiaStarted() { Debug.Log("OnVuforiaStarted() called."); m_StateManager = TrackerManager.Instance.GetStateManager(); // Check trackers to see if started and start if necessary m_PositionalDeviceTracker = TrackerManager.Instance.GetTracker <PositionalDeviceTracker>(); m_SmartTerrain = TrackerManager.Instance.GetTracker <SmartTerrain>(); if (m_PositionalDeviceTracker != null && m_SmartTerrain != null) { if (!m_PositionalDeviceTracker.IsActive) { m_PositionalDeviceTracker.Start(); } if (m_PositionalDeviceTracker.IsActive && !m_SmartTerrain.IsActive) { m_SmartTerrain.Start(); } } else { if (m_PositionalDeviceTracker == null) { Debug.Log("PositionalDeviceTracker returned null. GroundPlane not supported on this device."); } if (m_SmartTerrain == null) { Debug.Log("SmartTerrain returned null. GroundPlane not supported on this device."); } MessageBox.DisplayMessageBox(unsupportedDeviceTitle, unsupportedDeviceBody, false, null); } m_ContentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_ContentPositioningBehaviour.DuplicateStage = false; SetMidAirMode(true); }
private void SpawnDroid() { Debug.Log("SpawnDroid Setting Plane Augmentation to Active"); if (positionalDeviceTracker != null && positionalDeviceTracker.IsActive) { DestroyAnchors(); contentPositioningBehaviour = m_PlaneFinder.GetComponent <ContentPositioningBehaviour>(); contentPositioningBehaviour.PositionContentAtPlaneAnchor(currentResult); m_ResetButton.interactable = true; } if (!m_PlaneAugmentation.activeInHierarchy) { Debug.Log("Setting Plane Augmentation to Active"); // On initial run, unhide the augmentation m_PlaneAugmentation.SetActive(true); } Debug.Log("Positioning Plane Augmentation at: " + currentResult.Position); m_PlaneAugmentation.PositionAt(currentResult.Position); RotateTowardCamera(m_PlaneAugmentation); }
/* * private bool IsPointerOverGameObject(int fingerId) * { * EventSystem eventSystem = EventSystem.current; * return (eventSystem.IsPointerOverGameObject(fingerId) * && eventSystem.currentSelectedGameObject != null); * } */ // Use this for initialization void Start() { planeManager = transform.GetComponentInParent <PlaneManager>(); anchorInputListenerBehaviour = transform.GetComponent <AnchorInputListenerBehaviour>(); contentPositioningBehaviour = transform.GetComponent <ContentPositioningBehaviour>(); }
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; } 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("请先选择合影道具"); } } } }