/// <summary> /// generate code for AnimationTree /// </summary> /// <param name="aTree">AnimationTree</param> public void Generate(AnimationTreeData aTree) { AnimationTreeClass atClass = new AnimationTreeClass(aTree); _Document.AddUsingSkillAnimation(); _Document.Add(atClass); HasPartial = true; }
/// <summary> /// Create an instance of AnimationTreeClass /// </summary> /// <param name="tree">AnimationTree model</param> public AnimationTreeClass(AnimationTreeData tree) : base(tree.Name) { this._Tree = tree; this._CreateTreeMethodBody = new StringBuilder(); // look at each AnimNode in tree and create apropriate variables and properties for them ProcessNodes(); AddInherit("Skill.Framework.Animation.AnimationTree"); StringBuilder awakeBody = new StringBuilder(); awakeBody.AppendLine("base.Awake();"); // create profiles in constructor if (tree.Profiles != null && tree.Profiles.Length > 0) { foreach (var profile in tree.Profiles) { awakeBody.AppendLine(string.Format("this.AddProfile(\"{0}\",\"{1}\");", profile.Name, profile.Format)); } awakeBody.AppendLine(string.Format("this.Profile = \"{0}\";", tree.Profiles[0].Name)); } else { awakeBody.AppendLine("this.Profile = string.Empty;"); } if (!string.IsNullOrEmpty(tree.SkinMesh)) { awakeBody.AppendLine("if (base.Animation != null)"); awakeBody.AppendLine(string.Format("{0}.ApplyMixingTransforms(this.Animation);", tree.SkinMesh)); } // create constructor Method awake = new Method("void", "Awake", awakeBody.ToString()) { Modifier = Modifiers.Protected, SubMethod = SubMethod.Override }; Add(awake); // create protected CreateTree method Method createTree = new Method("Skill.Framework.Animation.AnimNode", "CreateTree", this._CreateTreeMethodBody.ToString()); createTree.IsPartial = false; createTree.SubMethod = SubMethod.Override; createTree.Modifier = Modifiers.Protected; Add(createTree); CreateParameters(); }
public ParameterProperty(string type, string name, string value, AnimationTreeData tree) : base(type, name, value, true) { base.Multiline = true; StringBuilder setBuffer = new StringBuilder(_Set); string vatiableName = Variable.GetName(name); foreach (var node in tree) { switch (node.NodeType) { case AnimNodeType.Override: if (((AnimNodeOverrideData)node).Parameter == name) { setBuffer.AppendLine(); setBuffer.AppendFormat("{0}.Value = {1};", Variable.GetName(node.Name), vatiableName); } break; case AnimNodeType.BlendByIndex: if (((AnimNodeBlendByIndexData)node).Parameter == name) { setBuffer.AppendLine(); setBuffer.AppendFormat("{0}.SelectedChildIndex = {1};", Variable.GetName(node.Name), vatiableName); } break; case AnimNodeType.Blend1D: if (((AnimNodeBlend1DData)node).Parameter == name) { setBuffer.AppendLine(); setBuffer.AppendFormat("{0}.Value = {1};", Variable.GetName(node.Name), vatiableName); } break; case AnimNodeType.Blend2D: if (((AnimNodeBlend2DData)node).Parameter1 == name) { setBuffer.AppendLine(); setBuffer.AppendFormat("{0}.ValueX = {1};", Variable.GetName(node.Name), vatiableName); } if (((AnimNodeBlend2DData)node).Parameter2 == name) { setBuffer.AppendLine(); setBuffer.AppendFormat("{0}.ValueY = {1};", Variable.GetName(node.Name), vatiableName); } break; case AnimNodeType.Additive: if (((AnimNodeAdditiveBlendingData)node).Parameter == name) { setBuffer.AppendLine(); setBuffer.AppendFormat("{0}.Value = {1};", Variable.GetName(node.Name), vatiableName); } break; } } _Set = setBuffer.ToString(); }