diff --git a/Penumbra/Importer/TexToolsImport.cs b/Penumbra/Importer/TexToolsImport.cs index 2a785994..de183fab 100644 --- a/Penumbra/Importer/TexToolsImport.cs +++ b/Penumbra/Importer/TexToolsImport.cs @@ -267,6 +267,9 @@ private void ExtractMod( DirectoryInfo outDirectory, SimpleMod mod, SqPackStream var extractedFile = new FileInfo( Path.Combine( outDirectory.FullName, mod.FullPath ) ); extractedFile.Directory?.Create(); + if( extractedFile.FullName.EndsWith( "mdl" ) ) + ProcessMdl( data.Data ); + File.WriteAllBytes( extractedFile.FullName, data.Data ); } catch( Exception ex ) @@ -275,6 +278,21 @@ private void ExtractMod( DirectoryInfo outDirectory, SimpleMod mod, SqPackStream } } + private void ProcessMdl( byte[] mdl ) + { + // Model file header LOD num + mdl[ 64 ] = 1; + + // Model header LOD num + var stackSize = BitConverter.ToUInt32( mdl, 4 ); + var runtimeBegin = stackSize + 0x44; + var stringsLengthOffset = runtimeBegin + 4; + var stringsLength = BitConverter.ToUInt32( mdl, (int) stringsLengthOffset ); + var modelHeaderStart = stringsLengthOffset + stringsLength + 4; + var modelHeaderLodOffset = 22; + mdl[ modelHeaderStart + modelHeaderLodOffset ] = 1; + } + private static Stream GetStreamFromZipEntry( ZipFile file, ZipEntry entry ) { return file.GetInputStream( entry );