Ejemplo n.º 1
0
        internal AnimationTemplate(AnimationTemplateJsonRepresentation <TKeyframeParameters, TBoneAttributes> json)
        {
            this.name     = json.Name;
            this.skeleton = new SkeletonTemplate <TBoneAttributes>(json.Skeleton);

            this.keyframes = json.Keyframes == null ? new List <Keyframe <TBoneParameters, TKeyframeParameters, TBoneAttributes> >().AsReadOnly()
                : json.Keyframes.Select(f => new Keyframe <TBoneParameters, TKeyframeParameters, TBoneAttributes>(f, this.skeleton)).ToList().AsReadOnly();

            this.keyframeDictionary = this.keyframes.ToDictionary(f => f.Name);

            this.sequences = json.Sequences == null
                ? new List <AnimationSequenceTemplate <TBoneParameters, TKeyframeParameters, TBoneAttributes> >().AsReadOnly()
                : json.Sequences.Select(
                s => new AnimationSequenceTemplate <TBoneParameters, TKeyframeParameters, TBoneAttributes>(s, this.keyframeDictionary))
                             .ToList().AsReadOnly();

            this.sequenceDictionary = this.sequences.ToDictionary(s => s.Name);
        }
Ejemplo n.º 2
0
        internal Keyframe(KeyframeJsonRepresentation <TKeyframeParameters> frame, SkeletonTemplate <TBoneAttributes> skeleton)
        {
            if (string.IsNullOrEmpty(frame.Name))
            {
                throw new InvalidDataException("Keyframe must have name.");
            }
            this.name = frame.Name;

            if (frame.Data == null)
            {
                this.data = new List <KeyframeData <TKeyframeParameters, TBoneAttributes> >().AsReadOnly();
                return;
            }

            this.data = frame.Data.Select(
                d => new KeyframeData <TKeyframeParameters, TBoneAttributes>(d, skeleton))
                        .ToList().AsReadOnly();
        }
Ejemplo n.º 3
0
        internal KeyframeData(KeyframeDataJsonRepresentation <TKeyframeParameters> data, SkeletonTemplate <TBoneAttributes> skeleton)
        {
            this.bone = skeleton[data.Bone];

            this.parameters = data.Parameters;

            if (this.bone == null)
            {
                throw new InvalidDataException("Keyframe data must specify valid bone.");
            }
        }