Exemplo n.º 1
0
        protected override void Update()
        {
            if (!VuforiaRuntimeUtilities.IsPlayMode())
            {
                return;
            }
            RotationalPlayModeDeviceTrackerImpl rotationalPlayModeDeviceTrackerImpl = TrackerManager.Instance.GetTracker <DeviceTracker>() as RotationalPlayModeDeviceTrackerImpl;

            if (rotationalPlayModeDeviceTrackerImpl == null)
            {
                return;
            }
            Vector3 rotation = rotationalPlayModeDeviceTrackerImpl.Rotation;

            if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
            {
                float num = Input.GetAxis("Mouse X") * 100f * Time.deltaTime;
                rotation.z += num;
                rotation.z  = Mathf.Clamp(rotation.z, -90f, 90f);
                rotationalPlayModeDeviceTrackerImpl.Rotation = rotation;
            }
            else
            {
                float num2 = Mathf.Abs(rotation.z);
                if (num2 > 0f)
                {
                    float num3 = 100f * Time.deltaTime;
                    if (num2 < num3)
                    {
                        rotation.z = 0f;
                    }
                    else
                    {
                        rotation.z += -Mathf.Sign(rotation.z) * num3;
                    }
                    rotationalPlayModeDeviceTrackerImpl.Rotation = rotation;
                }
            }
            if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
            {
                float num4 = Input.GetAxis("Mouse X") * 100f * Time.deltaTime;
                rotation.y += num4;
                float num5 = -Input.GetAxis("Mouse Y") * 100f * Time.deltaTime;
                rotation.x += num5;
                rotationalPlayModeDeviceTrackerImpl.Rotation = rotation;
            }
        }
        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);
        }