PDA

View Full Version : Help with openGL and Maya...



ricoBaby
11-03-2011, 08:44 AM
http://img.photobucket.com/albums/v72/balbas/openGL_fail.jpg

Hello, experts.

I am new to openGL coding and I am a technical artist using Maya and 3dsMAX, this is my first time to venture into openGL coding after about 12 years into my career.

I am coding with Python and I am making special locators for Maya using Maya's Python API with openGL.

The above picture shows a problem with transparency. The red cubes are the locators that I made using openGL.

Please read this:
1. the cone was created before the red cubes/locators.

2. the sphere and the grey cube was created after the red cubes/locators.

as you can see, it is not showing the lines when intersected with the red cubes/locators.

Below is basically my draw codes. I hope that it is not confusing.

################################################## #########

view.beginGL()

glFT.glPushAttrib(OpenMayaRender.MGL_CURRENT_BIT)
glFT.glPushAttrib(OpenMayaRender.MGL_ALL_ATTRIB_BI TS)

glFT.glEnable(OpenMayaRender.MGL_BLEND)
glFT.glBlendFunc (OpenMayaRender.MGL_SRC_ALPHA, OpenMayaRender.MGL_ONE_MINUS_SRC_ALPHA)

#These are Maya specific status codes#
if status == OpenMayaUI.M3dView.kDormant:
glFT.glColor4f(color_RVal,color_GVal,color_BVal, 0.3)

if status == OpenMayaUI.M3dView.kLead:
glFT.glColor4f(0.0+color_RVal+.0,0.0+color_GVal+.0 ,0.0+color_BVal+.0, 0.4)

if status == OpenMayaUI.M3dView.kActive:
glFT.glColor4f(0.0+color_RVal+.3,0.0+color_GVal+.3 ,0.0+color_BVal+.3, 0.5)

#some openGL primitive codes are inserted here#

glFT.glLineWidth(widthVal)

glFT.glDisable(OpenMayaRender.MGL_BLEND)

glFT.glPopAttrib()
glFT.glPopAttrib()

view.endGL()

################################################## #########

Thank you very much, I am trying to solve this on my own without any success. I hope that somebody more experienced in this can help me through. Rick

overlay
11-03-2011, 11:07 AM
You have to draw your transparent polygons back-to-front by first sorting them according to the camera transform.

ricoBaby
11-03-2011, 11:15 PM
Hello, kind sir.

Thank you very much for replying. I am not a trained programmer so I may not comprehend what you are saying instantly, please bear with me.

Is there a draw method or code that I need to look into?

This only happens when the RED OBJECTS are dormant and are not selected or active, once they are selected or active, it works as intended.

Thank you again, I am hoping that I can make fancier openGL stuff next time. This just a step into a part of my career that I always tried to avoid. Rick

ZbuffeR
11-04-2011, 12:34 AM
If the problem is only regarding the wireframes, make sure you draw your red locator last, after everything else.