/// <summary> /// Constructor /// </summary> /// <param name="node">Node Data to load</param> public AnimationSet(AnimationNode node) { int stride = node.Output.Count / node.Input.Count; int count = node.Input.Count; Ticks = new List <float>(node.Input); Output = node.Output.Select(m => new AnimationData(m)).ToList(); Tangent_In = new List <AnimationData>(); Tangent_Out = new List <AnimationData>(); if (node.In_Tangent != null && node.In_Tangent.Count > 0) { Tangent_In = node.In_Tangent.Select(m => new AnimationData(m)).ToList(); } if (node.Out_Tangent != null && node.Out_Tangent.Count > 0) { Tangent_Out = node.Out_Tangent.Select(m => new AnimationData(m)).ToList(); } InterpolationMode = (InterpolationType)node.Interpolation; Target = node.Target; }
private static AnimationNode CreateAnimationTrack(XElement animationData) { AnimationNode track = new AnimationNode(); //Get source, every source contain input and ouput data (input is time, output is matrix) var channel = animationData.GetChild("channel"); //cerca eventuali sotto animazioni foreach (XElement elem in animationData.GetChildren("animation")) { track.Children.Add(CreateAnimationTrack(elem)); } //search for valid channel if (channel == null) return track; //get all source XElement source = channel.GetSource(); var input = source.GetChildren("input").Where(i => i.GetAttribute("semantic") == "INPUT").FirstOrDefault(); var output = source.GetChildren("input").Where(i => i.GetAttribute("semantic") == "OUTPUT").FirstOrDefault(); var in_tangent = source.GetChildren("input").Where(i => i.GetAttribute("semantic") == "IN_TANGENT").FirstOrDefault(); var out_tangent = source.GetChildren("input").Where(i => i.GetAttribute("semantic") == "OUT_TANGENT").FirstOrDefault(); var interpolation = source.GetChildren("input").Where(i => i.GetAttribute("semantic") == "INTERPOLATION").FirstOrDefault(); //tangenti in_out if (in_tangent != null) in_tangent = in_tangent.GetSource(); if (out_tangent != null) out_tangent = out_tangent.GetSource(); //get target of animation string target = channel.GetAttribute("target"); //get parameter of animations (example, name/transform) string[] targetParts = channel.GetAttribute("target").Split(new char[] { '/' }); track.Target = targetParts[0]; string animationType = targetParts[1].ToLower(); animationType = animationType.Replace("(", " ").Replace(")", " ").Replace(".", " "); string[] parts = animationType.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); //keyframes track.Output = GetKeyFrames(animationType, output); track.In_Tangent = GetKeyFrames(animationType, in_tangent); track.Out_Tangent = GetKeyFrames(animationType, out_tangent); //input key frame input = input.GetSource(); interpolation = interpolation.GetSource(); //get interpolation time string interpolationType = interpolation.Value.Replace('\n', ' ').Split(' ').Where(s => !string.IsNullOrEmpty(s)).FirstOrDefault(); if (interpolationType == "LINEAR") track.Interpolation = Interpolation.Linear; else if (interpolationType == "BEZIER") track.Interpolation = Interpolation.Bezier; else track.Interpolation = Interpolation.Undefined; //get key frame track.Input = GetFloatList(input.GetChild("float_array").Value); return track; }
/// <summary> /// Constructor /// </summary> /// <param name="node">Node Data to load</param> public AnimationSet(AnimationNode node) { int stride = node.Output.Count / node.Input.Count; int count = node.Input.Count; Ticks = new List<float>(node.Input); Output = node.Output.Select(m => new AnimationData(m)).ToList(); Tangent_In = new List<AnimationData>(); Tangent_Out = new List<AnimationData>(); if (node.In_Tangent != null && node.In_Tangent.Count > 0) Tangent_In = node.In_Tangent.Select(m => new AnimationData(m)).ToList(); if (node.Out_Tangent != null && node.Out_Tangent.Count > 0) Tangent_Out = node.Out_Tangent.Select(m => new AnimationData(m)).ToList(); InterpolationMode = (InterpolationType)node.Interpolation; Target = node.Target; }