50 import maya.OpenMaya
as OpenMaya
51 import maya.OpenMayaMPx
as OpenMayaMPx
53 kMaterialName =
"solidMaterialInfo"
54 kTextureName =
"solidTextureInfo"
56 class SolidMaterialInfo(OpenMayaMPx.MPxMaterialInformation):
57 def __init__(self, node):
58 OpenMayaMPx.MPxMaterialInformation.__init__(self, node)
61 def materialInfoIsDirty(self, plug):
65 def connectAsTexture(self, plug):
69 def textureDisconnected(self, plug):
73 def computeMaterial(self, data):
78 class SolidTextureInfo(OpenMayaMPx.MPxBakeEngine):
80 print(
"text __init__")
81 OpenMayaMPx.MPxBakeEngine.__init__(self)
84 def bake(self, objectPath, cameraPath, samplePlug, bakeResult):
92 print(
"matCreator()\n")
93 return OpenMayaMPx.asMPxPtr(SolidMaterialInfo(node))
97 print(
"textCreator()\n")
98 return OpenMayaMPx.asMPxPtr(SolidTextureInfo())
101 def initializePlugin(mobject):
102 print(
"initializePlugin()\n")
103 mplugin = OpenMayaMPx.MFnPlugin(mobject,
"Autodesk",
"1.0",
"Any")
105 mplugin.registerMaterialInfo(kMaterialName, matCreator)
107 sys.stderr.write(
"Failed to register material info: %s\n" % kMaterialName)
111 mplugin.registerBakeEngine(kTextureName, textCreator)
113 sys.stderr.write(
"Failed to register material info: %s\n" % kTextureName)
117 def uninitializePlugin(mobject):
118 print(
"uninitializePlugin()\n")
119 mplugin = OpenMayaMPx.MFnPlugin(mobject)
121 mplugin.unregisterMaterialInfo(kMaterialName)
123 sys.stderr.write(
"Failed to unregister material info: %s\n" % kMaterialName)
127 mplugin.unregisterBakeEngine(kTextureName)
129 sys.stderr.write(
"Failed to unregister material info: %s\n" % kTextureName)