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)
i += 1
Example Logic: Extract Textures
from ctypes import *
Example Logic: Extract Textures from a Single Batch
with open("pl01.pld_1.txp", "rb") as f:
data = f.read()
tx = pyTextureBatch(0, data)
filename = "texture"
i = 0
bd = pyTextureBatchDescriptor(i, data)
size = bd.gettexturesize()
for texture in tx.gettextures():
with open(filename + str(i) + ".dds", "wb") as fw:
fw.write(texture)
i += 1
tp = pyTexturePack(data)
filename = "texture" # part 1 of output file name
id = 0 # part 2 of output file name
# Iterate through all of the batches in the package.
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():
with open(filename + str(id) + ".dds", "wb") as fw:
fw.write(texture)
id += 1
Example Logic: Iterate through all MeshHeaders and Meshes:
with open("pl00.pld_0", "rb") as f: