/// <summary> /// TEMP: Creates super-atlas populated with all archives in array. /// Currently does not support animated textures, normal map, or emission map. /// TODO: Integrate this feature fully with material system. /// </summary> /// <param name="archives">Archive array.</param> /// <param name="borderSize">Number of pixels border to add around image.</param> /// <param name="dilate">Blend texture into surrounding empty pixels. Requires border.</param> /// <param name="maxAtlasSize">Maximum atlas size.</param> /// <param name="alphaTextureFormat">Alpha TextureFormat.</param> /// <param name="nonAlphaFormat">Non-alpha TextureFormat.</param> /// <returns>TextureAtlasBuilder.</returns> public TextureAtlasBuilder CreateTextureAtlasBuilder( int[] archives, int borderSize = 0, bool dilate = false, int maxAtlasSize = 2048, SupportedAlphaTextureFormats alphaTextureFormat = SupportedAlphaTextureFormats.RGBA32, SupportedNonAlphaTextureFormats nonAlphaFormat = SupportedNonAlphaTextureFormats.RGB24) { // Iterate archives TextureFile textureFile = new TextureFile(); TextureAtlasBuilder builder = new TextureAtlasBuilder(); GetTextureSettings settings = TextureReader.CreateTextureSettings(0, 0, 0, 0, borderSize, dilate, maxAtlasSize); settings.stayReadable = true; for (int i = 0; i < archives.Length; i++) { // Load texture file settings.archive = archives[i]; textureFile.Load(Path.Combine(Arena2Path, TextureFile.IndexToFileName(settings.archive)), FileUsage.UseMemory, true); // Add all records for this archive - single frame only for (int record = 0; record < textureFile.RecordCount; record++) { settings.record = record; GetTextureResults results = GetTexture2D(settings, alphaTextureFormat, nonAlphaFormat); DFSize size = textureFile.GetSize(record); DFSize scale = textureFile.GetScale(record); builder.AddTextureItem( results.albedoMap, settings.archive, settings.record, 0, 1, new Vector2(size.Width, size.Height), new Vector2(scale.Width, scale.Height)); } } // Apply the builder builder.Rebuild(borderSize); return(builder); }
private bool ReadyCheck() { // Ensure we have a DaggerfallUnity reference if (dfUnity == null) { dfUnity = DaggerfallUnity.Instance; } // Do nothing if DaggerfallUnity not ready if (!dfUnity.IsReady) { DaggerfallUnity.LogMessage("MaterialReader: DaggerfallUnity component is not ready. Have you set your Arena2 path?"); return false; } // Ensure texture reader is ready if (textureReader == null) { textureReader = new TextureReader(dfUnity.Arena2Path); } return true; }