Esempio n. 1
0
        public static bool ToVector3(this OSCMessage message, out Vector3 value, bool force = false)
        {
            var values = message.GetValues(OSCValueType.Float);

            if (values.Length >= 3)
            {
                var firstValue  = values[0];
                var secondValue = values[1];
                var thirdValue  = values[2];

                value = new Vector3(firstValue.FloatValue, secondValue.FloatValue, thirdValue.FloatValue);

                return(true);
            }

            if (force)
            {
                Vector2 vector2;
                if (message.ToVector2(out vector2))
                {
                    value = vector2;
                    return(true);
                }

                Vector4 vector4;
                if (message.ToVector4(out vector4))
                {
                    value = vector4;
                    return(true);
                }
            }

            value = Vector3.zero;
            return(false);
        }
Esempio n. 2
0
        protected void RightEyeEulerAnglesReceived(OSCMessage message)
        {
            Vector2 value;

            if (message.ToVector2(out value) && eyeRTransform != null)
            {
                Matrix4x4 inMatrix = Matrix4x4.Rotate(ConvertEulerAnglesToUnitySpace(new Vector3(value.x, value.y, 0)));
                eyeRTransform.transform.localRotation = (inMatrix * eyeRMatrix).rotation;
            }
        }