Ejemplo n.º 1
0
        private Vector3 ReadVector3Attribute(XmlNode node, string key, float defaultValue, bool directional = true)
        {
            if (!node.TryGetAttribute(key, out var attribute))
            {
                return(new Vector3(defaultValue, defaultValue, defaultValue));
            }

            var values = ReadFloatArray(attribute);
            var x      = GetValueByIndex(values, 0, defaultValue);
            var y      = GetValueByIndex(values, 1, defaultValue);
            var z      = GetValueByIndex(values, 2, defaultValue);
            var vector = CoordinateUtility.ToUnityCoordinate(x, y, z, directional);

            return(vector);
        }
Ejemplo n.º 2
0
        private Quaternion ReadRotationAttribute(XmlNode node)
        {
            if (node.TryGetAttribute("rotation", out var attribute))
            {
                var values = ReadFloatArray(attribute);
                if (values.Count < 4)
                {
                    return(Quaternion.identity);
                }

                var x        = values[0];
                var y        = values[1];
                var z        = values[2];
                var w        = values[3];
                var rotation = CoordinateUtility.ToUnityCoordinate(x, y, z, w);
                rotation.Normalize();
                return(rotation);
            }

            return(Quaternion.identity);
        }