コード例 #1
0
        /// <summary>
        /// Updates the current matrix of this marker node
        /// </summary>
        /// <param name="elapsedTime">Elapsed time from last update in milliseconds</param>
        public virtual void Update(float elapsedTime)
        {
            if (tracker == null && scene.MarkerTracker != null)
            {
                tracker  = scene.MarkerTracker;
                markerID = tracker.AssociateMarker(markerConfigs);
            }

            if (tracker != null && tracker.FindMarker(markerID))
            {
                Vector3    p      = new Vector3();
                Quaternion q      = Quaternion.Identity;
                Matrix     rawMat = tracker.GetMarkerTransform();

                if (smooth || predict)
                {
                    Vector3 scale;
                    rawMat.Decompose(out scale, out q, out p);
                }

                if (smooth)
                {
                    smoother.FilterMatrix(ref p, ref q, out worldTransformation);
                }
                else
                {
                    worldTransformation = rawMat;
                }

                if (isInverseViewSet)
                {
                    Matrix.Multiply(ref worldTransformation, ref inverseCameraView, out worldTransformation);
                }

                if (predict)
                {
                    predictionTime = 0;
                    predictor.UpdatePredictor(ref p, ref q);
                }

                prevMatrix = worldTransformation;
                dropout    = 0;
                found      = true;
            }
            else
            {
                if (maxDropouts < 0)
                {
                    worldTransformation = prevMatrix;
                    found = false;
                }
                else
                {
                    if (dropout < maxDropouts)
                    {
                        dropout++;
                        if (predict)
                        {
                            predictionTime += elapsedTime;
                            predictor.GetPrediction(predictionTime, out worldTransformation);
                        }
                        else
                        {
                            worldTransformation = prevMatrix;
                        }
                    }
                    else
                    {
                        found = false;
                        worldTransformation = MatrixHelper.Empty;
                    }
                }

                if (smooth)
                {
                    smoother.ResetHistory();
                }
            }
        }