Jump to content

  • Log In with Google      Sign In   
  • Create Account

Bounding rectangle for a font sprite from objectspace using measurestring


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Monza   Members   -  Reputation: 140

Like
0Likes
Like

Posted 20 March 2013 - 07:31 AM

Trying to get the rendered bounding rectangle from a font sprite set to render into objectspace (not screen space) coordinates.

 

But the d3d9Font.measurestring(sprite .......    only gives the non objectspace rectangle even through the sprite is defined to render in objectspace.

 

So basically, even though the font is rendered into the 3D scene correctly at the correct depth and perspective based size (eg the same sized font may range from a few to 500 pixels of more depending on depth), I cannot get this size rectangle, because the measurestring only returns a fixed size (eg 250 x 100) regardless of rendered depth as if it was rendered directly to screen with objectspace not set (ie in transformed coordinates)

 

Do I need to use the defined sprite transformation matrix in another calculation or am I missing something?   Is there another way to compute the final text rendered screen size?

 



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5086

Like
0Likes
Like

Posted 20 March 2013 - 07:48 PM

Is the returned size just being used in your object space?  If so, perhaps the returned size is in pixels (which is normal for sprite based text rendering) and that is the same size regardless of how far away the sprite actually is from your camera.

 

I'm not familiar with the interface you are using, but try to experiment with it and see if the size returned only varies according to the number of characters when it is a fixed width font (like Consolas).  Then do the same test, but use a larger font size.  If the size is proportional to the number of characters, and is also proportional to the font size, then I bet the returned value is in pixels... 

 

In that case you just have to scale them according to how large you want the text to appear in your scene.



#3 Monza   Members   -  Reputation: 140

Like
0Likes
Like

Posted 20 March 2013 - 07:59 PM

I'm sure the 'measurestring' returned rectangle is the size of the string if it was rendered to the screen without scaling or transformation.  It appears to be based on the size and number of lines of the rendered font.  Which would be fine if I was sending it to the screen without transformation.

 

But the sprite is set to 'objectspace' which transforms and renders it into the scene at a completely different size.  This is the size I need (so I can calculate how to draw a bounding box around the text).

 

Maybe I can 'project' the font sprite bounding box coordinates into the scene to work out the size?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS