Torque3D Documentation / _generateds / guiShapeNameHud.cpp

guiShapeNameHud.cpp

Engine/source/T3D/fps/guiShapeNameHud.cpp

More...

Classes:

class

Displays name & damage above shape objects.

Public Functions

ConsoleDocClass(GuiShapeNameHud , "@brief Displays name and damage of <a href="/coding/class/classshapebase/">ShapeBase</a> objects in its bounds. Must be <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classguitsctrl/">GuiTSCtrl</a> and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server connection must be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">present.\n\n</a>" "This <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> displays the name and damage <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of all named <a href="/coding/class/classshapebase/">ShapeBase</a> objects on the client. " "The name and damage of objects within the <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a>'s display area are overlayed above the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">object.\n\n</a>" "This GUI <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> must be <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> TSControl, and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server connection and <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> object must be present. " "This is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> stand-alone <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> and relies only on the standard base <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControl.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguishapenamehud/">GuiShapeNameHud</a>()" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " fillColor=\"0.0 1.0 0.0 1.0\"; // Fills with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> solid green <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	frameColor = \"1.0 1.0 1.0 1.0\"; // Solid white frame <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	textColor = \"1.0 1.0 1.0 1.0\"; // Solid white text <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Color\n</a>" "	showFill = \"true\";\n" "	showFrame = \"true\";\n" "	labelFillColor = \"0.0 1.0 0.0 1.0\"; // Fills with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> solid green <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	labelFrameColor = \"1.0 1.0 1.0 1.0\"; // Solid white frame <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	showLabelFill = \"true\";\n" "	showLabelFrame = \"true\";\n" "	verticalOffset = \"0.15\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "	distanceFade = \"15.0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiGame\n</a>" )

Detailed Description

Public Functions

ConsoleDocClass(GuiShapeNameHud , "@brief Displays name and damage of <a href="/coding/class/classshapebase/">ShapeBase</a> objects in its bounds. Must be <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classguitsctrl/">GuiTSCtrl</a> and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server connection must be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">present.\n\n</a>" "This <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> displays the name and damage <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of all named <a href="/coding/class/classshapebase/">ShapeBase</a> objects on the client. " "The name and damage of objects within the <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a>'s display area are overlayed above the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">object.\n\n</a>" "This GUI <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> must be <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> TSControl, and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server connection and <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> object must be present. " "This is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> stand-alone <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> and relies only on the standard base <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControl.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguishapenamehud/">GuiShapeNameHud</a>()" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " fillColor=\"0.0 1.0 0.0 1.0\"; // Fills with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> solid green <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	frameColor = \"1.0 1.0 1.0 1.0\"; // Solid white frame <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	textColor = \"1.0 1.0 1.0 1.0\"; // Solid white text <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Color\n</a>" "	showFill = \"true\";\n" "	showFrame = \"true\";\n" "	labelFillColor = \"0.0 1.0 0.0 1.0\"; // Fills with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> solid green <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	labelFrameColor = \"1.0 1.0 1.0 1.0\"; // Solid white frame <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">color\n</a>" "	showLabelFill = \"true\";\n" "	showLabelFrame = \"true\";\n" "	verticalOffset = \"0.15\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "	distanceFade = \"15.0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiGame\n</a>" )

IMPLEMENT_CONOBJECT(GuiShapeNameHud )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "platform/platform.h"
 25
 26#include "gui/core/guiControl.h"
 27#include "gui/3d/guiTSControl.h"
 28#include "console/consoleTypes.h"
 29#include "scene/sceneManager.h"
 30#include "T3D/gameBase/gameConnection.h"
 31#include "T3D/shapeBase.h"
 32#include "gfx/gfxDrawUtil.h"
 33#include "console/engineAPI.h"
 34
 35
 36//----------------------------------------------------------------------------
 37/// Displays name & damage above shape objects.
 38///
 39/// This control displays the name and damage value of all named
 40/// ShapeBase objects on the client.  The name and damage of objects
 41/// within the control's display area are overlayed above the object.
 42///
 43/// This GUI control must be a child of a TSControl, and a server connection
 44/// and control object must be present.
 45///
 46/// This is a stand-alone control and relies only on the standard base GuiControl.
 47class GuiShapeNameHud : public GuiControl {
 48   typedef GuiControl Parent;
 49
 50   // field data
 51   LinearColorF   mFillColor;
 52   LinearColorF   mFrameColor;
 53   LinearColorF   mTextColor;
 54   LinearColorF   mLabelFillColor;
 55   LinearColorF   mLabelFrameColor;
 56
 57   F32      mVerticalOffset;
 58   F32      mDistanceFade;
 59   bool     mShowFrame;
 60   bool     mShowFill;
 61   bool     mShowLabelFrame;
 62   bool     mShowLabelFill;
 63
 64   Point2I  mLabelPadding;
 65
 66protected:
 67   void drawName( Point2I offset, const char *buf, F32 opacity);
 68
 69public:
 70   GuiShapeNameHud();
 71
 72   // GuiControl
 73   virtual void onRender(Point2I offset, const RectI &updateRect);
 74
 75   static void initPersistFields();
 76   DECLARE_CONOBJECT( GuiShapeNameHud );
 77   DECLARE_CATEGORY( "Gui Game" );
 78   DECLARE_DESCRIPTION( "Displays name and damage of ShapeBase objects in its bounds.\n"
 79      "Must be a child of a GuiTSCtrl and a server connection must be present." );
 80};
 81
 82
 83//-----------------------------------------------------------------------------
 84
 85IMPLEMENT_CONOBJECT(GuiShapeNameHud);
 86
 87ConsoleDocClass( GuiShapeNameHud,
 88   "@brief Displays name and damage of ShapeBase objects in its bounds. Must be a child of a GuiTSCtrl and a server connection must be present.\n\n"
 89   "This control displays the name and damage value of all named ShapeBase objects on the client. "
 90   "The name and damage of objects within the control's display area are overlayed above the object.\n\n"
 91   "This GUI control must be a child of a TSControl, and a server connection and control object must be present. "
 92   "This is a stand-alone control and relies only on the standard base GuiControl.\n\n"
 93   
 94   "@tsexample\n"
 95      "\n new GuiShapeNameHud()"
 96      "{\n"
 97      "  fillColor = \"0.0 1.0 0.0 1.0\"; // Fills with a solid green color\n"
 98      "  frameColor = \"1.0 1.0 1.0 1.0\"; // Solid white frame color\n"
 99      "  textColor = \"1.0 1.0 1.0 1.0\"; // Solid white text Color\n"
100      "  showFill = \"true\";\n"
101      "  showFrame = \"true\";\n"
102      "  labelFillColor = \"0.0 1.0 0.0 1.0\"; // Fills with a solid green color\n"
103      "  labelFrameColor = \"1.0 1.0 1.0 1.0\"; // Solid white frame color\n"
104      "  showLabelFill = \"true\";\n"
105      "  showLabelFrame = \"true\";\n"
106      "  verticalOffset = \"0.15\";\n"
107      "  distanceFade = \"15.0\";\n"
108      "};\n"
109   "@endtsexample\n\n"
110   
111   "@ingroup GuiGame\n"
112);
113
114GuiShapeNameHud::GuiShapeNameHud()
115{
116   mFillColor.set( 0.25f, 0.25f, 0.25f, 0.25f );
117   mFrameColor.set( 0, 1, 0, 1 );
118   mLabelFillColor.set( 0.25f, 0.25f, 0.25f, 0.25f );
119   mLabelFrameColor.set( 0, 1, 0, 1 );
120   mTextColor.set( 0, 1, 0, 1 );
121   mShowFrame = mShowFill = true;
122   mShowLabelFrame = mShowLabelFill = false;
123   mVerticalOffset = 0.5f;
124   mDistanceFade = 0.1f;
125   mLabelPadding.set(0, 0);
126}
127
128void GuiShapeNameHud::initPersistFields()
129{
130   addGroup("Colors");     
131   addField( "fillColor",  TypeColorF, Offset( mFillColor, GuiShapeNameHud ), "Standard color for the background of the control." );
132   addField( "frameColor", TypeColorF, Offset( mFrameColor, GuiShapeNameHud ), "Color for the control's frame."  );
133   addField( "textColor",  TypeColorF, Offset( mTextColor, GuiShapeNameHud ), "Color for the text on this control." );
134   addField( "labelFillColor",  TypeColorF, Offset( mLabelFillColor, GuiShapeNameHud ), "Color for the background of each shape name label." );
135   addField( "labelFrameColor", TypeColorF, Offset( mLabelFrameColor, GuiShapeNameHud ), "Color for the frames around each shape name label."  );
136   endGroup("Colors");     
137
138   addGroup("Misc");       
139   addField( "showFill",   TypeBool, Offset( mShowFill, GuiShapeNameHud ), "If true, we draw the background color of the control." );
140   addField( "showFrame",  TypeBool, Offset( mShowFrame, GuiShapeNameHud ), "If true, we draw the frame of the control."  );
141   addField( "showLabelFill",  TypeBool, Offset( mShowLabelFill, GuiShapeNameHud ), "If true, we draw a background for each shape name label." );
142   addField( "showLabelFrame", TypeBool, Offset( mShowLabelFrame, GuiShapeNameHud ), "If true, we draw a frame around each shape name label."  );
143   addField( "labelPadding", TypePoint2I, Offset( mLabelPadding, GuiShapeNameHud ), "The padding (in pixels) between the label text and the frame." );
144   addField( "verticalOffset", TypeF32, Offset( mVerticalOffset, GuiShapeNameHud ), "Amount to vertically offset the control in relation to the ShapeBase object in focus." );
145   addField( "distanceFade", TypeF32, Offset( mDistanceFade, GuiShapeNameHud ), "Visibility distance (how far the player must be from the ShapeBase object in focus) for this control to render." );
146   endGroup("Misc");
147   Parent::initPersistFields();
148}
149
150
151//----------------------------------------------------------------------------
152/// Core rendering method for this control.
153///
154/// This method scans through all the current client ShapeBase objects.
155/// If one is named, it displays the name and damage information for it.
156///
157/// Information is offset from the center of the object's bounding box,
158/// unless the object is a PlayerObjectType, in which case the eye point
159/// is used.
160///
161/// @param   updateRect   Extents of control.
162void GuiShapeNameHud::onRender( Point2I, const RectI &updateRect)
163{
164   // Background fill first
165   if (mShowFill)
166      GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor.toColorI());
167
168   // Must be in a TS Control
169   GuiTSCtrl *parent = dynamic_cast<GuiTSCtrl*>(getParent());
170   if (!parent) return;
171
172   // Must have a connection and control object
173   GameConnection* conn = GameConnection::getConnectionToServer();
174   if (!conn) return;
175   GameBase * control = dynamic_cast<GameBase*>(conn->getControlObject());
176   if (!control) return;
177
178   // Get control camera info
179   MatrixF cam;
180   Point3F camPos;
181   VectorF camDir;
182   conn->getControlCameraTransform(0,&cam);
183   cam.getColumn(3, &camPos);
184   cam.getColumn(1, &camDir);
185
186   F32 camFovCos;
187   conn->getControlCameraFov(&camFovCos);
188   camFovCos = mCos(mDegToRad(camFovCos) / 2);
189
190   // Visible distance info & name fading
191   F32 visDistance = gClientSceneGraph->getVisibleDistance();
192   F32 visDistanceSqr = visDistance * visDistance;
193   F32 fadeDistance = visDistance * mDistanceFade;
194
195   // Collision info. We're going to be running LOS tests and we
196   // don't want to collide with the control object.
197   static U32 losMask = TerrainObjectType | ShapeBaseObjectType | StaticObjectType;
198   control->disableCollision();
199
200   // All ghosted objects are added to the server connection group,
201   // so we can find all the shape base objects by iterating through
202   // our current connection.
203   for (SimSetIterator itr(conn); *itr; ++itr) {
204      ShapeBase* shape = dynamic_cast< ShapeBase* >(*itr);
205      if ( shape ) {
206         if (shape != control && shape->getShapeName()) 
207         {
208
209            // Target pos to test, if it's a player run the LOS to his eye
210            // point, otherwise we'll grab the generic box center.
211            Point3F shapePos;
212            if (shape->getTypeMask() & PlayerObjectType) 
213            {
214               MatrixF eye;
215
216               // Use the render eye transform, otherwise we'll see jittering
217               shape->getRenderEyeTransform(&eye);
218               eye.getColumn(3, &shapePos);
219            } 
220            else 
221            {
222                // Use the render transform instead of the box center
223                // otherwise it'll jitter.
224               MatrixF srtMat = shape->getRenderTransform();
225               srtMat.getColumn(3, &shapePos);
226            }
227            VectorF shapeDir = shapePos - camPos;
228
229            // Test to see if it's in range
230            F32 shapeDist = shapeDir.lenSquared();
231            if (shapeDist == 0 || shapeDist > visDistanceSqr)
232               continue;
233            shapeDist = mSqrt(shapeDist);
234
235            // Test to see if it's within our viewcone, this test doesn't
236            // actually match the viewport very well, should consider
237            // projection and box test.
238            shapeDir.normalize();
239            F32 dot = mDot(shapeDir, camDir);
240            if (dot < camFovCos)
241               continue;
242
243            // Test to see if it's behind something, and we want to
244            // ignore anything it's mounted on when we run the LOS.
245            RayInfo info;
246            shape->disableCollision();
247            SceneObject *mount = shape->getObjectMount();
248            if (mount)
249               mount->disableCollision();
250            bool los = !gClientContainer.castRay(camPos, shapePos,losMask, &info);
251            shape->enableCollision();
252            if (mount)
253               mount->enableCollision();
254            if (!los)
255               continue;
256
257            // Project the shape pos into screen space and calculate
258            // the distance opacity used to fade the labels into the
259            // distance.
260            Point3F projPnt;
261            shapePos.z += mVerticalOffset;
262            if (!parent->project(shapePos, &projPnt))
263               continue;
264            F32 opacity = (shapeDist < fadeDistance)? 1.0:
265               1.0 - (shapeDist - fadeDistance) / (visDistance - fadeDistance);
266
267            // Render the shape's name
268            drawName(Point2I((S32)projPnt.x, (S32)projPnt.y),shape->getShapeName(),opacity);
269         }
270      }
271   }
272
273   // Restore control object collision
274   control->enableCollision();
275
276   // Border last
277   if (mShowFrame)
278      GFX->getDrawUtil()->drawRect(updateRect, mFrameColor.toColorI());
279}
280
281
282//----------------------------------------------------------------------------
283/// Render object names.
284///
285/// Helper function for GuiShapeNameHud::onRender
286///
287/// @param   offset  Screen coordinates to render name label. (Text is centered
288///                  horizontally about this location, with bottom of text at
289///                  specified y position.)
290/// @param   name    String name to display.
291/// @param   opacity Opacity of name (a fraction).
292void GuiShapeNameHud::drawName(Point2I offset, const char *name, F32 opacity)
293{
294   F32 width = mProfile->mFont->getStrWidth((const UTF8 *)name) + mLabelPadding.x * 2;
295   F32 height = mProfile->mFont->getHeight() + mLabelPadding.y * 2;
296   Point2I extent = Point2I(width, height);
297
298   // Center the name
299   offset.x -= width / 2;
300   offset.y -= height / 2;
301
302   GFXDrawUtil* drawUtil = GFX->getDrawUtil();
303
304   // Background fill first
305   if (mShowLabelFill)
306      drawUtil->drawRectFill(RectI(offset, extent), mLabelFillColor.toColorI());
307
308   // Deal with opacity and draw.
309   mTextColor.alpha = opacity;
310   drawUtil->setBitmapModulation(mTextColor.toColorI());
311   drawUtil->drawText(mProfile->mFont, offset + mLabelPadding, name);
312   drawUtil->clearBitmapModulation();
313
314   // Border last
315   if (mShowLabelFrame)
316      drawUtil->drawRect(RectI(offset, extent), mLabelFrameColor.toColorI());
317}
318
319