示例#1
0
        public override bool Load(string fileName)
        {
            Groups = new List <Models.WmoGroup>();

            mFileName = fileName;

            using (var file = FileManager.Instance.Provider.OpenFile(fileName))
            {
                if (file == null)
                {
                    throw new ArgumentException("WMO not found: " + fileName);
                }

                var reader = new BinaryReader(file);

                try
                {
                    var hasHeader    = false;
                    var hasTextures  = false;
                    var hasMaterials = false;
                    while (hasHeader == false || hasTextures == false || hasMaterials == false)
                    {
                        var signature = reader.ReadUInt32();
                        var size      = reader.ReadInt32();
                        var curPos    = file.Position;
                        switch (signature)
                        {
                        case 0x4D4F4844:
                            mHeader   = reader.Read <Mohd>();
                            hasHeader = true;
                            break;

                        case 0x4D4F5458:
                            ReadTextures(reader, size);
                            hasTextures = true;
                            break;

                        case 0x4D4F4D54:
                            LoadMaterials(reader, size);
                            hasMaterials = true;
                            break;
                        }

                        file.Position = curPos + size;
                    }
                }
                catch (EndOfStreamException)
                {
                }
                catch (Exception e)
                {
                    Log.Error("Unable to load WMO: " + e);
                    return(false);
                }

                return(LoadGroups());
            }
        }
示例#2
0
        public override bool Load(string fileName)
        {
            Groups = new List<Models.WmoGroup>();

            mFileName = fileName;

            using (var file = FileManager.Instance.Provider.OpenFile(fileName))
            {
                if (file == null)
                    throw new ArgumentException("WMO not found: " + fileName);

                var reader = new BinaryReader(file);

                try
                {
                    var hasHeader = false;
                    var hasTextures = false;
                    var hasMaterials = false;
                    while (hasHeader == false || hasTextures == false || hasMaterials == false)
                    {
                        var signature = reader.ReadUInt32();
                        var size = reader.ReadInt32();
                        var curPos = file.Position;
                        switch (signature)
                        {
                            case 0x4D4F4844:
                                mHeader = reader.Read<Mohd>();
                                hasHeader = true;
                                break;

                            case 0x4D4F5458:
                                ReadTextures(reader, size);
                                hasTextures = true;
                                break;

                            case 0x4D4F4D54:
                                LoadMaterials(reader, size);
                                hasMaterials = true;
                                break;
                        }

                        file.Position = curPos + size;
                    }
                }
                catch (EndOfStreamException)
                {

                }
                catch(Exception e)
                {
                    Log.Error("Unable to load WMO: " + e);
                    return false;
                }

                return LoadGroups();
            }
        }