Updated texture example to iterate through all textures.

This commit is contained in:
_ 2018-05-18 01:58:18 -07:00
parent 549105e536
commit f34289def9

View File

@ -209,19 +209,21 @@ Example Logic: Extract Pld's
fw.write(chunk) fw.write(chunk)
i += 1 i += 1
Example Logic: Extract Textures Example Logic: Extract Textures from a Single Batch
from ctypes import *
with open("pl01.pld_1.txp", "rb") as f: with open("pl01.pld_1.txp", "rb") as f:
data = f.read() data = f.read()
tx = pyTextureBatch(0, data) tp = pyTexturePack(data)
filename = "texture" filename = "texture" # part 1 of output file name
i = 0 id = 0 # part 2 of output file name
bd = pyTextureBatchDescriptor(i, data) # Iterate through all of the batches in the package.
size = bd.gettexturesize() for i in range(0, tp.getbatchnumber()):
# Get a batch.
tx = pyTextureBatch(i, data)
# Iterate through all textures in batch.
for texture in tx.gettextures(): for texture in tx.gettextures():
with open(filename + str(i) + ".dds", "wb") as fw: with open(filename + str(id) + ".dds", "wb") as fw:
fw.write(texture) fw.write(texture)
i += 1 id += 1
Example Logic: Iterate through all MeshHeaders and Meshes: Example Logic: Iterate through all MeshHeaders and Meshes:
with open("pl00.pld_0", "rb") as f: with open("pl00.pld_0", "rb") as f: