About Store Forum Documentation Contact



Post Reply 
Billboard with text?
Author Message
ronghester Offline
Member

Post: #1
Billboard with text?
Hi,

What is the best way to draw text with rectangle background ? So my requirement is draw a white color text on grey color rectangle, rectangle width and height should be proportionate to the text.

Is there any way to do that. I don;t want to use GUI objects, i can use images.

Please let me know.

Thanks
05-09-2018 05:08 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: Billboard with text?
at the top of my head I can think of if you want it to be handled in 3D.
VI with images for each letter or VI with actual geometry for each letter.
VI with render to texture by rendering the text to a texture.(could be done real-time based on changes or precomputed)
VI and use D.text with postoscreen(don't know how unwielding this would be)
(This post was last modified: 05-09-2018 05:27 PM by Zervox.)
05-09-2018 05:26 PM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #3
RE: Billboard with text?
First approach does not sound realistic.
Second approach is complex too many images to RTT
Third approach is what i want. Is there any way to write text to dynamic image ?

GUI might as well be a option if there is something like GUI Label ? GUI Label as in UNITY

I have around 100 text boards to be drawn in the scene but they are all static means once drawn they don't need update.
(This post was last modified: 05-09-2018 06:49 PM by ronghester.)
05-09-2018 06:43 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Billboard with text?
You can use:

static void textDepth(Bool use, Flt depth=0); // this function can be optionally called before drawing text, to specify depth of the text (Z value for the Depth Buffer), if enabled then the text will be drawn with depth buffer test enabled and will be occluded by objects with depth smaller than 'depth'

to enable rendering text in 3D space, but it's always aligned front facing the camera.
I think sample code usage is in Ineisis Online source.
05-10-2018 12:08 AM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #5
RE: Billboard with text?
Tried textDepth but it does not work as expected. I had given the Z position of the object as value to depth parameter but output is not good [ The text cuts into half].

How about drawing the rect as a background of text ? Is there any easier way for that.
05-10-2018 05:22 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Billboard with text?
I've made this tutorial:
Code:
/******************************************************************************/
Mesh mesh;
/******************************************************************************/
void InitPre()
{
   EE_INIT();
}
/******************************************************************************/
bool Init()
{
   Cam.dist=2;

   mesh.parts.New().base.create(Ball(0.25), VTX_TEX0|VTX_NRM|VTX_TAN);
   mesh.material(UID(2123216029, 1141820639, 615850919, 3316401700)).setRender().setBox();

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   Cam.transformByMouse(1.5, 10, CAMH_ZOOM|CAMH_ROT);
   return true;
}
/******************************************************************************/
void Render()
{
   switch(Renderer())
   {
      case RM_PREPARE:
      {
         Matrix m; m.setPos(0, 0, Sin(Time.time()*2));
         if(Frustum(mesh.box, m))mesh.draw(m);

         LightDir(Vec(0, 0, 1)).add();
      }break;
   }
}
void Draw()
{
   Renderer(Render);
  
   Renderer.setDepthForDebugDrawing(); // make sure depth buffer is correct for custom rendering outside of 'Render' function
   D.textDepth(true, Cam.dist); // set depth of text as 'Cam.dist' from the camera
   D.text(0, 0, "3D Text");
   D.textDepth(false);
}
/******************************************************************************/
it works fine for me.

Quote:How about drawing the rect as a background of text ? Is there any easier way for that.
You can use EE::Text, set its members, then call Text.textSize, which is a wrapper for TextStyle.textLines
05-11-2018 03:55 AM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #7
RE: Billboard with text?
Got Following Errors :
error C2661: 'EE::Matrix::setPos': no overloaded function takes 3 arguments
error C2039: 'setDepthForDebugDrawing': is not a member of 'EE::RendererClass'
05-11-2018 03:41 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Billboard with text?
Are you not using latest EE version? which one do you have?
05-11-2018 11:35 PM
Find all posts by this user Quote this message in a reply
ronghester Offline
Member

Post: #9
RE: Billboard with text?
Engine Build 46 , Editor Build 48 ? Or should i find out the version from some where else?
05-12-2018 04:41 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Billboard with text?
The version is pretty old, is it Steam? Try downloading from EE Store -
http://www.esenthel.com/?id=store
05-13-2018 02:20 AM
Find all posts by this user Quote this message in a reply
Post Reply