Exemplo n.º 1
0
        private void ApplyAngles(DeviceType device, ref byte[] rawFrame)
        {
            var angles = RPY.ParseDataForOrientationAngles(rawFrame);

            if (device == DeviceType.Shirt)
            {
                AbsoluteAngles.SetUpperBodyAngles(
                    new UnityEngine.Vector3(angles.Center.Roll, angles.Center.Pitch, angles.Center.Yaw) * Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.LeftUpper.Roll, angles.LeftUpper.Pitch, angles.LeftUpper.Yaw) *
                    Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.LeftLower.Roll, angles.LeftLower.Pitch, angles.LeftLower.Yaw) *
                    Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.RightUpper.Roll, angles.RightUpper.Pitch, angles.RightUpper.Yaw) *
                    Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.RightLower.Roll, angles.RightLower.Pitch, angles.RightLower.Yaw) *
                    Mathf.Rad2Deg);
            }
            else if (device == DeviceType.Pants)
            {
                AbsoluteAngles.SetLowerBodyAngles(
                    new UnityEngine.Vector3(angles.Center.Roll, angles.Center.Pitch, angles.Center.Yaw) * Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.LeftUpper.Roll, angles.LeftUpper.Pitch, angles.LeftUpper.Yaw) *
                    Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.LeftLower.Roll, angles.LeftLower.Pitch, angles.LeftLower.Yaw) *
                    Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.RightUpper.Roll, angles.RightUpper.Pitch, angles.RightUpper.Yaw) *
                    Mathf.Rad2Deg,
                    new UnityEngine.Vector3(angles.RightLower.Roll, angles.RightLower.Pitch, angles.RightLower.Yaw) *
                    Mathf.Rad2Deg);
            }
        }
Exemplo n.º 2
0
        private void Update()
        {
            _pullInterface.PollDevices();

            if (IsShirtActive)
            {
                var upperModuleAngles = RPY.ParseDataForOrientationAngles(EnfluxPullInterface.ShirtRPY);
                if (ShirtState == DeviceState.Initializing && upperModuleAngles.IsInitialized)
                {
                    ShirtState = DeviceState.Streaming;
                    upperModuleAngles.ApplyUpperAnglesTo(AbsoluteAngles);
                    ResetFullBodyBaseOrientation();
                }
                else if (ShirtState == DeviceState.Streaming)
                {
                    upperModuleAngles.ApplyUpperAnglesTo(AbsoluteAngles);
                }
            }
            if (ArePantsActive)
            {
                var lowerModuleAngles = RPY.ParseDataForOrientationAngles(EnfluxPullInterface.PantsRPY);
                if (PantsState == DeviceState.Initializing && lowerModuleAngles.IsInitialized)
                {
                    PantsState = DeviceState.Streaming;
                    lowerModuleAngles.ApplyLowerAnglesTo(AbsoluteAngles);
                    ResetFullBodyBaseOrientation();
                }
                else if (PantsState == DeviceState.Streaming)
                {
                    lowerModuleAngles.ApplyLowerAnglesTo(AbsoluteAngles);
                }
            }
        }