I'm trying to create a custom locator node using the Maya Python API. Originally I started using glBegin()/glEnd() in the overloaded draw() method for my locator, but there was a soft limit to how many locators that can be in the scene before Maya starts becoming less responsive. I tried to optimize the code by switching to glDrawArrays() or glDrawElements(), but I cannot get it to work. Here is my code for my draw() method:
class myNode(OpenMayaMPx.MPxLocatorNode):
def __init__(self):
OpenMayaMPx.MPxLocatorNode.__init__(self)
def draw(self, view, path, style, status):
view.beginGL()
vertList = [0.0,0.0,0.0, 300.0,0.0,0.0, 0.0,300.0,0.0]
vertCount = len(vertList)/3
vertListMSU = OpenMaya.MScriptUtil()
vertListMSU.createFromList(vertList, len(vertList))
#this doesn't work
glFT.glPushClientAttrib(OpenMayaRender.MGL_CLIENT_VERTEX_ARRAY_BIT)
glFT.glVertexPointer(3, OpenMayaRender.MGL_FLOAT, 0, vertListMSU.asFloatPtr())
glFT.glEnableClientState(OpenMayaRender.MGL_VERTEX_ARRAY)
glFT.glDrawArrays(OpenMayaRender.MGL_TRIANGLES, 0, vertCount)
glFT.glPopClientAttrib()
#this does work
#glFT.glBegin(OpenMayaRender.MGL_TRIANGLES)
#glFT.glVertex3f(vertList[0],vertList[1],vertList[2])
#glFT.glVertex3f(vertList[3],vertList[4],vertList[5])
#glFT.glVertex3f(vertList[6],vertList[7],vertList[8])
#glFT.glEnd()
view.endGL()
Any ideas why the glDrawArrays() code doesn't work? I can't find anything in the documentation or on the internet of anyone else trying to do this.
FYI, one of our technical artists does most of our Maya scripting and he is primarily fluent in Python, which is why we're not writing this plugin in C++.
Solved! Go to Solution.
Solved by DouglasLauritsen. Go to Solution.
You will want to ask this on the Maya Forum in the Discussion Groups at the Area.