Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from inc_noesis import *
- import noesis
- import rapi
- def registerNoesisTypes():
- handle = noesis.register("Dead Rising Texture", ".tex")
- noesis.setHandlerTypeCheck(handle, noepyCheckType)
- noesis.setHandlerLoadRGBA(handle, noepyLoadRGBA)
- noesis.logFlush()
- noesis.logPopup()
- #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.")
- return 1
- #check if it's this type based on the data
- def noepyCheckType(data):
- bs = NoeBitStream(data)
- if bs.readInt() != 0x54455800 :
- return 0
- return 1
- texList = []
- def noepyLoadRGBA(data, texList):
- bs = NoeBitStream(data, NOE_BIGENDIAN)
- bs.seek(0, NOESEEK_ABS)
- Tex = bs.readInt()
- ukn01=bs.readByte()
- ukn02=bs.readByte()
- ukn03=bs.readByte()
- ukn04=bs.readByte()
- texW = bs.readInt()
- texH = bs.readInt()
- ukn05 = bs.readInt()
- ukn06=bs.readByte()
- ukn07=bs.readByte()
- ukn08=bs.readByte()
- texC=bs.readByte()
- bs.seek((ukn03*4), (bs.tell()))
- TexName = 'test'
- TXPMIPS = 1
- texStart = bs.tell()
- texEnd = len(data)
- Txpdata = bs.readBytes(texEnd - texStart)
- texFmt = 0
- print("\n" * 16, "Texture: ", TexName," (", texW, " x ", texH, ") Format: ",hex(texC) , " Size: ",texEnd," bytes." , sep="")
- #DXT1
- if texC == 0x52:
- Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
- texFmt = noesis.NOESISTEX_DXT1
- #DXT3
- elif texC == 0x53:
- Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
- texFmt = noesis.NOESISTEX_DXT3
- #DXT5
- elif texC == 0x54:
- Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 16)
- texFmt = noesis.NOESISTEX_DXT5
- #DXT5 packed normal map
- elif texC == 0x71:
- Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 16)
- Txpdata = rapi.imageDecodeDXT(Txpdata, texW, texH, noesis.FOURCC_ATI2)
- texFmt = noesis.NOESISTEX_RGBA32
- #texFmt = noesis.NOESISTEX_DXT5
- #DXT1 packed normal map
- elif texC == 0x7B:
- Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
- Txpdata = rapi.imageDecodeDXT(Txpdata, texW, texH, noesis.FOURCC_DXT1)
- texFmt = noesis.NOESISTEX_RGBA32
- #DXT1 packed normal map
- elif texC == 0x7C:
- Txpdata = rapi.imageUntile360DXT(rapi.swapEndianArray(Txpdata, 2), texW, texH, 8)
- Txpdata = rapi.imageDecodeDXT(Txpdata, texW, texH, noesis.FOURCC_DXT1NORMAL)
- texFmt = noesis.NOESISTEX_RGBA32
- #raw
- elif texC == 0x4A:
- Txpdata = rapi.imageUntile360Raw(rapi.swapEndianArray(Txpdata, 2), texW, texH, 2)
- texFmt = noesis.NOESISTEX_RGBA32
- #raw
- elif texC == 0x86:
- Txpdata = rapi.imageUntile360Raw(rapi.swapEndianArray(Txpdata, 4), texW, texH, 4)
- texFmt = noesis.NOESISTEX_RGBA32
- #unknown, not handled
- else:
- print("WARNING: Unhandled image format " + repr(texC) + " - " + repr(texW) + "x" + repr(texH) + " - " + repr(texEnd))
- return None
- tex1 = NoeTexture(TexName, texW, texH, Txpdata, texFmt)
- print("Last Read @ ",hex( bs.tell() ),"\n" , sep="")
- texList.append(tex1)
- return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement