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