ShapeName Fade
by Howard Dortch · in Torque Game Engine · 02/06/2005 (6:58 am) · 6 replies
I searched the forums for this and I know I ran across it someplace but can't find it now.
I want to fade out the names of players over a distance. I tried all kinds of settings and no fade.
The engine code looks like it does the alpha part but I guess I have the wrong numbers in.
1.0 - (shapeDist - fadeDistance) / (visDistance - fadeDistance);
shapeDist = 300;
fadeDist = 200;
visDistance = 500;
fadeDist = 200;
1.0 - (300 - 200) / (500 - 200) = 0.66 alpha or there abouts ?
It doesn't seem to fade at all no matter the numbers.
Anyone got this to work?
I want to fade out the names of players over a distance. I tried all kinds of settings and no fade.
The engine code looks like it does the alpha part but I guess I have the wrong numbers in.
1.0 - (shapeDist - fadeDistance) / (visDistance - fadeDistance);
shapeDist = 300;
fadeDist = 200;
visDistance = 500;
fadeDist = 200;
1.0 - (300 - 200) / (500 - 200) = 0.66 alpha or there abouts ?
It doesn't seem to fade at all no matter the numbers.
Anyone got this to work?
#2
distanceFade is in the gui and the opacity value passed to drawName in the engine is calculated from the formula on my first post.
It might be an openGL thing alpha not set somewhere.
02/07/2005 (1:04 pm)
Yeah I have played with values in the gui and the engine code and it doesn't seem to work.distanceFade is in the gui and the opacity value passed to drawName in the engine is calculated from the formula on my first post.
It might be an openGL thing alpha not set somewhere.
#4
12/03/2005 (2:29 pm)
I would try to use hard coded values, just to test. So do something like:void GuiShapeNameHud::drawName(Point2I offset, const char *name, F32 opacity)
{
// Center the name
offset.x -= mProfile->mFont->getStrWidth(name) / 2;
offset.y -= mProfile->mFont->getHeight();
// Set alpha values
F32 customAlpha = 0.10;
// Deal with opacity and draw.
mTextColor.alpha = customAlpha; If you've already tried something like that, then I'm not sure when it wouldn't work...hope you can get it. If you do manage to get it, be sure to share it with the rest of us :)
#5
Added a MaxVisibleDistance instead of using the visibility distans that is used default in the calculation. It works but everything could be better :)
Give me a mail adress Howard then i send it to you , if you like it then you can add the code here if you want .
12/03/2005 (5:24 pm)
I did somekind of code simular how the audiofalloff works.Added a MaxVisibleDistance instead of using the visibility distans that is used default in the calculation. It works but everything could be better :)
Give me a mail adress Howard then i send it to you , if you like it then you can add the code here if you want .
#6
12/04/2005 (7:01 am)
Ok I just changed the way it does the calculation and added a field for near distance and far distance so the user could set the range in an options dialog. Some players dont like the names showing at all and some like close range for names and fade fast so this all works fine now, thanks.
Torque Owner Ricardo Cabral
i also found this function in guiShapeNameHud.cc, which seems to be responsible for the name rendering. maybe the alpha variable you need to change is this one.
hope this helps.
void GuiShapeNameHud::drawName(Point2I offset, const char *name, F32 opacity)
{
// Center the name
offset.x -= mProfile->mFont->getStrWidth(name) / 2;
offset.y -= mProfile->mFont->getHeight();
// Deal with opacity and draw.
mTextColor.alpha = opacity;