PDA

View Full Version : Maya API: view.drawText in 'projection' mode?


Azrail
11-04-2010, 07:25 PM
Hi there, for a week or so I'm trying to dive into the API, and got stuck struggling with the glFunctionTable stuff. I've no previous knowledge in openGL and still find it hard to understand some things in it's rendering methods....

Anyway, up to the point:
I have a simple custom locator derived from an MPxLocator and in its draw function I want to display few lines of text. I'm using the view.drawText() function, and because I couldn't find a way to make a newline I did it with a loop trough the text lines and separate drawText calls for every line with some offset:

Here is the code, it's Python but that doesn't matter, C++ source would also be of help:

txtSrc = ("Line1\n Line2\n Line3\n Line4\n etc..")
txtLines = txtSrc.split('\n')
drawView.beginGL()
textLineSpace = .2
line = 0
for txtLine in txtLines:
linePos = OpenMaya.MPoint(textSrcPos[0], textSrcPos[1] + textLineSpace*line, textSrcPos[2])
drawView.drawText(txtLine, linePos, OpenMayaUI.M3dView.kCenter)
line += 1
drawView.endGL()


Now - the drawback is that my lines get shrunk or stretched when I zoom in the viewport. The one idea I've is to measure the distance between the camera and the locator and use that as a multiplier of the textLineSpace value, but I bet there is some smarter way you can draw a multiline text. I also succeeded in converting my textSrcPosfrom world to view coordinates , but couldn't make OpenGL draw it there :hmm:

Any help would be greatly appreciated, and please post full code, I mean with all push/pops of OpenGL, because it still is a mystery for me :)

CGTalk Moderation
11-04-2010, 07:25 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.