Page 1 of 1

Star Wars Kinect (XBOX360) .TEX

Posted: Mon Aug 19, 2019 12:51 pm
by gwlogan
Hello,
I've been using a Noesis python script to extract the game's textures but I'm having an issue with the displayed image dimensions when viewing the .tex files. I've mostly been using the game's .tga texture files with no problems but I've noticed the .tex files seem to include some higher resolution textures and it would be nice to properly extract these! This might be due to the .tex files being containers rather than just textures but I don't really know for sure. Here is an example of what is displayed in Noesis when viewing the .tga and .tex files respectively:
Image
Here are the .tex file samples:
http://www.mediafire.com/file/4lqbkmr3g ... s.zip/file
Noesis python script:

Code: Select all

from inc_noesis import *

def registerNoesisTypes():
	handle = noesis.register("Star Wars Kinect TEX", ".tex")
	noesis.setHandlerTypeCheck(handle, StarWarsKinectCheckType)
	noesis.setHandlerLoadRGBA(handle, StarWarsKinectLoadRGBA)
	return 1

def StarWarsKinectCheckType(data):
	bs = NoeBitStream(data)
	Magic = bs.readInt()
	if Magic != 8:
		return 0
	return 1   

def StarWarsKinectLoadRGBA(data, texList):
	datasize = len(data) - 0x34
	bs = NoeBitStream(data)
	bs.seek(0x18, NOESEEK_ABS)
	imgFmt = bs.readInt()
	imgWidth = bs.readInt() // 2
	imgHeight = bs.readInt() // 2
	if imgHeight == 2:
		imgHeight = 4
	data01 = bs.readInt()
	data02 = bs.readInt()
	bs.seek(0x34, NOESEEK_ABS)
	data = bs.readBytes(datasize)
	#DXT1
	if imgFmt == 0x28:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 8)
		texFmt = noesis.NOESISTEX_DXT1
	#DXT5
	elif imgFmt == 0x33:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 16)
		texFmt = noesis.NOESISTEX_DXT5
	#DXT5 packed normal map
	elif imgFmt == 0x1C:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 16)
		data = rapi.imageDecodeDXT(data, imgWidth, imgHeight, noesis.FOURCC_ATI2)
		texFmt = noesis.NOESISTEX_RGBA32
	#DXT5 packed normal map2
	elif imgFmt == 0x36:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 16)
		data = rapi.imageDecodeDXT(data, imgWidth, imgHeight, noesis.FOURCC_ATI1)
		texFmt = noesis.NOESISTEX_RGBA32
	#DXT1 packed normal map
	elif imgFmt == 0x16:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 8)
		data = rapi.imageDecodeDXT(data, imgWidth, imgHeight, noesis.FOURCC_DXT1NORMAL)
		texFmt = noesis.NOESISTEX_RGBA32
	#raw
	elif imgFmt == 0x1B:
		data = rapi.imageUntile360Raw(rapi.swapEndianArray(data, 4), imgWidth, imgHeight, 4)
		texFmt = noesis.NOESISTEX_RGBA32
	#unknown, not handled
	else:
		print("WARNING: Unhandled image format " + repr(imgFmt) + " - " + repr(imgWidth) + "x" + repr(imgHeight) + " - " + repr(len(data)))
		return None
	texList.append(NoeTexture(rapi.getInputName(), imgWidth, imgHeight, data, texFmt))
	return 1

Re: Star Wars Kinect (XBOX360) .TEX

Posted: Sat Aug 24, 2019 3:37 am
by Acewell
try this :D
tex_SWKinect_X360_tga_tex.zip

Re: Star Wars Kinect (XBOX360) .TEX

Posted: Sun Dec 15, 2019 2:04 am
by gwlogan
Thank you Acewell, your script works great!