2018-05-16 03:34:53 +05:30
|
|
|
from py3devil1pld import PLDHeader
|
|
|
|
from py3devil1tex import TEXturePack, TEXtureBatchDescriptor, TEXtureBatch
|
|
|
|
from py3devil1geo import GEOHeader, MEShHeader, MEsh
|
|
|
|
|
|
|
|
#print(libc)
|
2018-05-16 01:12:16 +05:30
|
|
|
|
|
|
|
#--------------------------------------+
|
|
|
|
# Regular Python
|
|
|
|
#--------------------------------------+
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
def pldtest(devil1pld, pldheader):
|
|
|
|
with open("pl01.pld", "rb") as f:
|
|
|
|
data = f.read()
|
|
|
|
devil1pld.getheader(ctypes.byref(pldheader), data)
|
|
|
|
devil1pld.printheader(ctypes.byref(pldheader))
|
|
|
|
# for offset in pldheader.getoffsets():
|
|
|
|
# print(hex(offset))
|
|
|
|
|
|
|
|
def textest(devil1tex, texheader):
|
|
|
|
print("texture test")
|
|
|
|
with open("pl01.pld_1.txp", "rb") as f:
|
|
|
|
data = f.read()
|
|
|
|
# texheader = ctypes.cast(data, ctypes.POINTER(TexturePack))
|
|
|
|
th = ctypes.pointer(texheader)
|
|
|
|
devil1tex.getheader(ctypes.byref(th), data)
|
|
|
|
devil1tex.printheader(th)
|
|
|
|
batchdesc = TextureBatchDescriptor()
|
|
|
|
bd = ctypes.pointer(batchdesc)
|
|
|
|
print("\nbatch descriptor:")
|
|
|
|
devil1tex.getbatchdesc(ctypes.byref(bd), 1, data, len(data))
|
|
|
|
devil1tex.printbatchdesc(bd)
|
|
|
|
print(bd.contents.textureSize)
|
|
|
|
|
|
|
|
def geotest(devil1geo, geoheader):
|
|
|
|
print("geo test")
|
|
|
|
with open("pl00.pld_0", "rb") as f:
|
|
|
|
data = f.read()
|
|
|
|
# geoheader = ctypes.cast(data, ctypes.POINTER(Header))
|
|
|
|
gh = ctypes.pointer(geoheader)
|
|
|
|
devil1geo.getheader(ctypes.byref(gh), data)
|
|
|
|
devil1geo.printheader(gh)
|
|
|
|
meshheader = MeshHeader()
|
|
|
|
mh = ctypes.pointer(meshheader)
|
|
|
|
devil1geo.getmeshheader(ctypes.byref(mh), 1, data)
|
|
|
|
devil1geo.printmeshheader(mh)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
sharedlib='./lib3ddevil1.so'
|
|
|
|
libc = ctypes.cdll.LoadLibrary(sharedlib)
|
|
|
|
if (not libc):
|
|
|
|
print("Couldn't load %s" % sharedlib)
|
|
|
|
return 1
|
|
|
|
print("OK")
|
|
|
|
|
|
|
|
pldfn = Devil1PLD_FN.in_dll(libc, "DEVIL1PLD")
|
|
|
|
pldh = PldHeader()
|
|
|
|
pldtest(pldfn, pldh)
|
|
|
|
|
|
|
|
texfn = Devil1TEX_FN.in_dll(libc, "DEVIL1TEX")
|
|
|
|
texh = TexturePack()
|
|
|
|
textest(texfn, texh)
|
|
|
|
|
|
|
|
geofn = Devil1GEO_FN.in_dll(libc, "DEVIL1GEO")
|
|
|
|
geoh = Header()
|
|
|
|
geotest(geofn, geoh)
|
|
|
|
|
|
|
|
def mainx():
|
|
|
|
with open("pl01.pld", "rb") as f:
|
|
|
|
data = f.read()
|
|
|
|
pld = PLDHeader(data)
|
|
|
|
pld.show()
|
|
|
|
pld2 = PLDHeader()
|
|
|
|
pld2.show()
|
|
|
|
|
|
|
|
with open("pl01.pld_1.txp", "rb") as f:
|
|
|
|
data = f.read()
|
|
|
|
txp = TEXturePack(data)
|
|
|
|
txp.show()
|
|
|
|
print(txp.getbatchno())
|
|
|
|
print(txp.getfirstbatchoffset())
|
|
|
|
tbd = TEXtureBatchDescriptor(1, data)
|
|
|
|
tbd.show()
|
|
|
|
print(tbd.gettexturesize())
|
|
|
|
#tx = TEXtures(0, tbd.gettexno(), data)
|
|
|
|
tx = TEXtureBatch(0, data)
|
|
|
|
ts = tx.gettextures()
|
|
|
|
for i in range(0, 10):
|
|
|
|
print(ts[0].data[i])
|
|
|
|
|
|
|
|
with open("pl00.pld_0", "rb") as f:
|
|
|
|
data = f.read()
|
|
|
|
gh = GEOHeader(data)
|
|
|
|
gh.show()
|
|
|
|
print("-------------")
|
|
|
|
print(gh.getmeshno())
|
|
|
|
print(gh.getunknownb())
|
|
|
|
print(gh.getunknownc())
|
|
|
|
print(gh.getunknownd())
|
|
|
|
print(gh.getpadding())
|
|
|
|
print(gh.getunknownoffset())
|
|
|
|
mh = MEShHeader(3, data)
|
|
|
|
mh.show()
|
|
|
|
m = MEsh(0, data)
|
|
|
|
m.show()
|
|
|
|
# p = m.getpositions()
|
|
|
|
# print("positions:")
|
|
|
|
# for point in p:
|
|
|
|
# print(point)
|
|
|
|
# n = m.getnormals()
|
|
|
|
# print("normals:")
|
|
|
|
# for point in n:
|
|
|
|
# print(point)
|
|
|
|
# u = m.getuvs()
|
|
|
|
# print("uvs:")
|
|
|
|
# for point in u:
|
|
|
|
# print(point)
|
|
|
|
dbatch = m.getbatchdata()
|
|
|
|
print(hex(dbatch.numVertex))
|
|
|
|
print(hex(dbatch.padding))
|
|
|
|
#---------------------------------------+
|
|
|
|
# main()
|
|
|
|
mainx()
|