public static AvatarSkeletonInfo ParseXml(XmlNode root) { if (root.NodeType != XmlNodeType.Element) { throw new Exception("Invalid root node."); } XmlElement rootElement = (XmlElement)root; AvatarSkeletonInfo avatarSkeletonInfo = new AvatarSkeletonInfo(); avatarSkeletonInfo.NumBones = ParseInt(rootElement.GetAttribute("num_bones"), "Couldn't find number of bones.", "Couldn't parse number of bones"); int.TryParse(rootElement.GetAttribute("num_collision_volumes"), out var i); avatarSkeletonInfo.NumCollisionVolumes = i; foreach (XmlNode childNode in rootElement.ChildNodes) { if (childNode.NodeType != XmlNodeType.Element) { continue; } AvatarBoneInfo boneInfo = AvatarBoneInfo.ParseXml(childNode); avatarSkeletonInfo.BoneInfoList.Add(boneInfo); } return(avatarSkeletonInfo); }
public static void InitClass(string avatarFilename, string skeletonFilename) { if (string.IsNullOrEmpty(avatarFilename)) { avatarFilename = $"{AVATAR_DEFAULT_CHAR}_lad.xml"; } avatarFilename = System.IO.Path.Combine(Application.streamingAssetsPath, "Character", avatarFilename); AvatarConfigurationXmlTree = OpenAvatarXmlFile(avatarFilename, "linden_avatar", new[] { "1.0", "2.0" }); // TODO: Extract the "wearable_definition_version" attribute of the root node and set it in the Wearable class if (string.IsNullOrEmpty(skeletonFilename)) { skeletonFilename = "avatar_skeleton.xml"; } skeletonFilename = System.IO.Path.Combine(Application.streamingAssetsPath, "Character", skeletonFilename); SkeletonXmlTree = OpenAvatarXmlFile(skeletonFilename, "linden_skeleton", new[] { "1.0", "2.0" }); try { AvatarSkeletonInfo = null; AvatarSkeletonInfo = AvatarSkeletonInfo.ParseXml(SkeletonXmlTree.GetFirstChild()); } catch (Exception e) { Logger.LogError("AvatarAppearance.InitClass", $"Error parsing skeleton file: {skeletonFilename} ({e})"); } try { AvatarXmlInfo = null; AvatarXmlInfo = AvatarXmlInfo.ParseXml(AvatarConfigurationXmlTree.GetFirstChild()); } catch (Exception e) { Logger.LogError("AvatarAppearance.InitClass", $"Error parsing avatar file: {avatarFilename} ({e})"); } }