private void UpdateSmartTerrain(VuforiaManagerImpl.FrameState frameState, StateManagerImpl stateManager) { SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>(); if (tracker != null && tracker.SmartTerrainBuilder.GetReconstructions().Any <ReconstructionAbstractBehaviour>()) { VuforiaManagerImpl.SmartTerrainRevisionData[] array = new VuforiaManagerImpl.SmartTerrainRevisionData[frameState.numSmartTerrainRevisions]; VuforiaManagerImpl.SurfaceData[] array2 = new VuforiaManagerImpl.SurfaceData[frameState.numUpdatedSurfaces]; VuforiaManagerImpl.PropData[] array3 = new VuforiaManagerImpl.PropData[frameState.numUpdatedProps]; for (int i = 0; i < frameState.numSmartTerrainRevisions; i++) { VuforiaManagerImpl.SmartTerrainRevisionData smartTerrainRevisionData = (VuforiaManagerImpl.SmartTerrainRevisionData)Marshal.PtrToStructure(new IntPtr(frameState.smartTerrainRevisionsArray.ToInt64() + (long)(i * Marshal.SizeOf(typeof(VuforiaManagerImpl.SmartTerrainRevisionData)))), typeof(VuforiaManagerImpl.SmartTerrainRevisionData)); array[i] = smartTerrainRevisionData; } for (int j = 0; j < frameState.numUpdatedSurfaces; j++) { VuforiaManagerImpl.SurfaceData surfaceData = (VuforiaManagerImpl.SurfaceData)Marshal.PtrToStructure(new IntPtr(frameState.updatedSurfacesArray.ToInt64() + (long)(j * Marshal.SizeOf(typeof(VuforiaManagerImpl.SurfaceData)))), typeof(VuforiaManagerImpl.SurfaceData)); array2[j] = surfaceData; } for (int k = 0; k < frameState.numUpdatedProps; k++) { VuforiaManagerImpl.PropData propData = (VuforiaManagerImpl.PropData)Marshal.PtrToStructure(new IntPtr(frameState.updatedPropsArray.ToInt64() + (long)(k * Marshal.SizeOf(typeof(VuforiaManagerImpl.PropData)))), typeof(VuforiaManagerImpl.PropData)); array3[k] = propData; } ((SmartTerrainBuilderImpl)tracker.SmartTerrainBuilder).UpdateSmartTerrainData(array, array2, array3); } }
public PropAbstractBehaviour AssociateProp(PropAbstractBehaviour templateBehaviour, Prop newProp) { if (this.mActivePropBehaviours.ContainsKey(newProp.ID)) { Debug.LogWarning("Prop has already an associated behaviour"); return(null); } StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl; if (templateBehaviour != null) { if (templateBehaviour.transform.parent == base.transform) { PropAbstractBehaviour propAbstractBehaviour = ReconstructionAbstractBehaviour.InstantiatePropBehaviour(templateBehaviour); Transform transform = null; if (newProp.Parent == null) { transform = base.transform; } else if (newProp.Parent is Surface) { if (this.mActiveSurfaceBehaviours.ContainsKey(newProp.Parent.ID)) { transform = this.mActiveSurfaceBehaviours[newProp.Parent.ID].transform; } else { Debug.LogError("Parent Surface with id " + newProp.Parent.ID + " could not be found"); } } else if (newProp.Parent is Prop) { if (this.mActivePropBehaviours.ContainsKey(newProp.Parent.ID)) { transform = this.mActivePropBehaviours[newProp.Parent.ID].transform; } else { Debug.LogError("Parent Prop with id " + newProp.Parent.ID + " could not be found"); } } if (transform != null) { propAbstractBehaviour.transform.parent = transform; } propAbstractBehaviour.gameObject.SetActive(true); this.AssociatePropBehaviour(newProp, propAbstractBehaviour); this.mActivePropBehaviours.Add(newProp.ID, propAbstractBehaviour); stateManagerImpl.RegisterExternallyManagedTrackableBehaviour(propAbstractBehaviour); return(propAbstractBehaviour); } Debug.LogError("ReconstructionBehaviour.AssociateProp: provided template needs to be a child of the Reconstruction object."); } return(null); }
public override void Stop() { VuforiaWrapper.Instance.TrackerStop((int)TypeMapping.GetTypeID(typeof(ObjectTracker))); this.IsActive = false; StateManagerImpl stateManagerImpl = (StateManagerImpl)TrackerManager.Instance.GetStateManager(); using (List <DataSetImpl> .Enumerator enumerator = this.mActiveDataSets.GetEnumerator()) { while (enumerator.MoveNext()) { foreach (Trackable current in enumerator.Current.GetTrackables()) { stateManagerImpl.SetTrackableBehavioursForTrackableToNotFound(current); } } } }
internal void UpdateTrackablePoses(Transform arCameraTransform, VuforiaManagerImpl.TrackableResultData[] trackableResultDataArray, VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResultDataArray, VuforiaManager.TrackableIdPair originTrackableID, int frameIndex) { Dictionary <int, TrackableBehaviour.Status> dictionary = new Dictionary <int, TrackableBehaviour.Status>(); for (int i = 0; i < trackableResultDataArray.Length; i++) { VuforiaManagerImpl.TrackableResultData trackableResultData = trackableResultDataArray[i]; dictionary.Add(trackableResultData.id, trackableResultData.status); TrackableBehaviour trackableBehaviour; if (this.mTrackableBehaviours.TryGetValue(trackableResultData.id, out trackableBehaviour) && trackableResultData.id != originTrackableID.TrackableId && VuforiaManagerImpl.IsDetectedOrTracked(trackableResultData.status) && trackableBehaviour.enabled) { StateManagerImpl.PositionTrackable(trackableBehaviour, arCameraTransform, trackableResultData.pose, trackableResultData.timeStamp); } } Dictionary <int, TrackableBehaviour.Status> dictionary2 = new Dictionary <int, TrackableBehaviour.Status>(); for (int i = 0; i < vuMarkResultDataArray.Length; i++) { VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = vuMarkResultDataArray[i]; dictionary2.Add(vuMarkTargetResultData.resultID, vuMarkTargetResultData.status); } this.mVuMarkManager.UpdateVuMarkPoses(arCameraTransform, vuMarkResultDataArray, originTrackableID.ResultId); this.mActiveTrackableBehaviours.Clear(); TrackableBehaviour[] array = this.GetTrackableBehaviours().ToArray <TrackableBehaviour>(); for (int i = 0; i < array.Length; i++) { TrackableBehaviour trackableBehaviour2 = array[i]; if (trackableBehaviour2.enabled) { TrackableBehaviour.Status vuforiaStatus; if (dictionary.TryGetValue(trackableBehaviour2.Trackable.ID, out vuforiaStatus) || (trackableBehaviour2 is VuMarkAbstractBehaviour && dictionary2.TryGetValue(((VuMarkAbstractBehaviour)trackableBehaviour2).VuMarkResultId, out vuforiaStatus))) { this.mExtendedTrackingManager.ApplyTrackingState(trackableBehaviour2, vuforiaStatus, arCameraTransform); trackableBehaviour2.OnFrameIndexUpdate(frameIndex); } else { this.mExtendedTrackingManager.ApplyTrackingState(trackableBehaviour2, TrackableBehaviour.Status.NOT_FOUND, arCameraTransform); } if (VuforiaManagerImpl.IsDetectedOrTracked(trackableBehaviour2.CurrentStatus)) { this.mActiveTrackableBehaviours.Add(trackableBehaviour2); } } } }
public override ImageTargetAbstractBehaviour EnableTracking(TargetFinder.TargetSearchResult result, GameObject gameObject) { IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ImageTargetData))); int num = VuforiaWrapper.Instance.TargetFinderEnableTracking(result.TargetSearchResultPtr, intPtr); ImageTargetData imageTargetData = (ImageTargetData)Marshal.PtrToStructure(intPtr, typeof(ImageTargetData)); Marshal.FreeHGlobal(intPtr); StateManagerImpl stateManagerImpl = (StateManagerImpl)TrackerManager.Instance.GetStateManager(); ImageTargetAbstractBehaviour result2 = null; if (imageTargetData.id == -1) { Debug.LogError("TargetSearchResult " + result.TargetName + " could not be enabled for tracking."); } else { ImageTarget imageTarget = new CloudRecoImageTargetImpl(result.TargetName, imageTargetData.id, imageTargetData.size); this.mImageTargets[imageTargetData.id] = imageTarget; result2 = stateManagerImpl.FindOrCreateImageTargetBehaviourForTrackable(imageTarget, gameObject); } IntPtr intPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * num); VuforiaWrapper.Instance.TargetFinderGetImageTargets(intPtr2, num); List <int> list = new List <int>(); for (int i = 0; i < num; i++) { int item = Marshal.ReadInt32(new IntPtr(intPtr2.ToInt64() + (long)(i * Marshal.SizeOf(typeof(int))))); list.Add(item); } Marshal.FreeHGlobal(intPtr2); ImageTarget[] array = this.mImageTargets.Values.ToArray <ImageTarget>(); for (int j = 0; j < array.Length; j++) { ImageTarget imageTarget2 = array[j]; if (!list.Contains(imageTarget2.ID)) { stateManagerImpl.DestroyTrackableBehavioursForTrackable(imageTarget2, true); this.mImageTargets.Remove(imageTarget2.ID); } } return(result2); }
internal void UpdateVuMarkPoses(Transform arCameraTransform, VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResults, int originTrackableResultId) { for (int i = 0; i < vuMarkResults.Length; i++) { VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = vuMarkResults[i]; VuMarkAbstractBehaviour activeBehaviour = this.GetActiveBehaviour(vuMarkTargetResultData.targetID, vuMarkTargetResultData.resultID); if (activeBehaviour != null) { if (vuMarkTargetResultData.resultID != originTrackableResultId) { StateManagerImpl.PositionTrackable(activeBehaviour, arCameraTransform, vuMarkTargetResultData.pose, vuMarkTargetResultData.timeStamp); } } else { Debug.Log(string.Format("Have a null behaviour while iterating over VuMarkResults: resultID={0}, targetID={1}", vuMarkTargetResultData.targetID, vuMarkTargetResultData.resultID)); } } }
private void UnregisterDeletedSurfaces(List <Surface> deletedSurfaces) { StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl; foreach (Surface current in deletedSurfaces) { if (this.mActiveSurfaceBehaviours.ContainsKey(current.ID)) { SurfaceAbstractBehaviour surfaceAbstractBehaviour = this.mActiveSurfaceBehaviours[current.ID]; if (surfaceAbstractBehaviour != null) { surfaceAbstractBehaviour.OnTrackerUpdate(TrackableBehaviour.Status.NOT_FOUND); surfaceAbstractBehaviour.UnregisterTrackable(); UnityEngine.Object.Destroy(surfaceAbstractBehaviour.gameObject); } this.mActiveSurfaceBehaviours.Remove(current.ID); stateManagerImpl.UnregisterExternallyManagedTrackableBehaviour(current.ID); } } }
private void UpdateProjection() { if (!VuforiaRuntimeUtilities.IsVuforiaEnabled()) { return; } if (VuforiaRuntimeUtilities.IsPlayMode()) { Matrix4x4 projectionGL = VuforiaUnity.GetProjectionGL(this.mPrimaryCamera.nearClipPlane, this.mPrimaryCamera.farClipPlane, this.mProjectionOrientation); this.ApplyMatrix(this.mPrimaryCamera, projectionGL); this.ApplyMatrix(this.mSecondaryCamera, projectionGL); return; } Device instance = Device.Instance; this.mLastAppliedNearClipPlane = this.mNewNearClipPlane; this.mLastAppliedFarClipPlane = this.mNewFarClipPlane; Matrix4x4 projectionMatrix = instance.GetProjectionMatrix(View.VIEW_LEFTEYE, this.mPrimaryCamera.nearClipPlane, this.mPrimaryCamera.farClipPlane, this.mProjectionOrientation); Matrix4x4 projectionMatrix2 = instance.GetProjectionMatrix(View.VIEW_RIGHTEYE, this.mPrimaryCamera.nearClipPlane, this.mPrimaryCamera.farClipPlane, this.mProjectionOrientation); Matrix4x4 eyeDisplayAdjustmentMatrix = instance.GetEyeDisplayAdjustmentMatrix(View.VIEW_LEFTEYE); Matrix4x4 eyeDisplayAdjustmentMatrix2 = instance.GetEyeDisplayAdjustmentMatrix(View.VIEW_RIGHTEYE); EyewearDevice eyewearDevice = Device.Instance as EyewearDevice; if (eyewearDevice != null && eyewearDevice.IsSeeThru()) { DedicatedEyewearCameraConfiguration.SetProjectionAndOffset(this.mPrimaryCamera, projectionMatrix, eyeDisplayAdjustmentMatrix); DedicatedEyewearCameraConfiguration.SetProjectionAndOffset(this.mSecondaryCamera, projectionMatrix2, eyeDisplayAdjustmentMatrix2); } else { this.mPrimaryCamera.projectionMatrix = projectionMatrix; this.mSecondaryCamera.projectionMatrix = projectionMatrix2; this.mPrimaryCamera.transform.localPosition = -eyeDisplayAdjustmentMatrix.GetColumn(3); this.mPrimaryCamera.transform.localRotation = StateManagerImpl.ExtractRotationFromMatrix(eyeDisplayAdjustmentMatrix); this.mSecondaryCamera.transform.localPosition = -eyeDisplayAdjustmentMatrix2.GetColumn(3); this.mSecondaryCamera.transform.localRotation = StateManagerImpl.ExtractRotationFromMatrix(eyeDisplayAdjustmentMatrix2); } this.mPrimaryCamera.rect = instance.GetNormalizedViewport(View.VIEW_LEFTEYE); this.mSecondaryCamera.rect = instance.GetNormalizedViewport(View.VIEW_RIGHTEYE); }
public override bool DeactivateDataSet(DataSet dataSet) { if (dataSet == null) { Debug.LogError("Dataset is null."); return(false); } DataSetImpl dataSetImpl = (DataSetImpl)dataSet; if (VuforiaWrapper.Instance.ObjectTrackerDeactivateDataSet(dataSetImpl.DataSetPtr) == 0) { Debug.LogError("Could not deactivate dataset."); return(false); } StateManagerImpl stateManagerImpl = (StateManagerImpl)TrackerManager.Instance.GetStateManager(); foreach (Trackable current in dataSet.GetTrackables()) { stateManagerImpl.EnableTrackableBehavioursForTrackable(current, false); } this.mActiveDataSets.Remove(dataSetImpl); return(true); }
private void UpdateTrackers(VuforiaManagerImpl.FrameState frameState) { this.UnmarshalTrackables(frameState); this.UnmarshalWordTrackables(frameState); this.UnmarshalVuMarkTrackables(frameState); this.UpdateTrackableFoundQueue(); StateManagerImpl stateManagerImpl = (StateManagerImpl)TrackerManager.Instance.GetStateManager(); this.UpdateSmartTerrain(frameState, stateManagerImpl); this.UpdateExtendedTrackedVuMarks(); stateManagerImpl.UpdateVuMarks(this.mVuMarkDataArray, this.mVuMarkResultDataArray); VuforiaManager.TrackableIdPair trackableIdPair = new VuforiaManager.TrackableIdPair { ResultId = -1, TrackableId = -1 }; int num = -1; if (this.mWorldCenterMode == VuforiaARController.WorldCenterMode.SPECIFIC_TARGET) { if (this.mVuMarkWorldCenter != null && this.mVuMarkWorldCenter.VuMarkTemplate != null) { this.mWorldCenter = this.GetVuMarkWorldCenter(this.mVuMarkWorldCenter.VuMarkTemplate.ID); } if (this.mWorldCenter != null && this.mWorldCenter.Trackable != null) { if (this.mWorldCenter is VuMarkAbstractBehaviour) { trackableIdPair.ResultId = ((VuMarkAbstractBehaviour)this.mWorldCenter).VuMarkResultId; } else { trackableIdPair.TrackableId = this.mWorldCenter.Trackable.ID; } } } else if (this.mWorldCenterMode == VuforiaARController.WorldCenterMode.FIRST_TARGET) { stateManagerImpl.RemoveDisabledTrackablesFromQueue(ref this.mTrackableFoundQueue); if (this.mTrackableFoundQueue.Count > 0) { trackableIdPair = this.mTrackableFoundQueue.First.Value; } } else if (this.mWorldCenterMode == VuforiaARController.WorldCenterMode.DEVICE_TRACKING) { num = frameState.deviceTrackableId; } DeviceTrackingManager deviceTrackingManager = stateManagerImpl.GetDeviceTrackingManager(); if (num != -1) { deviceTrackingManager.UpdateCamera(this.mCentralAnchorPoint, this.mTrackableResultDataArray, num); } else { RotationalPlayModeDeviceTrackerImpl rotationalPlayModeDeviceTrackerImpl = TrackerManager.Instance.GetTracker <DeviceTracker>() as RotationalPlayModeDeviceTrackerImpl; if (rotationalPlayModeDeviceTrackerImpl != null && rotationalPlayModeDeviceTrackerImpl.IsActive) { VuforiaManagerImpl.TrackableResultData trackable = rotationalPlayModeDeviceTrackerImpl.GetTrackable(); deviceTrackingManager.UpdateCamera(this.mCentralAnchorPoint, new VuforiaManagerImpl.TrackableResultData[] { trackable }, trackable.id); } else if (trackableIdPair.TrackableId >= 0 || trackableIdPair.ResultId >= 0) { VuforiaManagerImpl.TrackableResultData trackableResultData = this.GetTrackableResultData(trackableIdPair, true); if (VuforiaManagerImpl.IsDetectedOrTracked(trackableResultData.status)) { stateManagerImpl.UpdateCameraPoseWRTTrackable(this.mCentralAnchorPoint, this.mParentAnchorPoint, trackableIdPair, trackableResultData.pose); } } } if (this.mARCameraTransform != this.mCentralAnchorPoint) { this.mARCameraTransform.position = this.mCentralAnchorPoint.position; this.mARCameraTransform.rotation = this.mCentralAnchorPoint.rotation; } stateManagerImpl.UpdateTrackablePoses(this.mARCameraTransform, this.mTrackableResultDataArray, this.mVuMarkResultDataArray, trackableIdPair, frameState.frameIndex); stateManagerImpl.UpdateWords(this.mARCameraTransform, this.mWordDataArray, this.mWordResultDataArray); stateManagerImpl.UpdateVirtualButtons(frameState.numVirtualButtonResults, frameState.vbDataArray); }
private void UpdateExtendedTrackedVuMarks() { StateManagerImpl expr_0F = (StateManagerImpl)TrackerManager.Instance.GetStateManager(); VuforiaManager.TrackableIdPair[] array = expr_0F.GetExtendedTrackingManager().GetExtendedTrackedBehaviours().ToArray <VuforiaManager.TrackableIdPair>(); VuMarkManagerImpl vuMarkManagerImpl = (VuMarkManagerImpl)expr_0F.GetVuMarkManager(); List <int> list = new List <int>(); for (int i = 0; i < this.mVuMarkResultDataArray.Length; i++) { list.Add(this.mVuMarkResultDataArray[i].resultID); } Dictionary <int, List <int> > dictionary = new Dictionary <int, List <int> >(); VuforiaManager.TrackableIdPair[] array2 = array; for (int j = 0; j < array2.Length; j++) { int resultId = array2[j].ResultId; VuMarkAbstractBehaviour behaviourWithResultID = vuMarkManagerImpl.GetBehaviourWithResultID(resultId); if (behaviourWithResultID != null) { int iD = behaviourWithResultID.VuMarkTarget.ID; if (!list.Contains(resultId)) { if (!dictionary.ContainsKey(iD)) { dictionary[iD] = new List <int>(); } dictionary[iD].Add(resultId); } else { list.Remove(resultId); } } } for (int k = 0; k < this.mVuMarkResultDataArray.Length; k++) { int targetID = this.mVuMarkResultDataArray[k].targetID; int resultID = this.mVuMarkResultDataArray[k].resultID; if (list.Contains(resultID) && dictionary.ContainsKey(targetID)) { List <int> list2 = dictionary[targetID]; if (list2.Count > 0) { int num = list2[list2.Count - 1]; list2.RemoveAt(list2.Count - 1); Debug.Log(string.Concat(new object[] { "CHANGE RESULT ID ", this.mVuMarkResultDataArray[k].resultID, " => ", num })); this.mVuMarkResultDataArray[k].resultID = num; } } } List <VuforiaManagerImpl.VuMarkTargetResultData> list3 = this.mVuMarkResultDataArray.ToList <VuforiaManagerImpl.VuMarkTargetResultData>(); array2 = array; for (int j = 0; j < array2.Length; j++) { VuforiaManager.TrackableIdPair trackableIdPair = array2[j]; if (trackableIdPair.ResultId >= 0) { bool flag = false; VuforiaManagerImpl.VuMarkTargetResultData[] array3 = this.mVuMarkResultDataArray; for (int l = 0; l < array3.Length; l++) { if (array3[l].resultID == trackableIdPair.ResultId) { flag = true; break; } } if (!flag) { VuMarkAbstractBehaviour behaviourWithResultID2 = vuMarkManagerImpl.GetBehaviourWithResultID(trackableIdPair.ResultId); list3.Add(new VuforiaManagerImpl.VuMarkTargetResultData { pose = new VuforiaManagerImpl.PoseData { coordinateSystem = TrackableBehaviour.CoordinateSystem.WORLD, position = behaviourWithResultID2.transform.position, orientation = behaviourWithResultID2.transform.rotation * Quaternion.AngleAxis(90f, Vector3.right) }, resultID = trackableIdPair.ResultId, targetID = behaviourWithResultID2.VuMarkTarget.ID, status = TrackableBehaviour.Status.EXTENDED_TRACKED }); } } } this.mVuMarkResultDataArray = list3.ToArray(); HashSet <int> hashSet = new HashSet <int>(); array2 = array; for (int j = 0; j < array2.Length; j++) { VuforiaManager.TrackableIdPair trackableIdPair2 = array2[j]; if (trackableIdPair2.ResultId >= 0) { VuMarkAbstractBehaviour behaviourWithResultID3 = vuMarkManagerImpl.GetBehaviourWithResultID(trackableIdPair2.ResultId); if (behaviourWithResultID3 != null && behaviourWithResultID3.VuMarkTarget != null) { hashSet.Add(behaviourWithResultID3.VuMarkTarget.ID); } } } List <VuforiaManagerImpl.VuMarkTargetData> list4 = new List <VuforiaManagerImpl.VuMarkTargetData>(); for (int m = 0; m < this.mVuMarkDataArray.Length; m++) { int id = this.mVuMarkDataArray[m].id; if (!hashSet.Contains(id)) { list4.Add(this.mVuMarkDataArray[m]); } } this.mVuMarkDataArray = list4.ToArray(); }
public SurfaceAbstractBehaviour AssociateSurface(SurfaceAbstractBehaviour templateBehaviour, Surface newSurface) { if (this.mActiveSurfaceBehaviours.ContainsKey(newSurface.ID)) { Debug.LogWarning("Surface has already an associated behaviour"); return(null); } StateManagerImpl stateManagerImpl = TrackerManager.Instance.GetStateManager() as StateManagerImpl; if (templateBehaviour != null) { if (templateBehaviour.transform.parent == base.transform) { SurfaceAbstractBehaviour surfaceAbstractBehaviour = ReconstructionAbstractBehaviour.InstantiateSurfaceBehaviour(templateBehaviour); Transform transform = null; if (newSurface.Parent == null) { transform = base.transform; } else if (newSurface.Parent is Surface) { if (this.mActiveSurfaceBehaviours.ContainsKey(newSurface.Parent.ID)) { transform = this.mActiveSurfaceBehaviours[newSurface.Parent.ID].transform; } else { Debug.LogError("Parent Surface with id " + newSurface.Parent.ID + " could not be found"); } } else if (newSurface.Parent is Prop) { if (this.mActivePropBehaviours.ContainsKey(newSurface.Parent.ID)) { transform = this.mActivePropBehaviours[newSurface.Parent.ID].transform; } else { Debug.LogError("Parent Prop with id " + newSurface.Parent.ID + " could not be found"); } } if (transform != null) { surfaceAbstractBehaviour.transform.parent = transform; } surfaceAbstractBehaviour.gameObject.SetActive(true); this.AssociateSurfaceBehaviour(newSurface, surfaceAbstractBehaviour); this.mActiveSurfaceBehaviours.Add(newSurface.ID, surfaceAbstractBehaviour); stateManagerImpl.RegisterExternallyManagedTrackableBehaviour(surfaceAbstractBehaviour); if (VuforiaManager.Instance.WorldCenterMode == VuforiaARController.WorldCenterMode.SPECIFIC_TARGET) { if (VuforiaManager.Instance.WorldCenter == (WorldCenterTrackableBehaviour)templateBehaviour) { VuforiaManager.Instance.WorldCenter = surfaceAbstractBehaviour; this.mPreviouslySetWorldCenterSurfaceTemplate = templateBehaviour; } else if ((VuforiaManager.Instance.WorldCenter == null || VuforiaManager.Instance.WorldCenter.Equals(null)) && this.mPreviouslySetWorldCenterSurfaceTemplate == templateBehaviour) { VuforiaManager.Instance.WorldCenter = surfaceAbstractBehaviour; } } return(surfaceAbstractBehaviour); } Debug.LogError("ReconstructionBehaviour.AssociateSurface: provided template needs to be a child of the Reconstruction object."); } return(null); }
private void OnVuforiaInitialized() { this.CorrectCameraConfiguration(); VuforiaManager.Instance.CentralAnchorPoint = this.mCentralAnchorPoint; VuforiaManager.Instance.ParentAnchorPoint = this.mParentAnchorPoint; if (!VuforiaRuntimeUtilities.IsVuforiaEnabled()) { return; } if (this.mEyewearType == DigitalEyewearARController.EyewearType.None || this.mEyewearType == DigitalEyewearARController.EyewearType.OpticalSeeThrough) { Device.Instance.SetViewerActive(false); } else if (this.mEyewearType == DigitalEyewearARController.EyewearType.VideoSeeThrough) { Device.Instance.SetViewerActive(false); if (this.mStereoFramework == DigitalEyewearARController.StereoFramework.Vuforia) { if (this.mUseCustomViewer) { CustomViewerParameters customViewerParameters = new CustomViewerParameters(this.mCustomViewer.Version, this.mCustomViewer.Name, this.mCustomViewer.Manufacturer); customViewerParameters.SetButtonType(this.mCustomViewer.ButtonType); customViewerParameters.SetScreenToLensDistance(this.mCustomViewer.ScreenToLensDistance); customViewerParameters.SetInterLensDistance(this.mCustomViewer.InterLensDistance); customViewerParameters.SetTrayAlignment(this.mCustomViewer.TrayAlignment); customViewerParameters.SetLensCentreToTrayDistance(this.mCustomViewer.LensCenterToTrayDistance); customViewerParameters.AddDistortionCoefficient(this.mCustomViewer.DistortionCoefficients[0]); customViewerParameters.AddDistortionCoefficient(this.mCustomViewer.DistortionCoefficients[1]); customViewerParameters.SetFieldOfView(this.mCustomViewer.FieldOfView); customViewerParameters.SetContainsMagnet(this.mCustomViewer.ContainsMagnet); Device.Instance.SelectViewer(customViewerParameters); } else { IViewerParametersList viewerList = Device.Instance.GetViewerList(); if (viewerList != null) { IViewerParameters vp = viewerList.Get(this.mViewerName, this.mViewerManufacturer); if (!Device.Instance.SelectViewer(vp)) { Debug.LogWarning("Couldn't select viewer " + this.mViewerName); } } else { Debug.LogWarning("Couldn't select viewer " + this.mViewerName + "(no viewer available)"); } } } else { string text = ""; if (this.mStereoFramework == DigitalEyewearARController.StereoFramework.GearVR) { text = "GEARVR"; } else if (this.mStereoFramework == DigitalEyewearARController.StereoFramework.Cardboard) { text = "CARDBOARD"; } IViewerParametersList viewerList2 = Device.Instance.GetViewerList(); if (viewerList2 != null) { viewerList2.SetSDKFilter(text); if (viewerList2.Size() > 0) { Device.Instance.SelectViewer(viewerList2.Get(0)); } else { Debug.LogWarning(text + " is not supported"); } } } Device.Instance.SetViewerActive(true); } StateManagerImpl stateManagerImpl = (StateManagerImpl)TrackerManager.Instance.GetStateManager(); if (this.mEyewearType == DigitalEyewearARController.EyewearType.OpticalSeeThrough && this.mSeeThroughConfiguration == DigitalEyewearARController.SeeThroughConfiguration.HoloLens) { stateManagerImpl.SetExtendedTrackingManager(new HoloLensExtendedTrackingManager()); if (Screen.orientation != ScreenOrientation.Landscape) { Screen.autorotateToPortrait = false; Screen.autorotateToPortraitUpsideDown = false; Screen.autorotateToLandscapeLeft = false; Screen.autorotateToLandscapeRight = false; Screen.orientation = ScreenOrientation.Landscape; return; } } else { stateManagerImpl.SetExtendedTrackingManager(new VuforiaExtendedTrackingManager()); this.mSetFocusPlaneAutomatically = false; } }