public static void addbone(XmlNode bone, Bone parent)
{
if (bone.Name != "bone")
return;
Bone b = new Bone();
b.name = bone.Attributes.GetNamedItem("name").Value;
string pos = bone.Attributes.GetNamedItem("pos").Value;
string[] posparts = pos.Split(' ');
b.pos = new Vector3(float.Parse(posparts[0], Utils.EnUsCulture), float.Parse(posparts[1], Utils.EnUsCulture), float.Parse(posparts[2], Utils.EnUsCulture));
b.orig_pos = new Vector3(b.pos);
b.offset_pos = new Vector3(b.pos);
string rot = bone.Attributes.GetNamedItem("rot").Value;
string[] rotparts = rot.Split(' ');
b.rot = Quaternion.CreateFromEulers((float)(float.Parse(rotparts[0], Utils.EnUsCulture) * Math.PI / 180f), (float)(float.Parse(rotparts[1], Utils.EnUsCulture) * Math.PI / 180f), (float)(float.Parse(rotparts[2], Utils.EnUsCulture) * Math.PI / 180f));
b.orig_rot = new Quaternion(b.rot);
string scale = bone.Attributes.GetNamedItem("scale").Value;
string[] scaleparts = scale.Split(' ');
b.scale = new Vector3(float.Parse(scaleparts[0], Utils.EnUsCulture), float.Parse(scaleparts[1], Utils.EnUsCulture), float.Parse(scaleparts[2], Utils.EnUsCulture));
b.orig_scale = new Vector3(b.scale);
float[] deform = Math3D.CreateSRTMatrix(new Vector3(1, 1, 1), b.rot, b.orig_pos);
b.mDeformMatrix = new Matrix4(deform[0], deform[1], deform[2], deform[3], deform[4], deform[5], deform[6], deform[7], deform[8], deform[9], deform[10], deform[11], deform[12], deform[13], deform[14], deform[15]);
//TODO piviot
b.parent = parent;
if (parent != null)
{
b.mParentBone = parent.name;
parent.children.Add(b);
}
lock (Bone.mBones) mBones.Add(b.name, b);
mIndexedBones.Add(boneaddindex++, b);
Logger.Log("Found bone " + b.name, Helpers.LogLevel.Info);
foreach (XmlNode childbone in bone.ChildNodes)
{
addbone(childbone, b);
}
}