Sign in to follow this  
Crazyfool

Writing text in Dx9(c++) round 2

Recommended Posts

Howdy, my previous post got drawn out and probably confused potential helpers, so after letting it fall out of scope, I am trying again. Basically, I would like to write text in 3d coordinates (which is how I draw my tiles, characters, etc). Currently, I can only write text based off of screen coordinates. Meaning, if I wanted to write text to hover above someones head for instance, I would find that persons location, then draw text there, but add a slight offset to make it appear over the characters head. What I have tried: drawing it to a sprite and than translating the sprite to the desired coordinates (how I do it with textures using d3ddevice) which does not work, it translates it to the screen coordinates. So if a player is at 11,11, it would end up writing the text at the top left of the screen, barely off the corner. My question to you is - so how do I do this? Previous suggestions: billboarding (the only stuff I found, including Microsofts example, has to do with using a 2d texture to mimic 3d by having the quad always facing the camera) which I believe meant drawing the text onto the sprite - which I've tried. All help is appreciated, thanks a bunch.

Share this post


Link to post
Share on other sites
Do you want the text to be true 3D? That is, do you want it to have depth/perspective?

If not, you just have to find the screen coordinates of the location to draw the text (in your example, of the character's head) and draw the text there. D3DXVec3Project() can help you with this.

Share this post


Link to post
Share on other sites
Ah, thank you, that potentially be helpful.

The true 3d aspect im not so interested in, as I was also suggested something about creating texts out of meshes (I wanted to avoid that if possible).

I think this may help me, thanks. I'll report back my findings.

Share this post


Link to post
Share on other sites
If you want the text to always face the camera and scale with distance (ala names over a players head in an MMO) then you might want to look into billboarding, which would let you place a texture wherever and have it always face the camera.

As to how to put the text there...hmm I've never tried that before. I guess you could render the text to a buffer somewhere then use that buffer as the texture for your billboard, though that might be more work than is needed.

Share this post


Link to post
Share on other sites
text seems to always face the camera from what I've noticed.

D3DXVec3Project seems to work for me, but I am a bit confused.

It takes a source vector, is that the difference from where the camera is looking? I.e., if the camera is looking at 47,21, then then the source vector of 1,0, would have the screen coords at 48,21? It seems to work this way for me, as a source of 0,0 is at the center of the screen, and altering the source by 1 seems to essentially shift the numbers over just a bit.

Edit: it seems to be off a bit for the vertical aspect.

When I have the source being a difference in x, the mouse.x value is accurate, but the mouse.y seems to be off quit a bit.. My camera is at an angle, so does that affect anything or should the D3DXVec3Project function accommodate that already?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this