mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-21 21:32:58 +05:30
Added getpositions and printable coordinates
This commit is contained in:
parent
e4aeba9421
commit
8fdc05b9c0
@ -130,6 +130,9 @@ class Coordinate(ctypes.Structure):
|
||||
("z", ctypes.c_float)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return "(%s, %s, %s)" % (str(self.x), str(self.y), str(self.z))
|
||||
|
||||
class UVs(ctypes.Structure):
|
||||
_pack_ = 1
|
||||
_fields_ = [
|
||||
@ -232,7 +235,7 @@ libc = ctypes.cdll.LoadLibrary(sharedlib)
|
||||
if not libc:
|
||||
print("Couldn't load %s" % sharedlib)
|
||||
sys.exit()
|
||||
|
||||
del sys
|
||||
print("\nlib3ddevil1 loaded.")
|
||||
devil1pld = Devil1PLD_FN.in_dll(libc, "DEVIL1PLD")
|
||||
devil1tex = Devil1TEX_FN.in_dll(libc, "DEVIL1TEX")
|
||||
@ -343,13 +346,16 @@ class MEsh:
|
||||
mh = MEShHeader(i, filedata)
|
||||
# allocate memory for the size of batch * number of batches
|
||||
memsize = ctypes.sizeof(Batch) * mh.getbatchno()
|
||||
self.cstruct.b = ctypes.cast(ctypes.create_string_buffer(memsize),
|
||||
ctypes.POINTER(Batch))
|
||||
if not devil1geo.getmesh(ctypes.byref(self.cstruct),
|
||||
self.cstruct.b = ctypes.cast(
|
||||
ctypes.create_string_buffer(memsize),
|
||||
ctypes.POINTER(Batch))
|
||||
if not devil1geo.getmesh(
|
||||
ctypes.byref(self.cstruct),
|
||||
i,
|
||||
filedata,
|
||||
len(filedata)):
|
||||
print("failed to get mesh")
|
||||
del mh, memsize
|
||||
return
|
||||
|
||||
def show(self):
|
||||
@ -358,6 +364,10 @@ class MEsh:
|
||||
else:
|
||||
print("nothing to show")
|
||||
|
||||
def getpositions(self):
|
||||
length = self.cstruct.b.contents.bd.contents.numVertex
|
||||
return self.cstruct.b.contents.vd.positions[:length]
|
||||
|
||||
#--------------------------------------+
|
||||
# Regular Python
|
||||
#--------------------------------------+
|
||||
@ -445,6 +455,9 @@ if __name__ == "__main__":
|
||||
mh.show()
|
||||
m = MEsh(0, data)
|
||||
m.show()
|
||||
p = m.getpositions()
|
||||
for point in p:
|
||||
print(point)
|
||||
#---------------------------------------+
|
||||
# main()
|
||||
mainx()
|
||||
|
Loading…
Reference in New Issue
Block a user