Added pack to packed structs

This commit is contained in:
_ 2018-04-24 19:15:39 -07:00
parent 8585702471
commit 790afd9960

View File

@ -31,6 +31,7 @@ class Devil1PLD_FN(ctypes.Structure):
#--------------------------------------+ #--------------------------------------+
class TexturePack(ctypes.Structure): class TexturePack(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("id", ctypes.c_char * 4), # fixed length 4, reverse order ("id", ctypes.c_char * 4), # fixed length 4, reverse order
("batchNumber", ctypes.c_int), ("batchNumber", ctypes.c_int),
@ -39,6 +40,7 @@ class TexturePack(ctypes.Structure):
] ]
class TextureBatchDescriptor(ctypes.Structure): class TextureBatchDescriptor(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("batchIdx", ctypes.c_int), ("batchIdx", ctypes.c_int),
("hash", ctypes.c_int), ("hash", ctypes.c_int),
@ -49,11 +51,13 @@ class TextureBatchDescriptor(ctypes.Structure):
] ]
class Texture(ctypes.Structure): class Texture(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("data", ctypes.c_ubyte) ("data", ctypes.c_ubyte)
] ]
class TextureBatch(ctypes.Structure): class TextureBatch(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("batch", ctypes.POINTER(Texture)) ("batch", ctypes.POINTER(Texture))
] ]
@ -98,6 +102,7 @@ class Devil1TEX_FN(ctypes.Structure):
#--------------------------------------+ #--------------------------------------+
class Header(ctypes.Structure): class Header(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("numMesh", ctypes.c_ubyte), ("numMesh", ctypes.c_ubyte),
("unknownNumberB", ctypes.c_ubyte), ("unknownNumberB", ctypes.c_ubyte),
@ -108,6 +113,7 @@ class Header(ctypes.Structure):
] ]
class MeshHeader(ctypes.Structure): class MeshHeader(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("numBatch", ctypes.c_short), ("numBatch", ctypes.c_short),
("numVertex", ctypes.c_short), ("numVertex", ctypes.c_short),
@ -117,6 +123,7 @@ class MeshHeader(ctypes.Structure):
] ]
class Coordinate(ctypes.Structure): class Coordinate(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("x", ctypes.c_float), ("x", ctypes.c_float),
("y", ctypes.c_float), ("y", ctypes.c_float),
@ -124,23 +131,27 @@ class Coordinate(ctypes.Structure):
] ]
class UVs(ctypes.Structure): class UVs(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("u", ctypes.c_short), ("u", ctypes.c_short),
("v", ctypes.c_short) ("v", ctypes.c_short)
] ]
class BoneIndexes(ctypes.Structure): class BoneIndexes(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("indexes", ctypes.c_ubyte * 4), ("indexes", ctypes.c_ubyte * 4),
] ]
class BoneWeights(ctypes.Structure): class BoneWeights(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("weights", ctypes.c_short) ("weights", ctypes.c_short)
] ]
class BatchData(ctypes.Structure): class BatchData(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("numVertex", ctypes.c_short), ("numVertex", ctypes.c_short),
("uB", ctypes.c_short), ("uB", ctypes.c_short),
@ -154,6 +165,7 @@ class BatchData(ctypes.Structure):
] ]
class VertexData(ctypes.Structure): class VertexData(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("positions", ctypes.POINTER(Coordinate)), ("positions", ctypes.POINTER(Coordinate)),
("normals", ctypes.POINTER(Coordinate)), ("normals", ctypes.POINTER(Coordinate)),
@ -163,12 +175,14 @@ class VertexData(ctypes.Structure):
] ]
class Batch(ctypes.Structure): class Batch(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("bd", ctypes.POINTER(BatchData)), ("bd", ctypes.POINTER(BatchData)),
("vd", VertexData) ("vd", VertexData)
] ]
class Mesh(ctypes.Structure): class Mesh(ctypes.Structure):
_pack_ = 1
_fields_ = [ _fields_ = [
("b", ctypes.POINTER(Batch)) ("b", ctypes.POINTER(Batch))
] ]
@ -220,6 +234,7 @@ if __name__ == "__main__":
devil1pld.printheader(ctypes.byref(pldheader)) devil1pld.printheader(ctypes.byref(pldheader))
print(pldheader) print(pldheader)
print(pldheader.numOffset) print(pldheader.numOffset)
print(pldheader.offsets)
for i in range(0, pldheader.numOffset): for i in range(0, pldheader.numOffset):
print(hex(pldheader.offsets[i])) print(hex(pldheader.offsets[i]))