About Store Forum Documentation Contact



Post Reply 
Display Character name
Author Message
Rofar Offline
Member

Post: #1
Display Character name
Has anyone implemented displaying a character name above a characters head? I'm starting to look into how to do this and figured I would see if anyone has done this and if I could get any tips.
02-20-2010 04:47 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #2
RE: Display Character name
In draw game:
Code:
REPA(Characters)
{
    Vec2   screen=PosToScreen(Characters[i].pos()+Vec(0,1.15,0));
    D.text(screen,"Character");
02-20-2010 04:50 PM
Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #3
RE: Display Character name
Thanks Chris. Actually that is the "simplified" way to do it but doesn't take into account whether or not the character is in the players view so will display the text on the screen even if the camera is facing away from the character. Also, this is just drawing text over everything rendered in the screen which means that it doesn't get clipped by scene objects. The name really needs to be displayed as if it's part of the 3D scene and his hidden by objects and only drawn if in the camera frustum, etc.
(This post was last modified: 02-20-2010 06:03 PM by Rofar.)
02-20-2010 05:37 PM
Find all posts by this user Quote this message in a reply
Masterxilo Offline
Member

Post: #4
RE: Display Character name
Maybe you can render the name to a texture and apply that to a billboard which is always placed over the player's head. I'm not sure how to do any of this though.

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
02-20-2010 06:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #5
RE: Display Character name
Yes, I was thinking along those lines too. I did manage to include frustum culling for the simplified method so now the text is only displayed if the character is in view but the problem of drawing over the scene will still be an issue with that method.
02-20-2010 06:17 PM
Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #6
RE: Display Character name
I think I have something that works out ok by just scaling the text based on distance from camera, having a max distance where it is drawn, and only drawing if the character mesh is in the frustum.
02-22-2010 01:14 AM
Find all posts by this user Quote this message in a reply
Masterxilo Offline
Member

Post: #7
RE: Display Character name
To hide it if it's behind another object (to avoid drawing over the scene), you could additionally perform a raycast to the camera.

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
02-22-2010 11:21 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #8
RE: Display Character name
Yes, I am working on that aspect now. It is kind of working for me but I have to do some debugging because it's not exactly right yet. One thing I haven't figured out yet is how to exclude the Player Character from the Ray test. Since the camera is at the player, the Ray intersects the player unless I force the origin of the ray to be slightly forward of the player.
02-22-2010 11:55 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Display Character name
you can set the player capsule to a specific actor group and then exclude it in the bit field of Physics.ray

or you can specify callback function for the method, inside function skip actors whose Actor::obj points to your player object.
02-23-2010 04:31 PM
Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #10
RE: Display Character name
Using a callback function works. Thanks for the idea.
02-24-2010 12:56 AM
Find all posts by this user Quote this message in a reply
Post Reply