Exemplo n.º 1
0
 /// <summary>
 /// Returns a random rotation vector within the specified rotation range.
 /// </summary>
 /// <param name="range">A rotation range value defining the minimum and maximum values.</param>
 /// <returns>A random rotation vector within the specified rotation range.</returns>
 static public Vector3 NextRotation(RotationRange range)
 {
     return new Vector3
     {
         X = RandomUtil.NextSingle(range.Pitch),
         Y = RandomUtil.NextSingle(range.Yaw),
         Z = RandomUtil.NextSingle(range.Roll)
     };
 }
Exemplo n.º 2
0
        /// <summary>
        /// Converts the given object to the type of this converter, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"/> to use as the current culture.</param>
        /// <param name="value">The <see cref="T:System.Object"/> to convert.</param>
        /// <returns>
        /// An <see cref="T:System.Object"/> that represents the converted value.
        /// </returns>
        /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
        public override Object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
        {
            culture = culture ?? CultureInfo.CurrentCulture;

            if (value is String)
            {
                return(RotationRange.Parse(value as String, culture));
            }

            return(base.ConvertFrom(context, culture, value));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts the given value object to the specified type, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="culture">A <see cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current culture is assumed.</param>
        /// <param name="value">The <see cref="T:System.Object"/> to convert.</param>
        /// <param name="destinationType">The <see cref="T:System.Type"/> to convert the <paramref name="value"/> parameter to.</param>
        /// <returns>
        /// An <see cref="T:System.Object"/> that represents the converted value.
        /// </returns>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="destinationType"/> parameter is null. </exception>
        /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
        public override Object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType)
        {
            culture = culture ?? CultureInfo.CurrentCulture;

            if (destinationType == typeof(String))
            {
                if (value is RotationRange)
                {
                    RotationRange range = (RotationRange)value;

                    return(range.ToString(culture));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }