public ViewData(RelativeOrientation r)
        {
            this._ro = r;
            InitializeComponent();
            this.Text = Resources.Prog_Name+" - 相对定向元素查看";

            FillData();
        }
        public ViewData(RelativeOrientation r)
        {
            this._ro = r;
            InitializeComponent();
            this.Text = Resources.Prog_Name + " - 相对定向元素查看";

            FillData();
        }
    // Update is called once per frame
    void Update()
    {
        statDeltaCurrent += Time.deltaTime;
        if (statDeltaCurrent > statDelta)
        {
            trackStats(Time.time);
            statDeltaCurrent = 0;
        }



        switch (trackingMode)
        {
        case TrackingMode.tracking:

            if (checkForWallPass())
            {
                Debug.Log("Wall pass");

                //reset unity viewpoint to path.

                Vector3 deltaMove = GetComponent <RouteProgressController>().progressPosition - unityViewpoint.transform.position + new Vector3(0f, statDeviceHeight, 0f);

                RelativeOrientation r = ARCoreDevice.GetComponent <RelativeOrientation>();

                r.worldOffsetPostion = new Vector3(r.worldOffsetPostion.x + deltaMove.x, r.worldOffsetPostion.y + deltaMove.y, r.worldOffsetPostion.z + deltaMove.z);
            }


            break;

        case TrackingMode.ghosting:

            routeProgress.progress = ghostingProgressStart + ghostingProgressSpeed * (Time.time - ghostingTimeStart);
            //unityViewpoint.transform.position = routeProgress.getRoutePosition(routeProgress.progress) + new Vector3(0f, 1.4f, 0f);

            unityViewpoint.transform.position = routeProgress.getRoutePosition(routeProgress.progress) + new Vector3(0f, 1.4f, 0f);

            //get orientation from gyro instead arcore

            /*
             * RelativeOrientation ro= ARCoreDevice.GetComponent<RelativeOrientation>()
             * unityViewpoint.transform.rotation = TrackingUpdate.GyroQuaternion()*Quaternion.Loo(ro.rotOffX,ro.rotOffY,ro.rotOffZ);
             *
             * FindObjectOfType<messageController>().message("Gyro:\n"+ TrackingUpdate.GyroQuaternion().ToString(), 4.0f, "gyro");
             * FindObjectOfType<messageController>().message("Gyro active:\n" + Input.gyro.enabled, 1.0f, "gyro2");
             */
            break;
        }
    }
        /// <summary>
        /// 相对定向
        /// </summary>
        private void button3_Click(object sender, EventArgs e)
        {
            if (this._imgPane == null)
            {
                MessageBox.Show("请先打开数据并计算像平面坐标", Resources.Prog_Name, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                _rO = new RelativeOrientation(_imgPane.GetDictionaryForCalculation(), _camPara);
                _rO.SetLimit(0.3e-4); //书P83(5-27)下面要求
                _rO.Process();

                new ViewData(_rO).Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.Prog_Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    public void trackingGained()
    {
        if (trackingMode == TrackingMode.ghosting)
        {
            FindObjectOfType <messageController>().message("Tracking wiederhergestellt.", 4.0f, "ghostingStatus");
            trackingMode = TrackingMode.tracking;



            Vector3 desiredPosition = unityViewpoint.transform.position;

            RelativeOrientation r = ARCoreDevice.GetComponent <RelativeOrientation>();
            r.enabled      = true;
            r.trackingType = RelativeOrientation.TrackingType.RotationAndPosition;
            r.apply();
            r.apply();


            r.worldOffsetPostion = desiredPosition - unityViewpoint.transform.position;

            Input.gyro.enabled = false;
        }
    }
        /// <summary>
        /// Controller for AugmentedImage example.
        /// </summary>
        /// <summary>
        /// A prefab for visualizing an AugmentedImage.
        /// </summary>



        /// <summary>
        /// The Unity Update method.
        /// </summary>
        public void Update()
        {
            // Check that motion tracking is tracking.
            if (Session.Status != SessionStatus.Tracking)
            {
                isTracking = true;
                return;
            }
            else
            {
                isTracking = false;
            }

            // Get updated augmented images for this frame.
            Session.GetTrackables <AugmentedImage>(m_TempAugmentedImages, TrackableQueryFilter.Updated);

            // Create visualizers and anchors for updated augmented images that are tracking and do not previously
            // have a visualizer. Remove visualizers for stopped images.
            foreach (var image in m_TempAugmentedImages)
            {
                int status = 0;
                imTrackStatus.TryGetValue(image.DatabaseIndex, out status);
                if (image.TrackingState == TrackingState.Tracking && status == 0)
                {
                    // Create an anchor to ensure that ARCore keeps tracking this augmented image.
                    // TODO: Is this anchor automatically removed when no longer in use?

                    anchor = image.CreateAnchor(image.CenterPose);


                    //Find associated Markerobject in Gameworld

                    foreach (scrMarker marker in FindObjectsOfType <scrMarker>())
                    {
                        if (marker.augmentedImageDbIndex == image.DatabaseIndex)
                        {
                            RelativeOrientation r = gameObject.GetComponent <RelativeOrientation>();
                            r.AnchorSource = anchor.gameObject;
                            r.AnchorTarget = marker.gameObject;


                            if (controller.gameObject.GetComponent <RouteProgressController>().route.Length == 0)
                            {
                                controller.setMenuPreset(1);
                            }

                            GetComponent <RelativeOrientation>().worldOffsetPostion = Vector3.zero;
                            FindObjectOfType <messageController>().message("Marker gescannt.", 3.7f, "markerScanned");

                            break;
                        }
                    }



                    imTrackStatus.Add(image.DatabaseIndex, 1);
                }
                else
                {
                    if (image.TrackingState == TrackingState.Tracking)
                    {
                        foreach (scrMarker marker in FindObjectsOfType <scrMarker>())
                        {
                            if (marker.augmentedImageDbIndex == image.DatabaseIndex)
                            {
                                RelativeOrientation r = gameObject.GetComponent <RelativeOrientation>();
                                r.AnchorSource = anchor.gameObject;
                                r.AnchorTarget = marker.gameObject;


                                if (controller.gameObject.GetComponent <RouteProgressController>().route.Length == 0)
                                {
                                    controller.setMenuPreset(1);
                                }

                                GetComponent <RelativeOrientation>().worldOffsetPostion = Vector3.zero;
                                FindObjectOfType <messageController>().message("Marker gescannt.", 3.7f, "markerScanned");

                                break;
                            }
                        }
                    }
                    else if (image.TrackingState == TrackingState.Stopped && status != 0)
                    {
                        imTrackStatus.Remove(image.DatabaseIndex);
                    }
                }
            }
        }
Example #7
0
 /// <summary>
 /// Sets the specified linear motor axis using a specific relative orientation mode.
 /// </summary>
 /// <param name="index">The index of the linear motor axis to set.</param>
 /// <param name="relativeMode">The relative orientation mode of the specified axis.</param>
 /// <param name="ax">The x-component of the linear motor axis.</param>
 /// <param name="ay">The y-component of the linear motor axis.</param>
 /// <param name="az">The z-component of the linear motor axis.</param>
 public void SetAxis(int index, RelativeOrientation relativeMode, dReal ax, dReal ay, dReal az)
 {
     NativeMethods.dJointSetLMotorAxis(id, index, relativeMode, ax, ay, az);
 }
Example #8
0
 /// <summary>
 /// Sets the specified linear motor axis using a specific relative orientation mode.
 /// </summary>
 /// <param name="index">The index of the linear motor axis to set.</param>
 /// <param name="relativeMode">The relative orientation mode of the specified axis.</param>
 /// <param name="axis">The linear motor axis.</param>
 public void SetAxis(int index, RelativeOrientation relativeMode, Vector3 axis)
 {
     NativeMethods.dJointSetLMotorAxis(id, index, relativeMode, axis.X, axis.Y, axis.Z);
 }