X-Ray OpenGL shapes in Maya API

223 views
Skip to first unread message

Dilen Shah

unread,
Jan 17, 2014, 3:08:42 AM1/17/14
to python_in...@googlegroups.com
Hey guy,

I am creating a MPxLocatorNode and need it to be seen on top of all object in any viewport at all time.

How can I accomplish this?

D.

Jack Straw

unread,
Jan 17, 2014, 7:35:17 AM1/17/14
to python_in...@googlegroups.com
As it is a full OpenGL viewport you can just use standard OpenGL methods for rendering on top. From a quick google it looks like glClear(GL_DEPTH_BUFFER_BIT) is the best option. I have done this before but I cannot remember the exact command I used that time.

Jack

Janos Hunyadi

unread,
Jan 19, 2014, 10:25:04 PM1/19/14
to python_in...@googlegroups.com
You can even try glPolygonOffset. Not sure if it works inside maya, but in OpenGL that's the way to do it.

Dilen Shah

unread,
Jan 20, 2014, 4:41:54 AM1/20/14
to python_in...@googlegroups.com
will try it out and let you know if i was successful.

D.

Dilen Shah

unread,
Jan 20, 2014, 4:42:03 AM1/20/14
to python_in...@googlegroups.com
will try it out and let you know if i was successful.

D.

Dilen Shah

unread,
Jan 20, 2014, 8:05:23 AM1/20/14
to python_in...@googlegroups.com

Hey Jack,

I am trying to use that but in python as I am using the OpenMayaRender module for it but glClear(GL_DEPTH_BUFFER_BIT) isnt in the attirbutes of it. Do you know which module is it from.

D.

Jack Straw

unread,
Jan 20, 2014, 11:15:18 AM1/20/14
to python_in...@googlegroups.com
You need to call them from the OpenGL function table. Here is an example; http://www.fevrierdorian.com/blog/post/2010/02/12/Creating-custom-locator-with-Maya-s-Python-API 

Dilen Shah

unread,
Jan 20, 2014, 11:17:24 AM1/20/14
to python_in...@googlegroups.com
I am calling them this is my test code:

import maya.OpenMayaRender as OpenMayaRender
view.beginGL()

# Pushed current state
glFT.glPushAttrib(OpenMayaRender.MGL_CURRENT_BIT)
# Enabled Blend mode (to enable transparency)
glFT.glEnable(OpenMayaRender.MGL_BLEND)

glFT.glClear(OpenMayaRender.GL_DEPTH_BUFFER_BIT) here is get the error OpenMayaRender doesnt have attribute


D.

Jack Straw

unread,
Jan 20, 2014, 1:04:48 PM1/20/14
to python_in...@googlegroups.com
"The naming convention used in this file is to take the regular GL* definitions and add a "M" prefix." - Maya Python API Docs

Try OpenMayaRender.MGL_DEPTH_BUFFER_BIT.

Dilen Shah

unread,
Jan 21, 2014, 8:22:43 AM1/21/14
to python_in...@googlegroups.com
you are the man! it worked had to do some changes here and there but got it working.

thnx!

Dilen Shah

unread,
Jan 23, 2014, 9:25:18 AM1/23/14
to python_in...@googlegroups.com
Also found another way of doing this.

glFT.glDisable( OpenMayaRender.MGL_DEPTH_TEST )
...
...
your code and your opengl shape

glFT.glEnable( OpenMayaRender.MGL_DEPTH_TEST )

So two ways of doing this, this one makes to stop it after drawing, so might be better but i am nt sure.

D.
Reply all
Reply to author
Forward
0 new messages