Пример #1
0
    //解析XML文件中
    private static void ParseMeshElement(XmlTextReader meshElement, TreeModel treeModel)
    {
        string name = meshElement.GetAttribute("MName");

        if (name == null || name.Length == 0)
        {
            throw new ArgumentNullException("No MName Attribute in Mesh Element.");
        }

        string MeshPath = meshElement.GetAttribute("MPath");

        if (MeshPath == null || MeshPath.Length == 0)
        {
            throw new ArgumentNullException("No MPath Attribute in Mesh Element.");
        }

        string TexturePath = meshElement.GetAttribute("MTexPath");

        if (TexturePath == null || TexturePath.Length == 0)
        {
            throw new ArgumentNullException("No MTexPath Attribute in Mesh Element.");
        }

        string MaxSize = meshElement.GetAttribute("MMaxSize");

        if (MaxSize == null || MaxSize.Length == 0)
        {
            throw new ArgumentNullException("No MMaxSize Attribute in Mesh Element.");
        }

        string size = meshElement.GetAttribute("MSize");

        if (size == null || size.Length == 0)
        {
            throw new ArgumentNullException("No MSize Attribute in Mesh Element.");
        }

        string type = meshElement.GetAttribute("MType");

        if (type == null || type.Length == 0)
        {
            throw new ArgumentNullException("No MType Attribute in Mesh Element.");
        }

        treeModel.AddMesh(name, MeshPath, TexturePath, Convert.ToSingle(size), Convert.ToSingle(MaxSize), (OrganType)Enum.Parse(typeof(OrganType), type));
    }