Name above player's heads

Started by
2 comments, last by yckx 17 years, 2 months ago
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. ;)
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.
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
Ring3 Circus - Diary of a programmer, journal of a hacker.
AngelCode's Bitmap Font Generator should prove useful if you follow Crimson Sun's advice to use bitmap fonts, which I recommend.

This topic is closed to new replies.

Advertisement