diff --git a/maya/.gitignore b/maya/.gitignore new file mode 100644 index 0000000..ba0430d --- /dev/null +++ b/maya/.gitignore @@ -0,0 +1 @@ +__pycache__/ \ No newline at end of file diff --git a/maya/bunny.drc b/maya/bunny.drc new file mode 100644 index 0000000..1e80a75 Binary files /dev/null and b/maya/bunny.drc differ diff --git a/maya/draco.py b/maya/draco.py new file mode 100644 index 0000000..84945cb --- /dev/null +++ b/maya/draco.py @@ -0,0 +1,60 @@ +''' +Usage Example: + +from draco import Draco + +drc = Draco() +mesh = drc.decode('path-to-file.drc') + +print("") +print("==== FACES ====") +print(mesh.faces_num) +print(mesh.faces[0:10]) +print("") +print("==== VERTICES ====") +print(mesh.vertices_num) +print(mesh.vertices[0:10]) +print("==== NORMALS ====") +print(mesh.normals_num) +print(mesh.normals[0:10]) +''' + +import os +import ctypes + +class Drc2PyMesh(ctypes.Structure): + _fields_ = [ + ("faces_num", ctypes.c_uint), + ("faces", ctypes.POINTER(ctypes.c_uint)), + ("vertices_num", ctypes.c_uint), + ("vertices", ctypes.POINTER(ctypes.c_float)), + ("normals_num", ctypes.c_uint), + ("normals", ctypes.POINTER(ctypes.c_float)) + ] + +# TODO: Add integration for UNIX +class Draco: + def __init__(self): + dir_path = os.path.dirname(os.path.realpath(__file__)) + lib_path = os.path.join(dir_path, 'dracodec_maya') + self.drc_lib = ctypes.CDLL(lib_path) + self.drc_decode = self.drc_lib.drc2py_decode + self.drc_decode.argtype = [ ctypes.POINTER(ctypes.c_char), ctypes.c_uint, ctypes.POINTER(ctypes.POINTER(Drc2PyMesh)) ] + + def decode(self, file_path): + file = None + bytes = None + try: + file = open(file_path, 'rb') + bytes = file.read() + except IOError as err: + print('[ERROR] Failure opening file: ' + repr(err)) + return None + finally: + if file: file.close() + + size = len(bytes) + mesh_ptr = ctypes.POINTER(Drc2PyMesh)() + self.drc_decode(bytes, size, ctypes.byref(mesh_ptr)) + mesh = mesh_ptr.contents + return mesh; diff --git a/maya/draco_example.py b/maya/draco_example.py new file mode 100644 index 0000000..cd3a6ef --- /dev/null +++ b/maya/draco_example.py @@ -0,0 +1,14 @@ +from draco import Draco + +drc = Draco() +mesh = drc.decode('bunny.drc') + +print("\n==== FACES ====") +print(mesh.faces_num) +print(mesh.faces[0:10]) +print("\n==== VERTICES ====") +print(mesh.vertices_num) +print(mesh.vertices[0:10]) +print("\n==== NORMALS ====") +print(mesh.normals_num) +# print(mesh.normals[0:10]) This mesh has no normals diff --git a/maya/dracodec_maya.dll b/maya/dracodec_maya.dll new file mode 100644 index 0000000..805ae32 Binary files /dev/null and b/maya/dracodec_maya.dll differ diff --git a/maya/libs/win64/draco.dll b/maya/libs/win64/draco.dll deleted file mode 100644 index cef2eb8..0000000 Binary files a/maya/libs/win64/draco.dll and /dev/null differ diff --git a/maya/libs/win64/dracodec.dll b/maya/libs/win64/dracodec.dll deleted file mode 100644 index f0250d5..0000000 Binary files a/maya/libs/win64/dracodec.dll and /dev/null differ diff --git a/maya/libs/win64/dracoenc.dll b/maya/libs/win64/dracoenc.dll deleted file mode 100644 index 7038280..0000000 Binary files a/maya/libs/win64/dracoenc.dll and /dev/null differ