mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-25 16:28:57 +05:30
Fixed TEXtureBatchDescriptor
This commit is contained in:
parent
62841adcb9
commit
b30359aabc
@ -240,24 +240,12 @@ devil1geo = Devil1GEO_FN.in_dll(libc, "DEVIL1GEO")
|
|||||||
|
|
||||||
class PLDHeader:
|
class PLDHeader:
|
||||||
def __init__(self, filedata = None):
|
def __init__(self, filedata = None):
|
||||||
# self.offsets = []
|
|
||||||
# if filedata:
|
|
||||||
# h = PldHeader()
|
|
||||||
# devil1pld.getheader(ctypes.byref(h), filedata)
|
|
||||||
# self.offsets = h.offsets[:h.numOffset]
|
|
||||||
# self.offsets.append(len(filedata))
|
|
||||||
# Store C Struct in order to call C functions
|
# Store C Struct in order to call C functions
|
||||||
self.cstruct = PldHeader()
|
self.cstruct = PldHeader()
|
||||||
if filedata:
|
if filedata:
|
||||||
devil1pld.getheader(ctypes.byref(self.cstruct), filedata)
|
devil1pld.getheader(ctypes.byref(self.cstruct), filedata)
|
||||||
self.eof = len(filedata)
|
self.eof = len(filedata)
|
||||||
|
|
||||||
# def __str__(self):
|
|
||||||
# output = "numOffset: %s" % str(len(self.offsets))
|
|
||||||
# for offset in self.offsets:
|
|
||||||
# output += "\n\t" + str(hex(offset))
|
|
||||||
# return output
|
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
devil1pld.printheader(ctypes.byref(self.cstruct))
|
devil1pld.printheader(ctypes.byref(self.cstruct))
|
||||||
return
|
return
|
||||||
@ -290,27 +278,26 @@ class TEXturePack:
|
|||||||
|
|
||||||
class TEXtureBatchDescriptor:
|
class TEXtureBatchDescriptor:
|
||||||
def __init__(self, i, filedata):
|
def __init__(self, i, filedata):
|
||||||
self.cstruct = TextureBatchDescriptor()
|
self.cstruct = ctypes.pointer(TextureBatchDescriptor())
|
||||||
ptrofptr = ctypes.byref(ctypes.byref(self.cstruct))
|
ptrofptr = ctypes.byref(self.cstruct)
|
||||||
if filedata():
|
if filedata:
|
||||||
devil1tex.getbatchdesc(ptrofptr, i, filedata, len(filedata))
|
devil1tex.getbatchdesc(ptrofptr, i, filedata, len(filedata))
|
||||||
return
|
return
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
ptr = ctypes.byref(self.cstruct)
|
devil1tex.printbatchdesc(self.cstruct)
|
||||||
devil1tex.printbatchdesc(ptr)
|
|
||||||
|
|
||||||
def getbatchidx(self):
|
def getbatchidx(self):
|
||||||
return self.cstruct.batchIdx
|
return self.cstruct.contents.batchIdx
|
||||||
|
|
||||||
def gethash(self):
|
def gethash(self):
|
||||||
return self.cstruct.hash
|
return self.cstruct.contents.hash
|
||||||
|
|
||||||
def gettexno(self):
|
def gettexno(self):
|
||||||
return self.cstruct.texNumber
|
return self.cstruct.contents.texNumber
|
||||||
|
|
||||||
def gettexturesize(self):
|
def gettexturesize(self):
|
||||||
return self.cstruct.textureSize
|
return self.cstruct.contents.textureSize
|
||||||
|
|
||||||
class TEXtures:
|
class TEXtures:
|
||||||
def __init__(self, i, batchdescriptor, filedata):
|
def __init__(self, i, batchdescriptor, filedata):
|
||||||
@ -328,10 +315,11 @@ if __name__ == "__main__":
|
|||||||
data = f.read()
|
data = f.read()
|
||||||
devil1pld.getheader(ctypes.byref(pldheader), data)
|
devil1pld.getheader(ctypes.byref(pldheader), data)
|
||||||
devil1pld.printheader(ctypes.byref(pldheader))
|
devil1pld.printheader(ctypes.byref(pldheader))
|
||||||
for offset in pldheader.getoffsets():
|
# for offset in pldheader.getoffsets():
|
||||||
print(hex(offset))
|
# print(hex(offset))
|
||||||
|
|
||||||
def textest(devil1tex, texheader):
|
def textest(devil1tex, texheader):
|
||||||
|
print("texture test")
|
||||||
with open("pl01.pld_1.txp", "rb") as f:
|
with open("pl01.pld_1.txp", "rb") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
# texheader = ctypes.cast(data, ctypes.POINTER(TexturePack))
|
# texheader = ctypes.cast(data, ctypes.POINTER(TexturePack))
|
||||||
@ -342,8 +330,11 @@ if __name__ == "__main__":
|
|||||||
bd = ctypes.pointer(batchdesc)
|
bd = ctypes.pointer(batchdesc)
|
||||||
print("\nbatch descriptor:")
|
print("\nbatch descriptor:")
|
||||||
devil1tex.getbatchdesc(ctypes.byref(bd), 1, data, len(data))
|
devil1tex.getbatchdesc(ctypes.byref(bd), 1, data, len(data))
|
||||||
|
devil1tex.printbatchdesc(bd)
|
||||||
|
print(bd.contents.textureSize)
|
||||||
|
|
||||||
def geotest(devil1geo, geoheader):
|
def geotest(devil1geo, geoheader):
|
||||||
|
print("geo test")
|
||||||
with open("pl00.pld_0", "rb") as f:
|
with open("pl00.pld_0", "rb") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
# geoheader = ctypes.cast(data, ctypes.POINTER(Header))
|
# geoheader = ctypes.cast(data, ctypes.POINTER(Header))
|
||||||
@ -389,7 +380,11 @@ if __name__ == "__main__":
|
|||||||
txp.show()
|
txp.show()
|
||||||
print(txp.getbatchno())
|
print(txp.getbatchno())
|
||||||
print(txp.getfirstbatchoffset())
|
print(txp.getfirstbatchoffset())
|
||||||
|
tbd = TEXtureBatchDescriptor(1, data)
|
||||||
|
tbd.show()
|
||||||
|
print(tbd.gettexturesize())
|
||||||
|
|
||||||
#---------------------------------------+
|
#---------------------------------------+
|
||||||
# main()
|
main()
|
||||||
mainx()
|
mainx()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user