Game Development Community

Text over object???

by John Eric Miller · in Torque Game Engine · 03/30/2004 (5:46 am) · 6 replies

I am trying to design a generic class that will display text over any 3d object. I know about guiShapeNameHud.cc for displaying names over all objects. Would this be a good place to start? Has anyone else done this yet in their project? I would like to use this to display text about objects when the mouse is moved over them, kind of like a tool tip. Could this display be a hud control that the text is added to?

Also, which of guiHealthArcHud.cc or guiHealthBarHud.cc displays the health bar above the player? What calls the onRender of these control in script?

#1
03/30/2004 (11:30 am)
GuiShapeNameHud would be a good place to start.
#2
04/02/2004 (8:37 am)
Has anyone added this to their project? I am trying to determine what would be the best approach. I am looking at creating a new class similar to GuiShapeNameHud where you can assign a shape to it and some text which is then displayed over the shape. The other method is to add this functionality to shapebase where you can set a text field and that text is diapled over the shape. I would like to get other opinions on which would be preferable and why or a new way if possible. If you have implemented something like this please let me know how you did it.

Thanks!
#3
04/02/2004 (8:43 am)
You might as well go with the screen overlay method.
you can tell it is just 2dplaced text.
as opposed to 3d placed text.

but it's pretty hard to tell and most people cannot.

it is fairly simple to implement.
and you know the support is already there.
as for drawing text placed 3d you would need to go hacking.
so...

I would prolly just use the overlay method.
#4
04/02/2004 (9:01 am)
Is the overlay method what is used in GuiShapeNameHud? Overlay means I just convert the 3d coordinate to a 2d screen coordinate? Badguy, have you done anything like this?
#5
04/02/2004 (9:22 am)
Yea, and sure I have.

but not in this app.

simply take the GuiShapeNameHud and modify it till your happy :)

you can check the editor for the script reference and instantiaton.
everything you need is withing that object.
#6
04/02/2004 (9:37 am)
How would I add a pointer to the shape to use to draw the text over?

like this?
SimObjectPtr<ShapeBase> mObject;
add this to set shape pointer?
void GuiShapeTextHud::setObject(ShapeBase *obj) {
      // reset current object if not null
      if(bool(mObject)) {
         clearNotify(mObject);
      }
      mObject = obj;
      if(bool(mObject)) {         
         deleteNotify(mObject);
      }
   }
and define the text to display like this?
char *textToDisplay;
I appreciate your help my C++ is a little rusty.

Then I would just edit the onRender to not iterate through the shapes but use mObject instead?