   Draw the players name above their avatar
  Hi all,  I have a different problem now that I have no idea how to solve.I created a small example of a maze where there are some players that moves randomly in it. Now I want to draw their name upon them. Is there a known solution to this problem?Thanks in advance.[Edited by - Jardak on June 2, 2010 2:58:24 AM]
  Yes, draw text at the location of the player, with the text set to the players name.If you want a more precise answer, we'll need to know at the very least what language and graphics API you're using.   ;  Sorry for the broken english. I meant "above" not "upon".So I do not want to draw the text in the exact same position of the avatar but above it's head (and it should be tolerant to camera movements if possible).BTW I'm using Java and Lwjgl   ;  And?No idea? Well I can give you some ideas (and questions):Can you convert the world coordinates of the players to screen coordinates? This question is asked annoyingly lot here, you should able to look it up.If so, how about adding some value to the vertical screen coordinate of the model on the screen? Simply a constant value to make it look good.You could even simply draw it in world coordinates, but disable depth test.Can you render texts at all? If not, start with that. If so, can you measure their lengths in pixels? So that you can center the text horizontally.You tell us nothing. We have no idea what you tried (if tried anything at all), what do you use to draw anything, how do you render/position your text (if you do that at all).   ;  I actually haven't tried anything yet.I'm just asking if there is a pattern already used for this kind of problems. My goal was to have a high level answer with some pointers, but it seems that you prefer the details.Reading your answer (and questions) I understand that the solution would be:* Transform the world coordinates of the avatar to screen coordinates * Add a constant to the vertical axis* Draw some text at that coordinate (centering the text if necessary)Now some details about my question:Let's assume that I can switch between a "Platform view" (top) to the first person view. If I'm in first person view some avatars might be behind a wall or an obstacle and they cannot be visible. If my implementation counts on drawing the text in the orthogonal view, it might happen that the name of an avatar is shown even if it is behind a wall (am I right?). If, instead, in the perspective view I create a polygon above the head of the avatar where I write the name, making sure that the polygon always faces the camera (billboarding?) it can happen that the names of the avatar that are closer to the camera appear bigger than the other names. And that doesn't happen in most of the games. Am I right?So am I missing anything? Which is the best method?   ;  Those are some really important informations. As you mentioned "maze", I automatically visualized an isometric style game / RTS, not a FPS. And the genree is essential in case of this problem (avatar names).There are a lot of methods, and all of them have advantages and disadvantages. But the context matters here as well.For example if you already have some kind of occlusion culling /ray-shooting stuff, I would suggest to determine the visibility of the player. If it's visible, calculate the text's screen position and the other stuff.But the expected behavior is very important too: do you want the text to be partly occluded, or instead it should "pop", as soon as the player becomes invisible?If partly occluded: you could do the coordinate conversion stuff, set orthogonal projection (to mach the window resolution, I guess you know what I'm talking about), then draw the text as a textured/blended quad in the screen position with the same depth as the player's screen depth with depth test enabled. (for example you could set orthogonal projection with near=0.0, far=1.0, so simply draw the text in (screen_x,screen_y,screen_z). Obviously after drawing the scene and without clearing the depth-buffer).You could do occlusion queries (google that, I won't attempt to explain it), so you could determine if the player is occluded or not.See, there are different methods, I don't think there is a general and best solution to the problem. Do whatever is simple/efficient/fast for you.   ;  Thanks a lot for the answer. That is exactly was I was looking for.;Quote:Original post by JardakThanks a lot for the answer. That is exactly was I was looking for.By "exactly" you mean this?Quote:If partly occluded: you could do the coordinate conversion stuff, set orthogonal projection (to mach the window resolution, I guess you know what I'm talking about), then draw the text as a textured/blended quad in the screen position with the same depth as the player's screen depth with depth test enabled. (for example you could set orthogonal projection with near=0.0, far=1.0, so simply draw the text in (screen_x,screen_y,screen_z). Obviously after drawing the scene and without clearing the depth-buffer).This is not a very good solution as I think about it: the text may be occluded while the player is not (for example it's standing outside a small door, so it is visible, but the text would be not). This is very annoying, so I don't suggest that solution.Use the ray-shooting or occlusion test instead. Or wait a bit for better ideas.   