OpenGL maya api python in Maya 2015 Viewport 2.0

1,388 views
Skip to first unread message

Dilen Shah

unread,
Jan 15, 2015, 5:29:41 AM1/15/15
to python_in...@googlegroups.com
Hey guys,

So I have written many nodes with open gl draw functions for Maya 2014.

For Maya 2015, I was reading the footPrintNode.cpp file in the devkit of maya 2015 folder and I found that there is a Viewport 2.0 Implementation override and it has a set of classes and functions and also added lines in the initialize plugin function.

So my question is, I went though the scripted footPrintNode.py in Maya 2015 and there is no Viewport 2.0 implementation, so can anyone tell me what I need to do for it. Do I need to add it by translating c++ to python for all my gl shapes in Maya 2015?

Thank you and let me know if you dont understand my question would like to solve this problem.

D.

Janos Hunyadi

unread,
Jan 15, 2015, 8:21:12 AM1/15/15
to python_in...@googlegroups.com
Only works in C++ at the moment to my knowledge. You need to take the basic MPxLocatorNode and add an MPxDrawOverride to make it work it in VP 2.0.
You don't need to use the legacy draw method. Just use the overrides addUIDrawables() function and do your drawing there, after you prepared your data for caching in the prepareForDraw() function.

J

Dilen Shah

unread,
Jan 16, 2015, 3:47:30 AM1/16/15
to python_in...@googlegroups.com
Hey Janos,

Thanks for the reply,

So I need the functions class MPxDrawOverride and the following functions right:
1. prepareForDraw()
2. addUIDrawables

Thats it right, I still dont have a 2015 version so just preparing my scripts before I get it.

Let me know.

D. 

Janos Hunyadi

unread,
Jan 16, 2015, 2:50:35 PM1/16/15
to python_in...@googlegroups.com
There are a bunch more functions you can use with the overrides, but those two are that does the heavy lifting

Dilen Shah

unread,
Jan 19, 2015, 11:59:48 AM1/19/15
to python_in...@googlegroups.com
thanks for the reply. I got it.

Just waiting for some python support i hope :)

D.

jose....@gmail.com

unread,
Jul 19, 2015, 7:27:13 AM7/19/15
to python_in...@googlegroups.com
Hi guys,

I know that it's been a while since this post was created, but I found it looking in internet for some solution about this in python.

I can't believe that I couldnt find any example yet about this in python. Even I was checking Python API 2.0 just to check if there was something new that makes this works.

I made a simle MPxLocator that draws a simple line. That's all. I'm not drawing geometry or creating any specific shader. Just this:


def draw(self, view, path, style, status):
view.beginGL()
glFT.glBegin(OpenMayaRender.MGL_LINES)
glFT.glVertex3f(self.outX,
self.outY,
self.outZ)
glFT.glVertex3f(self.targetPosX,
self.targetPosY,
self.targetPosZ)
glFT.glEnd()
view.endGL()


So, my question is:

does anyone know if the implementation of the override functions is already possible in python? If it's so, it'd be really helpful some example.

Thanks!

Janos Hunyadi

unread,
Jul 20, 2015, 5:31:01 PM7/20/15
to python_in...@googlegroups.com, jose....@gmail.com
I think you're just better off coding it in C++ :D. Especially locators, much faster, but other than that, I noticed that for VP2.0 override (at least for c++) you have to have the draw function for VP1.0 implemented too otherwise you cannot select the locator (even though one of to new API changes in Maya 2016 is the selection handling in VP2.0)

For drawing in VP2.0 I don't use the legacy draw method any more. Just the  MHWRender::MUIDrawManager in the override

J

jose....@gmail.com

unread,
Jul 20, 2015, 6:07:36 PM7/20/15
to python_in...@googlegroups.com
Hi Janos,

You're right. I'll do it in C++. I was working in python because I was just developing the idea, and it's way faster to debug un python. But as the idea was always to convert it into C++, I'll fix that later.

Thanks for the tip.

:)
Reply all
Reply to author
Forward
0 new messages