Exemple #1
0
        private StylusTransformData RecalculateValues(StylusTransformData data)
        {
            _oldTransform.position = _input.HMUTransform.position;
            _oldTransform.rotation = _input.HMUTransform.rotation;
            _oldTransformsQueue.Enqueue(new TransformQueueElement()
            {
                Position = _oldTransform.position, Rotation = _oldTransform.rotation
            });

            if (_queueCounter < InputManager.RECALCULATED_STYLUS_TRANSFORMATION_FRAME)
            {
                _queueCounter++;
                return(new StylusTransformData
                {
                    Position = _input.HMUTransform.TransformPoint(data.Position),
                    Rotation = _input.HMUTransform.transform.rotation * data.Rotation,
                    Acceleration = data.Rotation * data.Acceleration
                });
            }

            var old = _oldTransformsQueue.Dequeue();

            _oldTransform.position = old.Position;
            _oldTransform.rotation = old.Rotation;

            var recalculatedData = new StylusTransformData
            {
                Position     = _oldTransform.TransformPoint(data.Position),
                Rotation     = _oldTransform.rotation * data.Rotation,
                Acceleration = data.Rotation * data.Acceleration
            };

            return(recalculatedData);
        }
Exemple #2
0
        // Call of delegate for debug informations, return the complete transform data.
        internal void OnStylusTransformDataUpdateInternal(StylusTransformData data)
        {
            if (InputInstance.ShowDebugInfos)
            {
                Debug.Log(data.Position);
            }

            float delta = Time.time - _timeLastAccelerationUpdate;

            _timeLastAccelerationUpdate = Time.time;

            var info = new PositionInfo {
                DeltaTime = delta, Position = data.Position
            };

            if (_lastPositions.Count > ACCELERATION_CALCULATION_VALUE_COUNT)
            {
                _lastPositions.Dequeue();
            }

            _lastPositions.Enqueue(info);
            CalculateAcceleration();
        }
 internal void RaiseStylusTransformRawChanged(StylusTransformData stylusTransformRaw)
 {
     RaiseStylusTransformUpdate(OnStylusTransformDataRawUpdate, stylusTransformRaw);
 }
 private void RaiseStylusTransformUpdate(StylusTransformDataUpdateHandler handler, StylusTransformData stylusTransform)
 {
     if (handler != null)
     {
         handler(stylusTransform);
     }
 }
 internal void RaiseStylusTransformChanged(StylusTransformData stylusTransform)
 {
     RaiseStylusTransformUpdate(OnStylusTransformDataUpdate, stylusTransform);
 }