private void AddBoneLines(Minotaur.Graphics.Bone bone, List <VertexPositionColor> lineData, Matrix4 parentTransform) { Matrix4 start = parentTransform; Matrix4 end = bone.Transform * parentTransform; if (Vector3.Subtract(GetTranslation(end), GetTranslation(start)).LengthSquared > 0) { if (lineData.Count == 0) { System.Diagnostics.Debug.WriteLine(bone.Name); } if (bone.Name == "weapon" || bone.Parent.Name == "weapon") { lineData.Add(new VertexPositionColor(GetTranslation(start), new Vector4(1f, 0, 0, 1f))); lineData.Add(new VertexPositionColor(GetTranslation(end), new Vector4(1f, 0, 0, 1f))); } else { lineData.Add(new VertexPositionColor(GetTranslation(start), Vector4.One)); lineData.Add(new VertexPositionColor(GetTranslation(end), Vector4.One)); } } foreach (Minotaur.Graphics.Bone child in bone.Children) { AddBoneLines(child, lineData, end); } }
private Minotaur.Graphics.Bone CreateSkeleton(List <Minotaur.Graphics.Bone> bones, Node node, Minotaur.Graphics.Bone parent, ref int index) { Minotaur.Graphics.Bone bone = new Minotaur.Graphics.Bone(index++, node.Name, ToMatrix4(node.Transform)); bones.Add(bone); if (node.HasChildren) { Minotaur.Graphics.Bone[] children = new Minotaur.Graphics.Bone[node.ChildCount]; for (int i = 0; i < node.ChildCount; i++) { children[i] = CreateSkeleton(bones, node.Children[i], bone, ref index); } bone.SetParentAndChildren(parent, children); } else if (parent != null) { bone.Parent = parent; } return(bone); }