00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llui.h"
00035 #include "llgl.h"
00036 #include "llfontgl.h"
00037
00038 #include "llagent.h"
00039
00040 #include "llvelocitybar.h"
00041
00042 const char tab = '\t';
00043
00044 void LLVelocityBar::draw()
00045 {
00046 const S32 BAR_TOP = 24;
00047 const S32 BAR_BOTTOM = 20;
00048 const S32 TICK_BOTTOM = 15;
00049 const S32 TICK_WIDTH = 2;
00050 const S32 MAGIC_CHAR_WIDTH = 6;
00051
00052 S32 left, top, right, bottom;
00053
00054
00055
00056
00057
00058 F32 velocity = gAgent.getVelocity().magVec();
00059
00060 LLColor4 bar_color(0.0f, 1.0f, 0.0f, 1.f);
00061
00062
00063
00064
00065
00066 LLGLSNoTexture gls_no_texture;
00067
00068
00069
00070
00071
00072
00073
00074 LLColor4 color(1.f, 1.f, 1.f, 1.f);
00075
00076 top = BAR_BOTTOM - 1;
00077 bottom = TICK_BOTTOM;
00078
00079 left = 0;
00080 right = left + TICK_WIDTH;
00081 gl_rect_2d(left, top, right, bottom, color);
00082
00083 left = (S32) (getRect().getWidth() * 1 / 6);
00084 right = left + TICK_WIDTH;
00085 gl_rect_2d(left, top, right, bottom, color);
00086
00087 left = (S32) (getRect().getWidth() * 2 / 6);
00088 right = left + TICK_WIDTH;
00089 gl_rect_2d(left, top, right, bottom, color);
00090
00091 left = (S32) (getRect().getWidth() * 3 / 6);
00092 right = left + TICK_WIDTH;
00093 gl_rect_2d(left, top, right, bottom, color);
00094
00095 left = (S32) (getRect().getWidth() * 4 / 6);
00096 right = left + TICK_WIDTH;
00097 gl_rect_2d(left, top, right, bottom, color);
00098
00099 left = (S32) (getRect().getWidth() * 5 / 6);
00100 right = left + TICK_WIDTH;
00101 gl_rect_2d(left, top, right, bottom, color);
00102
00103 left = (S32) (getRect().getWidth() * 6 / 6);
00104 right = left + TICK_WIDTH;
00105 gl_rect_2d(left, top, right, bottom, color);
00106
00107
00108
00109
00110 top = BAR_TOP + 15;
00111 left = 0;
00112 char str[80];
00113 snprintf(str, sizeof(str), "Velocity %.3fm/s", velocity);
00114 LLFontGL::sMonospace->renderUTF8(str, 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00115
00116 top = TICK_BOTTOM;
00117
00118 left = - MAGIC_CHAR_WIDTH/2;
00119 LLFontGL::sMonospace->renderUTF8("0", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00120
00121 left = (getRect().getWidth()*1 / 6) - MAGIC_CHAR_WIDTH * 2;
00122 LLFontGL::sMonospace->renderUTF8("1", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00123
00124 left = (getRect().getWidth()*2 / 6) - MAGIC_CHAR_WIDTH;
00125 LLFontGL::sMonospace->renderUTF8("2", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00126
00127 left = (getRect().getWidth()*3 / 6) - MAGIC_CHAR_WIDTH * 2;
00128 LLFontGL::sMonospace->renderUTF8("3", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00129
00130 left = (getRect().getWidth()*4 / 6) - MAGIC_CHAR_WIDTH;
00131 LLFontGL::sMonospace->renderUTF8("4", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00132
00133 left = (getRect().getWidth()*5 / 6) - MAGIC_CHAR_WIDTH * 2;
00134 LLFontGL::sMonospace->renderUTF8("5", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00135
00136 left = (getRect().getWidth()*6 / 6) - MAGIC_CHAR_WIDTH * 3;
00137 LLFontGL::sMonospace->renderUTF8("6 m/s", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00138
00139
00140 top = BAR_TOP;
00141 bottom = BAR_BOTTOM;
00142
00143
00144 left = 0;
00145 right = (S32) (left + velocity * 0.33333f * getRect().getWidth() / 2.f);
00146 gl_rect_2d(left, top, right, bottom, bar_color);
00147 }