If you want the best examples for images MR adults has them in his bullet witch script and in the quake formats.
so here is the code
Code: Select all
#Noesis Python model import+export test module, imports/exports some data from/to a made-up format
from inc_noesis import *
import noesis
#rapi methods should only be used during handler callbacks
import rapi
#registerNoesisTypes is called by Noesis to allow the script to register formats.
#Do not implement this function in script files unless you want them to be dedicated format modules!
def registerNoesisTypes():
handle = noesis.register("Virtual Fighter 5 Textures", ".bin")
noesis.setHandlerTypeCheck(handle, noepyCheckType)
noesis.setHandlerLoadRGBA(handle, noepyLoadRGBA)
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() != 0x3505854 :
return 0
return 1
texList = []
def noepyLoadRGBA(data, texList):
bs = NoeBitStream(data)
bs.seek(0, NOESEEK_ABS)
Tex = bs.readInt()
TexCount = bs.readInt()
Unk01 = bs.readInt()
TexOffList = bs.read("i"*TexCount)
for i in range(0, TexCount):
TexName = 'test'
bs.seek(TexOffList[i], NOESEEK_ABS)
print(bs.tell())
TXP = bs.readInt()
TXPMIPS = bs.readInt()
TXPUNK = bs.readInt()
TexOff = bs.readInt()
bs.seek(TexOffList[i] + TexOff, NOESEEK_ABS)
TxpHeader = bs.read("i"*6)
print(bs.tell())
Txpdata = bs.readBytes(TxpHeader[5])
print(TxpHeader)
print(TxpHeader[3])
texFmt = 0
#DXT1
if TxpHeader[3] == 6:
texFmt = noesis.NOESISTEX_DXT1
#DXT3
if TxpHeader[3] == 7:
texFmt = noesis.NOESISTEX_DXT3
#DXT5
if TxpHeader[3] == 9:
texFmt = noesis.NOESISTEX_DXT5
#ATI2N
if TxpHeader[3] == 11:
Txpdata = rapi.imageDecodeDXT(Txpdata, int(TxpHeader[1]), int(TxpHeader[2]), noesis.FOURCC_ATI2)
texFmt = noesis.NOESISTEX_RGBA32
tex1 = NoeTexture(TexName, int(TxpHeader[1]), int(TxpHeader[2]), Txpdata, texFmt)
texList.append(tex1)
return 1So these are the important lines.
Code: Select all
#DXT1
if TxpHeader[3] == 6:
texFmt = noesis.NOESISTEX_DXT1
#DXT3
if TxpHeader[3] == 7:
texFmt = noesis.NOESISTEX_DXT3
#DXT5
if TxpHeader[3] == 9:
texFmt = noesis.NOESISTEX_DXT5
#ATI2N
if TxpHeader[3] == 11:
Txpdata = rapi.imageDecodeDXT(Txpdata, int(TxpHeader[1]), int(TxpHeader[2]), noesis.FOURCC_ATI2)
texFmt = noesis.NOESISTEX_RGBA32
tex1 = NoeTexture(TexName, int(TxpHeader[1]), int(TxpHeader[2]), Txpdata, texFmt)
texList.append(tex1)This was the line at the end of bullet witch
NoeTexture(entry.name, imgWidth, imgHeight, data, texFmt)
Then once you have This up and running you can import this script into a model script to have the textures load right into the texture list of your main script.


