Jump to content
  • Advertisement
Sign in to follow this  
Shaflugi

Name above player's heads

This topic is 4307 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

To start with, sorry if this is in the wrong forum, there are so many. @_@ I'm working in an ancient Doom sourceport (Doom Legacy), and I was trying to think of a way to display player names above their heads. I was thinking I could just map their name to a texture and put it on a rectangle above their head, but how would I go about doing that? I'm using OpenGL, if it helps. Thanks in advance. ;)

Share this post


Link to post
Share on other sites
Advertisement
You could make a texture for each entities name and display it in a textured quad above the entities head. However, this is rather restrictive. I would suggest you implement texture-mapped fonts. You create a texture with all the alphabet's characters inside (maybe even some extended characters) and access the portion of the texture you need to display each character. That way you can load a string into the displaying function and process each component of the string giving you the entire word/phrase you want displayed. This could also be used to create a HUD for your game.

As for displaying the fonts above enemies heads, you display the character-textured polygons along the line parallel to the crossproduct of your camera's view vector and your camera's "up" vector.

This method is great because the font appears scaled based upon how far away it is, and if used on static objects, such as lettering on a sign, the text won't necessarily be perpendicular to the camera, and the color of the text can be changed by changing the color of the polygon the text is mapped to.

Share this post


Link to post
Share on other sites
If you want the name scaled with distance, as an object in 3D space, then you should place the quad as a billboard above the player's head.

If you'd rather the name stayed uniform in size, then you should unproject the position of the player onto screen space and render the quad as a set of transformed vertices.

Techniques to research are 'billboarding' and 'unprojecting' (though you may want to search for 'picking' in the latter case).

Admiral

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!