Advertisement
Guest User

Untitled

a guest
Dec 11th, 2011
284
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.07 KB | None
  1. from inc_noesis import *
  2. import noesis
  3. import rapi
  4.  
  5. def registerNoesisTypes():
  6.     handle = noesis.register("Dead Rising Texture", ".tex")
  7.     noesis.setHandlerTypeCheck(handle, noepyCheckType)
  8.     noesis.setHandlerLoadRGBA(handle, noepyLoadRGBA)
  9.     noesis.logFlush()
  10.     noesis.logPopup()
  11.     #print("The log can be useful for catching debug prints from preview loads.\nBut don't leave it on when you release your script, or it will probably annoy people.")
  12.     return 1
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. #check if it's this type based on the data
  20. def noepyCheckType(data):
  21.     bs = NoeBitStream(data)
  22.     if bs.readInt() != 0x54455800 :
  23.         return 0
  24.     return 1
  25.  
  26.  
  27.  
  28. texList = []
  29. def noepyLoadRGBA(data, texList):
  30.     bs = NoeBitStream(data, NOE_BIGENDIAN)
  31.     bs.seek(0, NOESEEK_ABS)
  32.     Tex = bs.readInt()
  33.     ukn01=bs.readByte()
  34.     ukn02=bs.readByte()
  35.     ukn03=bs.readByte()
  36.     ukn04=bs.readByte()
  37.     texW = bs.readInt()
  38.     texH = bs.readInt()
  39.     ukn05 = bs.readInt()
  40.     ukn06=bs.readByte()
  41.     ukn07=bs.readByte()
  42.     ukn08=bs.readByte()
  43.     texC=bs.readByte()
  44.     bs.seek((ukn03*4), (bs.tell()))
  45.    
  46.  
  47.     TexName = 'test'
  48.     TXPMIPS = 1
  49.     texStart = bs.tell()
  50.     texEnd = len(data)
  51.     Txpdata = bs.readBytes(texEnd - texStart)
  52.     texFmt = 0
  53.  
  54.     print("\n" * 16, "Texture: ", TexName," (", texW, " x ", texH, ") Format: ",hex(texC) , " Size: ",texEnd," bytes." , sep="")
  55.     #DXT1
  56.     if texC == 0x52:
  57.         Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
  58.         texFmt = noesis.NOESISTEX_DXT1
  59.     #DXT3
  60.     elif texC == 0x53:
  61.         Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
  62.         texFmt = noesis.NOESISTEX_DXT3
  63.     #DXT5
  64.     elif texC == 0x54:
  65.         Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 16)
  66.         texFmt = noesis.NOESISTEX_DXT5
  67.     #DXT5 packed normal map
  68.     elif texC == 0x71:
  69.         Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 16)
  70.         Txpdata = rapi.imageDecodeDXT(Txpdata, texW, texH, noesis.FOURCC_ATI2)
  71.         texFmt = noesis.NOESISTEX_RGBA32
  72.         #texFmt = noesis.NOESISTEX_DXT5
  73.     #DXT1 packed normal map
  74.     elif texC == 0x7B:
  75.         Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
  76.         Txpdata = rapi.imageDecodeDXT(Txpdata, texW, texH, noesis.FOURCC_DXT1)
  77.         texFmt = noesis.NOESISTEX_RGBA32
  78.     #DXT1 packed normal map
  79.     elif texC == 0x7C:
  80.         Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
  81.         Txpdata = rapi.imageDecodeDXT(Txpdata, texW, texH, noesis.FOURCC_DXT1NORMAL)
  82.         texFmt = noesis.NOESISTEX_RGBA32
  83.     #raw
  84.     elif texC == 0x4A:
  85.         Txpdata = rapi.imageUntile360Raw(rapi.swapEndianArray(Txpdata, 2), texW, texH, 2)
  86.         texFmt = noesis.NOESISTEX_RGBA32
  87.     #raw
  88.     elif texC == 0x86:
  89.         Txpdata = rapi.imageUntile360Raw(rapi.swapEndianArray(Txpdata, 4), texW, texH, 4)
  90.         texFmt = noesis.NOESISTEX_RGBA32
  91.     #unknown, not handled
  92.     else:
  93.         print("WARNING: Unhandled image format " + repr(texC) + " - " + repr(texW) + "x" + repr(texH) + " - " + repr(texEnd))
  94.         return None
  95.     tex1 = NoeTexture(TexName, texW, texH, Txpdata, texFmt)
  96.    
  97.     print("Last Read @ ",hex( bs.tell() ),"\n" , sep="")
  98.  
  99.     texList.append(tex1)
  100.     return 1
  101.  
Advertisement
RAW Paste Data Copied
Advertisement