How to render text in world space just like the text above people's head in the game

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

Recommended Posts

How to render text in world space just like the text above people's head in the game of world of warcraft? is it just same like "Render to Surface" to create a texture with text ,then map on a quad? or there is another efficiency way? thank's a lot!

Share on other sites
you could transform the point above the characters head to screenspace(project it) and use that coord to draw a usual 2D-Text there.

Share on other sites
you could write your text to a surface and use that in a texture on a screen aligned quad...?

havent done it myself but its possible

Share on other sites
Quote:
 you could transform the point above the characters head to screenspace(project it) and use that coord to draw a usual 2D-Text there.

This seems like the best way to go, as long as you don't care if the text doesn't interact correctly with geometry (ie., if a character walks behind a wall and you can no longer see him, you will still see text above his head - but this could be solved by determining first if the character is unobscured.)

I do pretty much the same thing in my own game, printing text above entities such as each entity's ID number, or whatever. What I do is use a GetScreenPoint() function which takes a point in 3d space and returns a point in screenspace. I get the screen position of my entity and then call my print function to output text at (returned_position.x-xoffset,returned_position.y-yoffset).

Of course, this may or may not work depending on what you mean by having text "above" a character's head. Does "above" mean above along the y axis on the screen or on the y axis in the world? (Those two may be more or less the same thing, depending on where your camera is.) If the latter, you would probably want to tweak the values of xoffset and yoffset per camera orientation so that they always print text in the right direction away from your character.

Here's my GetScreenPoint function, for reference:

D3DXVECTOR2 GetPoint(D3DXVECTOR3 point, const D3DXMATRIX* mscreen_pnt){	//return the screen point of a point in 3dimensions	D3DXVECTOR3 v1;	D3DXVECTOR2 screenpoint;	D3DXVec3TransformCoord(&v1, &point, mscreen_pnt);	v1.x=((v1.x+1.0f)/2.0f);	v1.y=((v1.y+1.0f)/2.0f);	screenpoint.x=v1.x*800;	screenpoint.y=600-v1.y*600;	return screenpoint;}

where mscreen_pnt is defined elsewhere thus:
D3DXMATRIX mscreen_pnt;D3DXMATRIX m_view;D3DXMATRIX m_world;D3DXMATRIX m_proj;d3ddevice->GetTransform(D3DTS_VIEW,&m_view);d3ddevice->GetTransform(D3DTS_WORLD, &m_world);d3ddevice->GetTransform(D3DTS_PROJECTION, &m_proj);m_screen_pnt=m_world*m_view*m_proj;

Share on other sites
thank your!!!!!!!!!!!!!!!I'll try now!