IEnumerator AssembleHTBlock() { if (working && currentLoadingHTerrainBlock.Count > 0) { Area.AreaDataType areaData = AreaData.areas.Dequeue(); QueueItem HTGroupItem = currentLoadingHTerrainBlock.Dequeue(); if (HTGroupItem.Block != null) { HTGroupItem.Block.SetActive(false); loadedTerrainLoD1Materials.Add(new Material(terrainDefault)); int frameSpread = 8; // spreading terrain chunks creation over multiple frames for (int i = 1; i <= frameSpread; i++) { GenerateQuarterAreaTerrain(frameSpread, i, areaData, HTGroupItem.Block, HTGroupItem.mapName, HTGroupItem.x, HTGroupItem.y); yield return(null); } HTGroupItem.Block.transform.SetParent(transform); HTGroupItem.Block.transform.localScale = new Vector3(-1, 1, -1); HTGroupItem.Block.SetActive(true); // LoD Material // TexFile texFile = new TexFile(); string mapName = HTGroupItem.mapName; int x = HTGroupItem.x; int y = HTGroupItem.y; string texPath = @"AIDX\Map\" + mapName + @"\" + mapName + "." + x.ToString("X").ToLower() + y.ToString("X").ToLower() + ".tex"; Texture2D LoDTexture = texFile.ReadToTexture2D(texPath); if (LoDTexture != null) { loadedTerrainLoD1Materials[loadedTerrainLoD1Materials.Count - 1].mainTexture = LoDTexture; } } } frameBusy = false; }
public static ImageSource ToImageSource(this TexFile self) { if (self == null) { throw new NullReferenceException(); } BitmapSource bmp = BitmapSource.Create(self.Header.Width, self.Header.Height, 96, 96, PixelFormats.Bgra32, null, self.ImageData, self.Header.Width * 4); bmp.Freeze(); return(bmp); }
public static ImageSource?GetImage(this TexFile self) { if (self == null) { return(null); } BitmapSource bmp = BitmapSource.Create(self.Header.Width, self.Header.Height, 96, 96, PixelFormats.Bgra32, null, self.ImageData, self.Header.Width * 4); bmp.Freeze(); return(bmp); }
/// <summary> /// Returns the image data formatted for <see cref="RawDX11Scene.LoadImageRaw"/>. /// </summary> /// <param name="texFile">The TexFile to format.</param> /// <returns>The formatted image data.</returns> public static byte[] GetRgbaImageData(this TexFile texFile) { var imageData = texFile.ImageData; var dst = new byte[imageData.Length]; for (var i = 0; i < dst.Length; i += 4) { dst[i] = imageData[i + 2]; dst[i + 1] = imageData[i + 1]; dst[i + 2] = imageData[i]; dst[i + 3] = imageData[i + 3]; } return(dst); }
private void DisposeTexFile() { if (_currentTexFile != null) { _currentTexFile.Dispose(); _currentTexFile = null; CurrentImgFile = null; } _imgList.Items.Clear(); _imgList.SelectedIndex = -1; _imageInfoBox.Enabled = false; //this.RebuildBtn.Enabled = false; _imagePreviewBox.Image = null; }
private static unsafe Image GetImage(TexFile tex) { // this is terrible please find something better or get rid of .net imaging altogether Image image; fixed(byte *p = tex.ImageData) { var ptr = (IntPtr)p; using var tempImage = new Bitmap(tex.Header.Width, tex.Header.Height, tex.Header.Width * 4, PixelFormat.Format32bppArgb, ptr); image = new Bitmap(tempImage); } return(image); }
private void method_2() { if (this._texFile != null) { this._texFile.Dispose(); this._texFile = null; } this.ImgList.Items.Clear(); this.ImgList.SelectedIndex = -1; Control arg_49_0 = this.RebuildBtn; this.ImageInfoBox.Enabled = false; arg_49_0.Enabled = false; this.ImagePreviewBox.Image = null; }
/// <summary> /// Retrieve the TexFile referenced by this Texture, and store it /// in this Texture for future use. /// </summary> /// <param name="data">A reference to game data access.</param> /// <returns>The TexFile referenced by this Texture if found, null otherwise.</returns> public TexFile GetTexture(GameData data) { if (_isLoaded) { return(_tex); } if (data == null) { return(null); } _tex = data.GetFile <TexFile>(TexturePath); _isLoaded = true; return(_tex); }
// Request a minimap image from the parser // private static void RequestBlock(MinimapRequest minimapRequest) { string mapName = minimapRequest.mapName; int x = (int)minimapRequest.coords.x; int y = (int)minimapRequest.coords.y; string fileName = mapName + "." + x.ToString("X").ToLower() + y.ToString("X").ToLower() + ".tex"; string path = @"AIDX\Map\" + mapName + @"\" + fileName; if (DataManager.fileList.ContainsKey(path)) { TexFile texFile = new TexFile(); byte[] data = texFile.Read(path); MinimapBlockData blockData = new MinimapBlockData(); blockData.mapName = mapName; blockData.coords = minimapRequest.coords; blockData.textureInfo = texFile.header2; blockData.minimapByteData = data; MinimapDataQueue.Enqueue(blockData); } }
private void DataFolder_TreeView_DoubleClick(object sender, EventArgs e) { if (_dataFolderTreeView.SelectedNode != null) { if (_dataFolderTreeView.SelectedNode.Tag is int && _dataFolderTreeView.SelectedNode.ToolTipText != "") { DisposeTexFile(); var toolTipText = _dataFolderTreeView.SelectedNode.ToolTipText; ZzPakNode2 pakNode; if (File.Exists(toolTipText.Replace(".pak.xen", ".pab.xen"))) { pakNode = new ZzPabNode(toolTipText, toolTipText.Replace(".pak.xen", ".pab.xen"), false); } else { pakNode = new ZzPakNode2(toolTipText, false); } _currentTexFile = new TexFile(pakNode.method_13((int)_dataFolderTreeView.SelectedNode.Tag)); for (var i = 1; i <= _currentTexFile.TextureCount(); i++) { _imgList.Items.Add("Image " + i); } pakNode.Dispose(); return; } if (_dataFolderTreeView.SelectedNode.ToolTipText != "") { DisposeTexFile(); _currentTexFile = new TexFile(_dataFolderTreeView.SelectedNode.ToolTipText); for (var j = 1; j <= _currentTexFile.TextureCount(); j++) { _imgList.Items.Add("Image " + j); } } } }
private void DataFolder_TreeView_DoubleClick(object sender, EventArgs e) { if (this.DataFolder_TreeView.SelectedNode != null) { if (this.DataFolder_TreeView.SelectedNode.Tag is int && this.DataFolder_TreeView.SelectedNode.ToolTipText != "") { this.method_2(); string toolTipText = this.DataFolder_TreeView.SelectedNode.ToolTipText; zzPakNode2 @class; if (File.Exists(toolTipText.Replace(".pak.xen", ".pab.xen"))) { @class = new zzPabNode(toolTipText, toolTipText.Replace(".pak.xen", ".pab.xen"), false); } else { @class = new zzPakNode2(toolTipText, false); } this._texFile = new TexFile(@class.method_13((int)this.DataFolder_TreeView.SelectedNode.Tag)); for (int i = 1; i <= this._texFile.TextureCount(); i++) { this.ImgList.Items.Add("Image " + i); } @class.Dispose(); return; } if (this.DataFolder_TreeView.SelectedNode.ToolTipText != "") { this.method_2(); this._texFile = new TexFile(this.DataFolder_TreeView.SelectedNode.ToolTipText); for (int j = 1; j <= this._texFile.TextureCount(); j++) { this.ImgList.Items.Add("Image " + j); } } } }
public static ImageSource?GetImage(this LuminaData self, int imageId) { TexFile tex = self.GetIcon(imageId); return(tex.GetImage()); }
private void Update() { if (interacted) { interacted = false; // clicked folder // if (currentPath != previousPath) { previousPath = currentPath; BreadCrumb.GetComponent <UnityEngine.UI.Text>().text = currentPath; OpenFolder(); } // clicked file // if (currentSelected != previousSelected) { previousSelected = currentSelected; if (previousSelectedFileIcon != null) { previousSelectedFileIcon.GetComponent <UnityEngine.UI.Image>().color = Color.white; } currentSelectedFileIcon.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 1, .2f); string infoText = ""; infoText += currentPath + "\\" + currentSelected + "\n"; //infoText += "Name Offset: " + fileList[currentSelected].nameOffset + "\n"; string compression = "Uncompressed"; if (fileList[currentSelected].flags == 3) { compression = "ZLib"; } else if (fileList[currentSelected].flags == 5) { compression = "LZMA"; } infoText += "Compression: " + fileList[currentSelected].flags + " " + compression + "\n"; DateTime date = new DateTime((long)fileList[currentSelected].writeTime); infoText += "Write Time: " + date.Hour + ":" + date.Minute + " - " + date.Day + "\\" + date.Month + "\\" + date.Year + "\n"; infoText += "Uncompressed Size: " + fileList[currentSelected].uncompressedSize + "\n"; infoText += "Compressed Size: " + fileList[currentSelected].compressedSize + "\n"; infoText += "Hash: " + DataManager.ToHex(fileList[currentSelected].hash, false) + "\n"; infoText += "Unknown: " + fileList[currentSelected].unk2 + "\n"; fileProperties.GetComponent <UnityEngine.UI.Text>().text = infoText; DataManager.ExtractFile(currentPath + "\\" + currentSelected); //DataManager.GetFileBytes(currentPath + "\\" + currentSelected); // Texture File // if (Path.GetExtension(currentSelected).ToLower() == ".tex") { TexFile texFile = new TexFile(); texFile.Read(currentPath + @"\" + currentSelected); Texture2D tex = texFile.ReadToTexture2D(currentPath + @"\" + currentSelected); texturePreview.GetComponent <UnityEngine.UI.RawImage>().texture = tex; string texPropertiesString = ""; texPropertiesString += "Type: " + texFile.header2.version + "\n"; texPropertiesString += "Dimensions: " + texFile.header2.width + "x" + +texFile.header2.height + "\n"; texPropertiesString += "Depth: " + texFile.header2.depth + "\n"; texPropertiesString += "Sides: " + texFile.header2.faces + "\n"; texPropertiesString += "MipmapCount: " + texFile.header2.mipCount + "\n"; string format = texFile.header2.format.ToString(); /* * if (texFile.header2.format == 13) * format = "DXT1"; * else if (texFile.header2.format == 14) * format = "DXT3"; * else if (texFile.header2.format == 15) * format = "DXT5"; */ texPropertiesString += "Format: " + format + "\n"; texPropertiesString += "Sizes: " + texFile.header2.sizes[0] + " " + texFile.header2.sizes[1] + " " + texFile.header2.sizes[2] + " " + texFile.header2.sizes[3] + " " + texFile.header2.sizes[4] + " " + texFile.header2.sizes[5] + " " + texFile.header2.sizes[6] + " " + texFile.header2.sizes[7] + " " + texFile.header2.sizes[8] + " " + texFile.header2.sizes[9] + " " + texFile.header2.sizes[10] + " " + texFile.header2.sizes[11] + " " + texFile.header2.sizes[12] + " " + texFile.header2.sizes[13] + " " + "\n"; texPropertiesString += "unk1: " + texFile.header2.unk1 + "\n"; texPropertiesString += "unk2: " + texFile.header2.unk2[0] + " " + texFile.header2.unk2[1] + " " + texFile.header2.unk2[2] + " " + "\n"; texPropertiesString += "unk3: " + texFile.header2.unk3 + "\n"; specificProperties.GetComponent <UnityEngine.UI.Text>().text = texPropertiesString; } } } }