public WorldModelGroup(string path, int groupIndex) { uint fileId; uint.TryParse(path, out fileId); if (fileId <= 0) { Data = new ChunkedData(path); } else { Data = new ChunkedData(fileId); } GroupIndex = groupIndex; var mainChunk = Data.GetChunkByName("MOGP"); var firstSub = mainChunk.FindSubChunkOffset("MOPY"); if (firstSub == -1) { return; } var stream = mainChunk.GetStream(); stream.Seek(firstSub, SeekOrigin.Begin); SubData = new ChunkedData(stream, (int)(mainChunk.Length - firstSub)); ReadBoundingBox(); ReadMaterials(); ReadTriangles(); ReadVertices(); ReadNormals(); ReadLiquid(); }
public void ProcessMapChunk(MapChunk chunk) { if (!Source.HasObjectData) { return; } // f**k it blizzard, why is this crap necessary? var firstIndex = Source.ObjectData.GetFirstIndex("MCNK"); if (firstIndex == -1) { return; } if (firstIndex + chunk.Index > Source.ObjectData.Chunks.Count) { return; } var ourChunk = Source.ObjectData.Chunks[firstIndex + chunk.Index]; if (ourChunk.Length == 0) { return; } var subChunks = new ChunkedData(ourChunk.GetStream(), (int)ourChunk.Length, 2); ProcessInternal(subChunks); }
protected override void ProcessInternal(ChunkedData subChunks) { if (!IsSane) { return; } var wmoReferencesChunk = subChunks.GetChunkByName("MCRW"); if (wmoReferencesChunk == null) { return; } var stream = wmoReferencesChunk.GetStream(); var reader = new BinaryReader(stream); var refCount = (int)(wmoReferencesChunk.Length / 4); for (int i = 0; i < refCount; i++) { int index = reader.ReadInt32(); if (index < 0 || index >= _definitions.Count) { continue; } var wmo = _definitions[index]; if (_drawn.Contains(wmo.UniqueId)) { continue; } _drawn.Add(wmo.UniqueId); if (wmo.MwidIndex >= _paths.Count) { continue; } var path = _paths[(int)wmo.MwidIndex]; var model = Cache.WorldModel.Get(path); if (model == null) { model = new WorldModelRoot(path); Cache.WorldModel.Insert(path, model); } if (Vertices == null) { Vertices = new List <Vector3>(1000); } if (Triangles == null) { Triangles = new List <Triangle <uint> >(1000); } InsertModelGeometry(Vertices, Triangles, wmo, model); } }
public WorldModelRoot(string path) { Data = new ChunkedData(path); Path = path; ReadHeader(); ReadGroups(); ReadDoodadInstances(); ReadDoodadSets(); }
private async Task SendToClient(string tempFolderPath, PluginsPlugin plug, int itemCount) { try { if (plug != null) { if (plug.IsSync) { Utils ut = new Utils(); ut.FileName = plug.Path; ut.TempFolder = tempFolderPath; if (!Directory.Exists(ut.TempFolder)) { Directory.CreateDirectory(ut.TempFolder); } ut.MaxFileSizeKB = MaxFileSizeKB; await ut.SplitFile(); ConfigModel sendModel = new ConfigModel { PluginName = plug.name, JsonConfigFile = await Helper.GetBytesFromChunkedFileAsync(plug.ConfigPath) }; foreach (string file in ut.FileParts) // improvement - this is sequential, make threaded { var chN = file.Split("\\"); if (_connection.State == HubConnectionState.Disconnected) { _connection.StartAsync().GetAwaiter().GetResult(); } ChunkedData sendData = new ChunkedData { Version = plug.version, PluginName = plug.name, Extension = plug.Extension, FilePathName = file, ChunkName = chN[chN.Length - 1], Bytes = await Helper.GetBytesFromChunkedFileAsync(file) }; await _connection.InvokeAsync <ChunkedData>("SendChunkedFile", sendData, plug.name, ut.FileParts.Count, itemCount, sendModel); } Directory.Delete(tempFolderPath, true); } } } catch { throw; } }
public ADT(string file) { try { Data = new ChunkedData(file); ObjectData = new ChunkedData(file.Replace(".adt", "_obj0.adt")); HasObjectData = true; } catch (FileNotFoundException) { ObjectData = null; HasObjectData = false; } }
public ADT(string file) { Data = new ChunkedData(file); try { ObjectData = new ChunkedData(file.Replace(".adt", "_obj0.adt")); HasObjectData = true; } catch (FileNotFoundException) { ObjectData = null; HasObjectData = false; } }
protected override void ProcessInternal(ChunkedData subChunks) { if (!IsSane) return; var doodadReferencesChunk = subChunks.GetChunkByName("MCRD"); if (doodadReferencesChunk == null) return; var stream = doodadReferencesChunk.GetStream(); var reader = new BinaryReader(stream); var refCount = (int)(doodadReferencesChunk.Length/4); for (int i = 0; i < refCount; i++) { int index = reader.ReadInt32(); if (index < 0 || index >= _definitions.Count) continue; var doodad = _definitions[index]; if (_drawn.Contains(doodad.UniqueId)) continue; _drawn.Add(doodad.UniqueId); if (doodad.MmidIndex >= _paths.Count) continue; var path = _paths[(int) doodad.MmidIndex]; var model = Cache.Model.Get(path); if (model == null) { model = new Model(path); Cache.Model.Insert(path, model); } if (!model.IsCollidable) continue; // some weak heuristic to save memory allocation time if (Vertices == null) Vertices = new List<Vector3>((int)(refCount * model.Vertices.Length * 0.2)); if (Triangles == null) Triangles = new List<Triangle<uint>>((int)(refCount * model.Triangles.Length * 0.2)); InsertModelGeometry(doodad, model); } }
public void ProcessMapChunk(MapChunk chunk) { if (!Source.HasObjectData) return; // f**k it blizzard, why is this crap necessary? var firstIndex = Source.ObjectData.GetFirstIndex("MCNK"); if (firstIndex == -1) return; if (firstIndex + chunk.Index > Source.ObjectData.Chunks.Count) return; var ourChunk = Source.ObjectData.Chunks[firstIndex + chunk.Index]; if (ourChunk.Length == 0) return; var subChunks = new ChunkedData(ourChunk.GetStream(), (int)ourChunk.Length, 2); ProcessInternal(subChunks); }
protected override void ProcessInternal(ChunkedData subChunks) { if (!IsSane) return; var wmoReferencesChunk = subChunks.GetChunkByName("MCRW"); if (wmoReferencesChunk == null) return; var stream = wmoReferencesChunk.GetStream(); var reader = new BinaryReader(stream); var refCount = (int)(wmoReferencesChunk.Length / 4); for (int i = 0; i < refCount; i++) { int index = reader.ReadInt32(); if (index < 0 || index >= _definitions.Count) continue; var wmo = _definitions[index]; if (_drawn.Contains(wmo.UniqueId)) continue; _drawn.Add(wmo.UniqueId); if (wmo.MwidIndex >= _paths.Count) continue; var path = _paths[(int) wmo.MwidIndex]; var model = Cache.WorldModel.Get(path); if (model == null) { model = new WorldModelRoot(path); Cache.WorldModel.Insert(path, model); } if (Vertices == null) Vertices = new List<Vector3>(1000); if (Triangles == null) Triangles = new List<Triangle<uint>>(1000); InsertModelGeometry(Vertices, Triangles, wmo, model); } }
public WorldModelGroup(string path, int groupIndex) { Data = new ChunkedData(path); GroupIndex = groupIndex; var mainChunk = Data.GetChunkByName("MOGP"); var firstSub = mainChunk.FindSubChunkOffset("MOPY"); if (firstSub == -1) return; var stream = mainChunk.GetStream(); stream.Seek(firstSub, SeekOrigin.Begin); SubData = new ChunkedData(stream, (int)(mainChunk.Length - firstSub)); ReadBoundingBox(); ReadMaterials(); ReadTriangles(); ReadVertices(); ReadNormals(); ReadLiquid(); }
protected abstract void ProcessInternal(ChunkedData subChunks);
protected override void ProcessInternal(ChunkedData subChunks) { if (!IsSane) { return; } var doodadReferencesChunk = subChunks.GetChunkByName("MCRD"); if (doodadReferencesChunk == null) { return; } var stream = doodadReferencesChunk.GetStream(); var reader = new BinaryReader(stream); var refCount = (int)(doodadReferencesChunk.Length / 4); for (int i = 0; i < refCount; i++) { int index = reader.ReadInt32(); if (index < 0 || index >= _definitions.Count) { continue; } var doodad = _definitions[index]; if (_drawn.Contains(doodad.UniqueId)) { continue; } _drawn.Add(doodad.UniqueId); if (doodad.MmidIndex >= _paths.Count) { continue; } var path = _paths[(int)doodad.MmidIndex]; var model = Cache.Model.Get(path); if (model == null) { model = new Model(path); Cache.Model.Insert(path, model); } if (!model.IsCollidable) { continue; } // some weak heuristic to save memory allocation time if (Vertices == null) { Vertices = new List <Vector3>((int)(refCount * model.Vertices.Length * 0.2)); } if (Triangles == null) { Triangles = new List <Triangle <uint> >((int)(refCount * model.Triangles.Length * 0.2)); } InsertModelGeometry(doodad, model); } }
public async Task SendChunkedFile(ChunkedData fileChunk, string pluginName, int count, int itemsCount, ConfigModel model) { await Clients.All.SendAsync("ReceiveChunks", fileChunk, pluginName, count, itemsCount, model); }