コード例 #1
0
        /// <summary>
        /// Returns the float value of the given label. Can be redefined in children classes to change the smoothing logic. Current smoothing logic is as follows:<para><example> <see cref="GenericDeviceController.Smoothing"/> ? <see cref="Smoother.Average(Queue{Vector3})"/> : queue.LastOrDefault()</example></para>
        /// </summary>
        /// <param name="label">The label to get the float value.</param>
        /// <returns>A float value of the given label.</returns>
        public virtual float GetFloat(string label)
        {
            if (FloatQueues.ContainsKey(label) == false)
            {
                return(0f);
            }

            var @lock = FloatLocks[label];
            var queue = FloatQueues[label];

            lock (@lock)
            {
                return(Controller.Smoothing ? Smoother.Average(queue) : queue.Count == 0 ? 0f : queue.Last().Value);
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns the Quaternion representing the rotation of the given label. Can be redefined in children classes to change the smoothing logic. Current smoothing logic is as follows:<para><example> <see cref="GenericDeviceController.Smoothing"/> ? <see cref="Smoother.Average(Queue{Quaternion})"/> : queue.LastOrDefault()</example></para>
        /// </summary>
        /// <param name="label">The label to get the rotation.</param>
        /// <returns>A Quaternion representing the rotation of the given label.</returns>
        public virtual Quaternion GetRotation(string label)
        {
            if (RotationLocks.ContainsKey(label) == false)
            {
                return(Quaternion.identity);
            }

            var @lock = RotationLocks[label];
            var queue = RotationQueues[label];

            lock (@lock)
            {
                return(Controller.Smoothing ? Smoother.Average(queue) : queue.Count == 0 ? Quaternion.identity : queue.Last().Rotation);
            }
        }
コード例 #3
0
        /// <summary>
        /// Returns the Vector3 representing the position of the given label. Can be redefined in children classes to change the smoothing logic. Current smoothing logic is as follows:<para><example> <see cref="GenericDeviceController.Smoothing"/> ? <see cref="Smoother.Average(System.Collections.Generic.Queue{Neurorehab.Scripts.Devices.UdpPosition})"/> : queue.LastOrDefault()</example></para>
        /// </summary>
        /// <param name="label">The label to get the rotation.</param>
        /// <returns>A Vector3 representing the rotation of the given label.</returns>
        public virtual Vector3 GetPosition(string label)
        {
            if (PositionLocks.ContainsKey(label) == false)
            {
                return(Vector3.zero);
            }

            var @lock = PositionLocks[label];
            var queue = PositionQueues[label];

            lock (@lock)
            {
                return((Controller.Smoothing ?
                        Smoother.Average(queue) : queue.Count == 0 ?
                        Vector3.zero : queue.Last().Position) * Controller.PositionMultiplier);
            }
        }
コード例 #4
0
        /// <summary>
        /// Returns the Vector3 representing the position of the given label according to the <see cref="GenericDeviceController.Smoothing"/> and <see cref="GenericDeviceController.PositionMultiplier"/>.
        /// </summary>
        /// <param name="label">The label to get the rotation.</param>
        /// <returns>A Vector3 representing the rotation of the given label where the x and z are multiplied by the <see cref="GenericDeviceController.PositionMultiplier"/>.</returns>
        public override Vector3 GetPosition(string label)
        {
            if (PositionLocks.ContainsKey(label) == false)
            {
                return(Vector3.zero);
            }

            var @lock = PositionLocks[label];
            var queue = PositionQueues[label];

            Vector3 position;

            lock (@lock)
            {
                position = Controller.Smoothing ?
                           Smoother.Average(queue) : queue.Count == 0 ?
                           Vector3.zero : queue.Last().Position;
            }

            return(new Vector3(position.x * Controller.PositionMultiplier, position.y,
                               position.z * Controller.PositionMultiplier));
        }