Installation & Licensing
Welcome to Autodesk’s Installation and Licensing Forums. Share your knowledge, ask questions, and explore popular Download, Installation, and Licensing topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maya Python API can't do glDrawArrays() in custom locator

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ryanloewen
850 Views, 2 Replies

Maya Python API can't do glDrawArrays() in custom locator

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++.

2 REPLIES 2
Message 2 of 3

You will want to ask this on the Maya Forum in the Discussion Groups at the Area.



Douglas Lauritsen
Support Specialist
Product Support
Autodesk, Inc.

Message 3 of 3

Oh wow. I was sure that's where I posted. Wonder how I managed that.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Administrator Productivity


Autodesk Design & Make Report