Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MorphWeightCollection"/> class for the specified morph
        /// targets.
        /// </summary>
        /// <param name="morphTargetNames">The names of the morph targets.</param>
        /// <exception cref="ArgumentException">
        /// No parameters specified. Or the name of a morph target is null or empty.
        /// </exception>
        public MorphWeightCollection(params string[] morphTargetNames)
        {
            if (morphTargetNames == null || morphTargetNames.Length == 0)
            {
                throw new ArgumentException("The list of morph target names is empty.");
            }

            for (int i = 0; i < morphTargetNames.Length; i++)
            {
                if (string.IsNullOrEmpty(morphTargetNames[i]))
                {
                    throw new ArgumentException("The name of the morph target must not be null or empty.");
                }
            }

            _names = new string[morphTargetNames.Length];
            Array.Copy(morphTargetNames, _names, morphTargetNames.Length);
            Array.Sort(_names, StringComparer.Ordinal);

            _names   = morphTargetNames;
            _weights = new MorphWeight[morphTargetNames.Length];
            for (int i = 0; i < morphTargetNames.Length; i++)
            {
                _weights[i] = new MorphWeight();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a copy of the specified <see cref="MorphWeightCollection"/> instance.
        /// </summary>
        /// <param name="source">The source <see cref="MorphWeightCollection"/>.</param>
        private MorphWeightCollection(MorphWeightCollection source)
        {
            Name   = source.Name;
            _names = source._names;

            var weights = source._weights;

            _weights = new MorphWeight[weights.Length];
            for (int i = 0; i < weights.Length; i++)
            {
                _weights[i] = new MorphWeight {
                    Value = weights[i].Value
                }
            }
            ;
        }