home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 15490 / RE2_R.7z / fmt_RE2_REMAKE_tex.py next >
Encoding:
Python Source  |  2019-01-15  |  2.5 KB  |  85 lines

  1. ∩╗┐#RE 2 Remake .tex [PC] - ".10" Loader
  2. #v1.0 by zaramot
  3.  
  4. from inc_noesis import *
  5.  
  6. def registerNoesisTypes():
  7.     handle = noesis.register("RE 2 Remake Texture [PC]", ".10",)
  8.     noesis.setHandlerTypeCheck(handle, datCheckType)
  9.     noesis.setHandlerLoadRGBA(handle, datLoadDDS)
  10.     noesis.logPopup()
  11.     return 1
  12.         
  13. def datCheckType(data):
  14.     bs = NoeBitStream(data)
  15.     fileMagic = bs.readUInt()
  16.     if fileMagic == 0x584554:
  17.         return 1
  18.     else: 
  19.         print("Fatal Error: Unknown file magic: " + str(hex(fileMagic) + " expected 0x584554!"))
  20.         return 0
  21.  
  22. def datLoadDDS(data, texList):
  23.     bs = NoeBitStream(data)
  24.     
  25.     numTextures  = 1
  26.     fileMagic = bs.readUInt()
  27.     
  28.     for i in range (1):
  29.         bs.seek((0x4), NOESEEK_REL)
  30.         ddsWidth =  bs.readUShort()
  31.         ddsHeight =  bs.readUShort()
  32.         unk1 =  bs.readUShort()
  33.         unk2 =  bs.readUShort()
  34.         dxtType =  bs.readUInt()
  35.         bs.seek((0xC), NOESEEK_REL)
  36.         dataOff = bs.readUInt()
  37.         bs.seek((0x8), NOESEEK_REL)
  38.         ddsSize = bs.readUInt()
  39.         ddsName = rapi.getLocalFileName(rapi.getInputName())
  40.         bs.seek((dataOff), NOESEEK_ABS)
  41.         print (ddsSize)
  42.         print (dxtType)
  43.         print (dataOff)
  44.         ddsData = bs.readBytes(ddsSize)      
  45.         #DXT1
  46.         if dxtType == 7:
  47.             ddsFmt = noesis.NOESISTEX_DXT1
  48.         #DXT3
  49.         if dxtType == 26:
  50.             ddsFmt = noesis.NOESISTEX_DXT3
  51.         #DXT5
  52.         elif dxtType == 26:
  53.             ddsFmt = noesis.NOESISTEX_DXT5
  54.         #ATI1
  55.         elif dxtType == 7:
  56.             ddsData = rapi.imageDecodeDXT(ddsData, ddsWidth, ddsHeight, noesis.FOURCC_ATI1)
  57.             ddsFmt = noesis.NOESISTEX_RGBA32    
  58.         #ATI2
  59.         elif dxtType == 26:
  60.             ddsData = rapi.imageDecodeDXT(ddsData, ddsWidth, ddsHeight, noesis.FOURCC_ATI2)
  61.             ddsFmt = noesis.NOESISTEX_RGBA32
  62.         #BC7
  63.         elif dxtType == 98:
  64.             ddsData = rapi.imageDecodeDXT(ddsData, ddsWidth, ddsHeight, noesis.FOURCC_BC7)
  65.             ddsFmt = noesis.NOESISTEX_RGBA32    
  66.         #ATI1
  67.         elif dxtType == 80:
  68.             ddsData = rapi.imageDecodeDXT(ddsData, ddsWidth, ddsHeight, noesis.FOURCC_ATI1)
  69.             ddsFmt = noesis.NOESISTEX_RGBA32
  70.         #BC7
  71.         elif dxtType == 99:
  72.             ddsData = rapi.imageDecodeDXT(ddsData, ddsWidth, ddsHeight, noesis.FOURCC_BC7)
  73.             ddsFmt = noesis.NOESISTEX_RGBA32
  74.         #DXT1 packed normal map
  75.         elif dxtType == 71:
  76.             ddsFmt = noesis.NOESISTEX_DXT1
  77.         #raw
  78.         elif dxtType == 7:
  79.             ddsData = rapi.imageDecodeRaw(ddsData, ddsWidth, ddsHeight, "a8r8g8b8")
  80.             ddsFmt = noesis.NOESISTEX_RGBA32
  81.         #print (ddsType)   
  82.         #print (dxtType)      
  83.         texList.append(NoeTexture(ddsName, ddsWidth, ddsHeight, ddsData, ddsFmt))
  84.     return 1
  85.