LSLib.Granny.Model.ColladaAnimation.ImportSampler C# (CSharp) Метод

ImportSampler() приватный Метод

private ImportSampler ( ) : void
Результат void
        private void ImportSampler()
        {
            sampler sampler = null;
            foreach (var item in Animation.Items)
            {
                if (item is sampler)
                {
                    sampler = item as sampler;
                    break;
                }
            }

            if (sampler == null)
                throw new ParsingException("Animation " + Animation.id + " has no sampler!");

            Source inputSource = null, outputSource = null, interpolationSource = null;
            foreach (var input in sampler.input)
            {
                if (input.source[0] != '#')
                    throw new ParsingException("Only ID references are supported for animation input sources");

                Source source;
                if (!Sources.TryGetValue(input.source.Substring(1), out source))
                    throw new ParsingException("Animation sampler " + input.semantic + " references nonexistent source: " + input.source);

                switch (input.semantic)
                {
                    case "INPUT":
                        inputSource = source;
                        break;

                    case "OUTPUT":
                        outputSource = source;
                        break;

                    case "INTERPOLATION":
                        interpolationSource = source;
                        break;

                    default:
                        break;
                }
            }

            if (inputSource == null || outputSource == null || interpolationSource == null)
                throw new ParsingException("Animation " + Animation.id + " must have an INPUT, OUTPUT and INTERPOLATION sampler input!");

            if (!inputSource.FloatParams.TryGetValue("TIME", out Times))
                Times = inputSource.FloatParams.Values.SingleOrDefault();

            if (Times == null)
                throw new ParsingException("Animation " + Animation.id + " INPUT must have a TIME parameter!");

            if (!outputSource.MatrixParams.TryGetValue("TRANSFORM", out Transforms))
                Transforms = outputSource.MatrixParams.Values.SingleOrDefault();

            if (Transforms == null)
                throw new ParsingException("Animation " + Animation.id + " OUTPUT must have a TRANSFORM parameter!");

            if (Transforms.Count != Times.Count)
                throw new ParsingException("Animation " + Animation.id + " has different time and transform counts!");

            for (var i = 0; i < Transforms.Count; i++ )
            {
                var m = Transforms[i];
                m.Transpose();
                Transforms[i] = m;
            }
        }