Merge pull request #532 from Jiloc/patch-1

integrate maya plugin loading on linux
This commit is contained in:
FrankGalligan 2020-02-03 11:52:36 -08:00 committed by GitHub
commit f29415698d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ Draco wrapper for Maya extensions
import os import os
import ctypes import ctypes
import platform
__author__ = "Mattia Pezzano, Federico de Felici, Duccio Lenkowicz" __author__ = "Mattia Pezzano, Federico de Felici, Duccio Lenkowicz"
__version__ = "0.1" __version__ = "0.1"
@ -43,12 +44,17 @@ def array_to_ptr(array, size, ctype):
carr = (ctype * size)(*array) carr = (ctype * size)(*array)
return ctypes.cast(carr, ctypes.POINTER(ctype)) return ctypes.cast(carr, ctypes.POINTER(ctype))
# TODO: Add integration for reading Linux lib
class Draco: class Draco:
def __init__(self): def __init__(self):
# Lib loading # Lib loading
if platform.system() == 'Linux':
lib_name = 'libdraco_maya_wrapper.so'
else:
lib_name = 'draco_maya_wrapper'
dir_path = os.path.dirname(os.path.realpath(__file__)) dir_path = os.path.dirname(os.path.realpath(__file__))
lib_path = os.path.join(dir_path, 'draco_maya_wrapper') lib_path = os.path.join(dir_path, lib_name)
self.drc_lib = ctypes.CDLL(lib_path) self.drc_lib = ctypes.CDLL(lib_path)
# Mapping decode funct # Mapping decode funct
self.drc_decode = self.drc_lib.drc2py_decode self.drc_decode = self.drc_lib.drc2py_decode
@ -120,4 +126,3 @@ class Draco:
mesh_ptr = ctypes.byref(mesh) mesh_ptr = ctypes.byref(mesh)
file_ptr = ctypes.c_char_p(file.encode()) file_ptr = ctypes.c_char_p(file.encode())
self.drc_encode(mesh_ptr, file_ptr) self.drc_encode(mesh_ptr, file_ptr)