From f34289def982afe760808daa9af06a183ddeeaaa Mon Sep 17 00:00:00 2001 From: _ <_> Date: Fri, 18 May 2018 01:58:18 -0700 Subject: [PATCH] Updated texture example to iterate through all textures. --- docs/doc-python.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/doc-python.txt b/docs/doc-python.txt index 0c813a0..6324206 100644 --- a/docs/doc-python.txt +++ b/docs/doc-python.txt @@ -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: