Jump to content
  • Advertisement
Sign in to follow this  
REspawn

3D Text, in a similar way to DrawTransform for a line

This topic is 4158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, im wondering if anyone has ever seen or knows if its possible to draw flat text in 3d space, kinda like a billboard only without it having to be a texture. Best example i can think of it the 3d line function drawtransform, and a visual example of what im trying to get would be metal gear solid's style of drawing the name of objects like below... thanks for any help, -Dave

Share this post


Link to post
Share on other sites
Advertisement
What language are you using? Are you using ID3DXFont? If not, then it's just a case of drawing bilboarded quads, or scaled quads using an orthogonal projection matrix.

Share this post


Link to post
Share on other sites
Since you most likely want to draw the text "5 pixels above an object" and not "2 world units above an object", it would make sense to do the drawing in screen-space after all.

What I do with things like this is get the position of the object I want to draw the text next to, offset by the amount I want (say, 5 pixels above the top of the bounding box) and then draw it at that screen position. This also allows me to handle cases where an object is too close to the top of the screen for the text to fit.

Hope this helps ;)

Share this post


Link to post
Share on other sites
Im using c++ and im not using anything at the moment, im just looking into how i would go about creating the desired effect, cheers for the replys

Share this post


Link to post
Share on other sites
Quote:
Original post by REspawn only without it having to be a texture.
What does this mean?? The screenshot you give shows an effect that would most certainly be created using at least one 'texture'...

Share this post


Link to post
Share on other sites
Quote:
Original post by MasterWorks
Quote:
Original post by REspawn only without it having to be a texture.
What does this mean?? The screenshot you give shows an effect that would most certainly be created using at least one 'texture'...


If you read it in context with the rest of the post you will see I make refrence to the DrawTransform function of a line and how it can be drawn without the need for a texture.

So to make it a bit clearer what it means is: Is it possible to draw text in 3D like in the screenshot without having to resort to using a texture.

Share this post


Link to post
Share on other sites
This is my 3d space text drawing code (it's pretty simple):

void d3drenderer::rendertext3d(const std::wstring& text, const D3DXVECTOR3& p, unsigned long colour)
{
D3DVIEWPORT9 vp;
vp.X = 0;
vp.Y = 0;
vp.Width = width_;
vp.Height = height_;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;

D3DXVECTOR3 textposition2d;

D3DXMATRIX w;
D3DXMatrixIdentity(&w);

D3DXVec3Project(&textposition2d, &p, &vp, &cache_proj, &cache_view, &w);

RECT rc;
rc.left = static_cast<long>(textposition2d.x);
rc.top = static_cast<long>(textposition2d.y);
rc.bottom = height_;
rc.right = width_;
font->DrawTextW( NULL, text.c_str(), -1, &rc, DT_NOCLIP, colour);
}


Where font is an ID3DXFont*. Hope it helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!