diff --git a/maya/README.md b/maya/README.md new file mode 100644 index 0000000..5321388 --- /dev/null +++ b/maya/README.md @@ -0,0 +1,6 @@ +Description +=========== + +Plugin which add support for Draco files in Autodesk Maya. +Currently is supported drc file import on Windows, from the import menu or by drag & drop + diff --git a/maya/draco_maya.py b/maya/draco_maya.py new file mode 100644 index 0000000..f5a670a --- /dev/null +++ b/maya/draco_maya.py @@ -0,0 +1,59 @@ +import maya.api.OpenMaya as OpenMaya +import maya.OpenMayaMPx as OpenMayaMPx +import sys + +__author__ = "Mattia Pezzano, Federico de Felici, Duccio Lenkowicz" +__version__ = "0.1" + +class DracoTranslator(OpenMayaMPx.MPxFileTranslator): + def __init__(self): + OpenMayaMPx.MPxFileTranslator.__init__(self) + + def maya_useNewAPI(): + pass + + def haveWriteMethod(self): + return False + + def haveReadMethod(self): + return True + + def filter(self): + return "*.drc" + + def defaultExtension(self): + return "drc" + + def reader(self, fileObject, optionString, accessMode): + print(fileObject.fullName()) + vertices = [OpenMaya.MPoint(10, 10, 10), OpenMaya.MPoint(-10, -10, -10), OpenMaya.MPoint(0, 10, 0)] + indices = [0, 1, 2] + polyCount = [3] + + fnMesh = OpenMaya.MFnMesh() + newMesh = fnMesh.create(vertices, polyCount, indices) + fnMesh.updateSurface() + +def translatorCreator(): + return OpenMayaMPx.asMPxPtr(DracoTranslator()) + + +def initializePlugin(mobject): + print('init') + mplugin = OpenMayaMPx.MFnPlugin( + mobject, "Autodesk", '0.1', "Any") + + try: + mplugin.registerFileTranslator( + 'drc', + None, + translatorCreator) # , + # kPluginTranslatorDefaultOptions) + + except Exception as e: + sys.stderr.write("Failed to register command: %s\n" % + 'drc') + raise + +def uninitializePlugin(mobject): +print('uninit') \ No newline at end of file diff --git a/maya/draco_example.py b/maya/dracodec_example.py similarity index 90% rename from maya/draco_example.py rename to maya/dracodec_example.py index cd3a6ef..eb49cd0 100644 --- a/maya/draco_example.py +++ b/maya/dracodec_example.py @@ -1,4 +1,4 @@ -from draco import Draco +from dracodec_maya import Draco drc = Draco() mesh = drc.decode('bunny.drc') diff --git a/maya/draco.py b/maya/dracodec_maya.py similarity index 100% rename from maya/draco.py rename to maya/dracodec_maya.py diff --git a/maya/test_nm_quant.0.9.0.drc b/maya/test_nm_quant.0.9.0.drc new file mode 100644 index 0000000..e810c0c Binary files /dev/null and b/maya/test_nm_quant.0.9.0.drc differ