public void LoadDDS(string FileName, byte[] FileData = null) { TexName = STGenericTexture.SetNameFromPath(FileName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; var surfaces = DDS.GetArrayFaces(dds, dds.ArrayCount); RedComp = dds.RedChannel; GreenComp = dds.GreenChannel; BlueComp = dds.BlueChannel; AlphaComp = dds.AlphaChannel; foreach (var surface in surfaces) { DataBlockOutput.Add(Utils.CombineByteArray(surface.mipmaps.ToArray())); } Format = dds.Format; }
public void LoadDDS(string FileName, BntxFile bntxFile, byte[] FileData = null, TextureData tree = null) { TexName = Path.GetFileNameWithoutExtension(FileName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; DataBlockOutput = dds.bdata; Format = LoadDDSFormat(dds.header.ddspf.fourCC, dds, IsSRGB); Texture tex = FromBitMap(DataBlockOutput, this); if (tree != null) { tree.LoadTexture(tex, 1); } else { textureData = new TextureData(tex, bntxFile); } }
public void LoadDDS(string FileName, byte[] FileData = null) { TexName = Path.GetFileNameWithoutExtension(FileName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; arrayLength = 1; if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES) { arrayLength = 6; } DataBlockOutput.Add(dds.bdata); Format = LoadDDSFormat(dds.header.ddspf.fourCC, dds, IsSRGB); }
public void LoadDDS(string FileName, byte[] FileData = null) { TexName = STGenericTexture.SetNameFromPath(FileName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; arrayLength = 1; if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES) { arrayLength = 6; } DataBlockOutput.Add(dds.bdata); Format = (CTR_3DS.PICASurfaceFormat)CTR_3DS.ConvertToPICAFormat(dds.Format); }
public void LoadDDS(string FileName, byte[] FileData = null) { TexName = STGenericTexture.SetNameFromPath(FileName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; arrayLength = 1; if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES) { arrayLength = 6; } DataBlockOutput.Add(dds.bdata); RedComp = dds.RedChannel; GreenComp = dds.GreenChannel; BlueComp = dds.BlueChannel; AlphaComp = dds.AlphaChannel; Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(dds.Format);; }
public void LoadDDS(string FileName, byte[] FileData = null, TextureData tree = null) { TexName = Path.GetFileNameWithoutExtension(FileName); Console.WriteLine(TexName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; arrayLength = 1; if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES) { arrayLength = 6; } foreach (var array in DDS.GetArrayFacesBytes(dds, (int)arrayLength)) { DataBlockOutput.Add(array); } Format = LoadDDSFormat(dds.header.ddspf.fourCC, dds, IsSRGB); }
public override Asset Import(string path) { Texture texture = new Texture { FileName = path }; texture.CreateFromBitmap(DDS.Load(path).Decompress(), Path.GetFileNameWithoutExtension(path)); return(texture); }
public void LoadDDS(string FileName, BntxFile bntxFile, byte[] FileData = null, TextureData tree = null) { TexName = Path.GetFileNameWithoutExtension(FileName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; arrayLength = 1; if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES) { arrayLength = 6; } DataBlockOutput.Add(dds.bdata); var formats = dds.GetFormat(); Format = formats.Item1; FormatType = formats.Item2; Texture tex = FromBitMap(DataBlockOutput[0], this); if (tree != null) { tree.LoadTexture(tex, 1); } else { textureData = new TextureData(tex, bntxFile); } }
// Methods public static void LoadDefaults() { // Load default model var watch = System.Diagnostics.Stopwatch.StartNew(); string cubePth = Path.Combine(Program.StartupPath, Program.ResourcesPath, $"DefaultCube{Model.MDLExtension}"); var mdl = new Model(); mdl.Load(cubePth); // Load default texture string defaultTexPath = Path.Combine(Program.StartupPath, Program.ResourcesPath, $"DefaultTexture{DDS.Extension}"); Texture defaultTex; if (File.Exists(defaultTexPath)) { defaultTex = new DDS(); defaultTex.Load(defaultTexPath); } else { defaultTex = new Texture() { Width = 1, Height = 1, PixelFormat = Texture.PixelFormats.RGB, MipmapCount = 1, ColorData = new byte[][] { new byte[] { 255, 255, 255 } } }; } // Setup default texture/material/model DefaultTexture = GenTexture(defaultTex); DefaultMaterial = new GensMaterial(); DefaultCube = new VPModel(mdl, true); watch.Stop(); Console.WriteLine("Default assets init time: {0}", watch.ElapsedMilliseconds); }
public Bitmap LoadNearTileTexture(string tileName) { Bitmap toReturn; var tileFullPath = Path.Combine(_terrainDB.CurrentTheaterTextureBaseFolderPath, tileName); var tileInfo = new FileInfo(tileFullPath); if (string.Equals(tileInfo.Extension, ".PCX", StringComparison.InvariantCultureIgnoreCase)) { var textureSubfolder = !string.IsNullOrWhiteSpace(_terrainDB.TileSet) ? "TEXTURE_" + _terrainDB.TileSet: "TEXTURE"; tileFullPath = Path.Combine(Path.Combine(_terrainDB.CurrentTheaterTextureBaseFolderPath, textureSubfolder), Path.GetFileNameWithoutExtension(tileInfo.Name) + ".DDS"); tileInfo = new FileInfo(tileFullPath); } if (tileInfo.Exists) { try { toReturn = DDS.Load(tileFullPath); return(toReturn); } catch (Exception e) { Log.Debug(e.Message, e); } } if (!_terrainDB.TextureDotZipFileEntries.ContainsKey(tileName.ToLowerInvariant())) { return(null); } var thisEntry = _terrainDB.TextureDotZipFileEntries[tileName.ToLowerInvariant()]; using (var zipStream = _terrainDB.TextureZipFile.GetInputStream(thisEntry)) { var rawBytes = new byte[zipStream.Length]; zipStream.Read(rawBytes, 0, rawBytes.Length); toReturn = PCX.LoadFromBytes(rawBytes); } return(toReturn); }
public static int LoadTexture(string path, string name = null) { // Don't bother loading this texture again if we've already loaded it name = (string.IsNullOrEmpty(name)) ? Path.GetFileNameWithoutExtension(path) : name; if (Textures.ContainsKey(name)) { return(Textures[name]); } // Figure out what type of texture to use Texture tex; switch (Types.CurrentDataType) { case Types.DataTypes.Forces: case Types.DataTypes.LW: case Types.DataTypes.Gens: case Types.DataTypes.SU: case Types.DataTypes.S06: tex = new DDS(); break; // TODO: Add Storybook Support case Types.DataTypes.Storybook: throw new NotImplementedException( "Could not load, Storybook textures are not yet supported!"); // TODO: Add Colors Support case Types.DataTypes.Colors: throw new NotImplementedException( "Could not load, Colors textures are not yet supported!"); // TODO: Add Heroes/Shadow Support case Types.DataTypes.Shadow: case Types.DataTypes.Heroes: throw new NotImplementedException( "Could not load, Heroes/Shadow textures are not yet supported!"); // TODO: Add SA2 Support case Types.DataTypes.SA2: throw new NotImplementedException( "Could not load, SA2 textures are not yet supported!"); default: throw new Exception( "Could not load, game type has not been set!"); } // Load Texture try { int texID = -1; tex.Load(path); Program.MainUIInvoke(() => { texID = AddTexture(name, tex); }); return(texID); } catch (Exception ex) { LuaTerminal.LogError($"ERROR: {ex.Message}"); return(-1); } }