Jump to content

Drawing text in the viewport


Zero

Recommended Posts

I'm writing a render hook that is supposed to draw some geometry (lines) and some text in the viewport.

I am using RE_OGLRender::textMove3W() to get to the correct position in 3D space, where I want my text to appear, and then RE_Render::putString() to draw a string. This works fine.

I am having two issues though, which I cannot figure out, so if anyone with experience with this could shed some light on the situation, that would be much appreciated.

Houdini version is 11.0.535 and I am stuck with this version for production.

ISSUE #1: RE_Render::putMultiLineString()

This does not work. It draws the first line correctly, but all other lines do not appear. I have resorted to converting the string into an UT_String, tokenising it to split out the different lines into a UT_WorkArgs object, and then looping over the items and passing each line to a separate call to RE_Render::putString(), while using RE_OGLRender::setViewportFontOffset() to offset the separate lines, so they appear underneath each other (RE_Font::getHeight() gives me the amount of pixels to use for the offset).

Additionally, I found that before drawing each line, I have to call RE_OGLRender::textMove3W() again, even though the coordinates do not change. If I omit that, again, only the first line of text appears (I suspect the rest of the lines are drawn at completely different positions in space). Why do I need to call textMove3W() each time, and why does putMultiLineString() only draw the first line?

ISSUE #2: Flying point numbers

While testing variable expansion in the string I was using to display in my custom render hook, I found that, when I move my geometry such that some of its points are not in view anymore, and at the same time point number display is turned on, the text of these points starts flying over the viewport in the opposite direction.

For example: I move the geometry towards the left edge of the screen. The moment the first point goes off screen, its number starts flying towards the right, at a higher speed than I am panning the point, until it goes off screen to the right.

At first I thought I was doing something wrong with the drawing instructions in my code, so I started commenting out various sections of my code in an attempt to find the offender. This resulted in me eventually commenting out my entire code, resulting in empty GR_RenderHook::renderWire() and RE_RenderHook::renderShaded() implementations, and yet the problem still occurs. So it seems I am missing to do something important rather than doing something I should not, but what is it?

As I said: any help would be much appreciated. Thanks.

Link to comment
Share on other sites

I received an email from SideFX' Mark Alexander explaining what is going on:

ISSUE #1:

putMultiLineString() is only good for drawing text in a 2D context, as it calls textMove2DS() for subsequent lines. If you use it in the 3D viewport, the lines will appear at (x,y,0), and be culled because they're behind the near clip plane. So you'll have to use multiple putString()'s in that context.

ISSUE #2

This is a general issue with bitmapped fonts in the viewport. I don't see a fix coming for it, as they are being replaced in the next major version of Houdini.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...