llmanip.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llmanip.h"
00035 
00036 #include "llmath.h"
00037 #include "v3math.h"
00038 #include "llgl.h"
00039 #include "llglimmediate.h"
00040 #include "llprimitive.h"
00041 #include "llview.h"
00042 #include "llviewerimagelist.h"
00043 
00044 #include "llagent.h"
00045 #include "llviewercontrol.h"
00046 #include "lldrawable.h"
00047 #include "llfontgl.h"
00048 #include "llhudrender.h"
00049 #include "llselectmgr.h"
00050 #include "llui.h"
00051 #include "llviewercamera.h"
00052 #include "llviewerjoint.h"
00053 #include "llviewerobject.h"
00054 #include "llviewerwindow.h"
00055 #include "llvoavatar.h"
00056 #include "llworld.h"            // for LLWorld::getInstance()
00057 #include "llresmgr.h"
00058 #include "pipeline.h"
00059 #include "llglheaders.h"
00060 
00061 // Local constants...
00062 const S32 VERTICAL_OFFSET = 50;
00063 
00064 F32             LLManip::sHelpTextVisibleTime = 2.f;
00065 F32             LLManip::sHelpTextFadeTime = 2.f;
00066 S32             LLManip::sNumTimesHelpTextShown = 0;
00067 S32             LLManip::sMaxTimesShowHelpText = 5;
00068 F32             LLManip::sGridMaxSubdivisionLevel = 32.f;
00069 F32             LLManip::sGridMinSubdivisionLevel = 1.f;
00070 LLVector2 LLManip::sTickLabelSpacing(60.f, 25.f);
00071 
00072 
00073 //static
00074 void LLManip::rebuild(LLViewerObject* vobj)
00075 {
00076         LLDrawable* drawablep = vobj->mDrawable;
00077         if (drawablep && drawablep->getVOVolume())
00078         {
00079                 
00080                 gPipeline.markRebuild(drawablep,LLDrawable::REBUILD_VOLUME, TRUE);
00081                 drawablep->setState(LLDrawable::MOVE_UNDAMPED); // force to UNDAMPED
00082                 drawablep->updateMove();
00083                 LLSpatialGroup* group = drawablep->getSpatialGroup();
00084                 if (group)
00085                 {
00086                         group->dirtyGeom();
00087                 }
00088         }
00089 }
00090 
00092 // LLManip
00093 
00094 
00095 LLManip::LLManip( const LLString& name, LLToolComposite* composite )
00096         :
00097         LLTool( name, composite ),
00098         mInSnapRegime(FALSE),
00099         mHighlightedPart(LL_NO_PART)
00100 {
00101 }
00102 
00103 void LLManip::getManipNormal(LLViewerObject* object, EManipPart manip, LLVector3 &normal)
00104 {
00105         LLVector3 grid_origin;
00106         LLVector3 grid_scale;
00107         LLQuaternion grid_rotation;
00108 
00109         LLSelectMgr::getInstance()->getGrid(grid_origin, grid_rotation, grid_scale);
00110 
00111         if (manip >= LL_X_ARROW && manip <= LL_Z_ARROW)
00112         {
00113                 LLVector3 arrow_axis;
00114                 getManipAxis(object, manip, arrow_axis);
00115 
00116                 LLVector3 cross = arrow_axis % LLViewerCamera::getInstance()->getAtAxis();
00117                 normal = cross % arrow_axis;
00118                 normal.normVec();
00119         }
00120         else if (manip >= LL_YZ_PLANE && manip <= LL_XY_PLANE)
00121         {
00122                 switch (manip)
00123                 {
00124                 case LL_YZ_PLANE:
00125                         normal = LLVector3::x_axis;
00126                         break;
00127                 case LL_XZ_PLANE:
00128                         normal = LLVector3::y_axis;
00129                         break;
00130                 case LL_XY_PLANE:
00131                         normal = LLVector3::z_axis;
00132                         break;
00133                 default:
00134                         break;
00135                 }
00136                 normal.rotVec(grid_rotation);
00137         }
00138         else
00139         {
00140                 normal.clearVec();
00141         }
00142 }
00143 
00144 
00145 BOOL LLManip::getManipAxis(LLViewerObject* object, EManipPart manip, LLVector3 &axis)
00146 {
00147         LLVector3 grid_origin;
00148         LLVector3 grid_scale;
00149         LLQuaternion grid_rotation;
00150 
00151         LLSelectMgr::getInstance()->getGrid(grid_origin, grid_rotation, grid_scale);
00152 
00153         if (manip == LL_X_ARROW)
00154         {
00155                 axis = LLVector3::x_axis;
00156         }
00157         else if (manip == LL_Y_ARROW)
00158         {
00159                 axis = LLVector3::y_axis;
00160         }
00161         else if (manip == LL_Z_ARROW)
00162         {
00163                 axis = LLVector3::z_axis;
00164         }
00165         else
00166         {
00167                 return FALSE;
00168         }
00169 
00170         axis.rotVec( grid_rotation );
00171         return TRUE;
00172 }
00173 
00174 F32 LLManip::getSubdivisionLevel(const LLVector3 &reference_point, const LLVector3 &translate_axis, F32 grid_scale, S32 min_pixel_spacing)
00175 {
00176         //update current snap subdivision level
00177         LLVector3 cam_to_reference;
00178         if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
00179         {
00180                 cam_to_reference = LLVector3(1.f / gAgent.getAvatarObject()->mHUDCurZoom, 0.f, 0.f);
00181         }
00182         else
00183         {
00184                 cam_to_reference = reference_point - LLViewerCamera::getInstance()->getOrigin();
00185         }
00186         F32 current_range = cam_to_reference.normVec();
00187 
00188         F32 projected_translation_axis_length = (translate_axis % cam_to_reference).magVec();
00189         F32 subdivisions = llmax(projected_translation_axis_length * grid_scale / (current_range / LLViewerCamera::getInstance()->getPixelMeterRatio() * min_pixel_spacing), 0.f);
00190         subdivisions = llclamp((F32)pow(2.f, llfloor(log(subdivisions) / log(2.f))), 1.f / 32.f, 32.f);
00191 
00192         return subdivisions;
00193 }
00194 
00195 void LLManip::handleSelect()
00196 {
00197         mObjectSelection = LLSelectMgr::getInstance()->getEditSelection();
00198 }
00199 
00200 void LLManip::handleDeselect()
00201 {
00202         mObjectSelection = NULL;
00203 }
00204 
00205 LLObjectSelectionHandle LLManip::getSelection()
00206 {
00207         return mObjectSelection;
00208 }
00209 
00210 BOOL LLManip::handleHover(S32 x, S32 y, MASK mask)
00211 {
00212         // We only handle the event if mousedown started with us
00213         if( hasMouseCapture() )
00214         {
00215                 if( mObjectSelection->isEmpty() )
00216                 {
00217                         // Somehow the object got deselected while we were dragging it.
00218                         // Release the mouse
00219                         setMouseCapture( FALSE );
00220                 }
00221 
00222                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLManip (active)" << llendl;
00223         }
00224         else
00225         {
00226                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLManip (inactive)" << llendl;
00227         }
00228         gViewerWindow->setCursor(UI_CURSOR_ARROW);
00229         return TRUE;
00230 }
00231 
00232 
00233 BOOL LLManip::handleMouseUp(S32 x, S32 y, MASK mask)
00234 {
00235         BOOL    handled = FALSE;
00236         if( hasMouseCapture() )
00237         {
00238                 handled = TRUE;
00239                 setMouseCapture( FALSE );
00240         }
00241         return handled;
00242 }
00243 
00244 void LLManip::updateGridSettings()
00245 {
00246         sGridMaxSubdivisionLevel = gSavedSettings.getBOOL("GridSubUnit") ? (F32)gSavedSettings.getS32("GridSubdivision") : 1.f;
00247 }
00248 
00249 BOOL LLManip::getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector3 origin, LLVector3 normal)
00250 {
00251         LLVector3d origin_double = gAgent.getPosGlobalFromAgent(origin);
00252         LLVector3d global_point;
00253         BOOL result = getMousePointOnPlaneGlobal(global_point, x, y, origin_double, normal);
00254         point = gAgent.getPosAgentFromGlobal(global_point);
00255         return result;
00256 }
00257 
00258 BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVector3d origin, LLVector3 normal) const
00259 {
00260         if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
00261         {
00262                 BOOL result = FALSE;
00263                 F32 mouse_x = ((F32)x / gViewerWindow->getWindowWidth() - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom;
00264                 F32 mouse_y = ((F32)y / gViewerWindow->getWindowHeight() - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom;
00265 
00266                 LLVector3 origin_agent = gAgent.getPosAgentFromGlobal(origin);
00267                 LLVector3 mouse_pos = LLVector3(0.f, -mouse_x, mouse_y);
00268                 if (llabs(normal.mV[VX]) < 0.001f)
00269                 {
00270                         // use largish value that should be outside HUD manipulation range
00271                         mouse_pos.mV[VX] = 10.f;
00272                 }
00273                 else
00274                 {
00275                         mouse_pos.mV[VX] = (normal * (origin_agent - mouse_pos))
00276                                                                 / (normal.mV[VX]);
00277                         result = TRUE;
00278                 }
00279 
00280                 point = gAgent.getPosGlobalFromAgent(mouse_pos);
00281                 return result;
00282         }
00283         else
00284         {
00285                 return gViewerWindow->mousePointOnPlaneGlobal(
00286                                                                                 point, x, y, origin, normal );
00287         }
00288 
00289         //return FALSE;
00290 }
00291 
00292 // Given the line defined by mouse cursor (a1 + a_param*(a2-a1)) and the line defined by b1 + b_param*(b2-b1),
00293 // returns a_param and b_param for the points where lines are closest to each other.
00294 // Returns false if the two lines are parallel.
00295 BOOL LLManip::nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param )
00296 {
00297         LLVector3 a1;
00298         LLVector3 a2;
00299 
00300         if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
00301         {
00302                 F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom;
00303                 F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeight()) - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom;
00304                 a1 = LLVector3(llmin(b1.mV[VX] - 0.1f, b2.mV[VX] - 0.1f, 0.f), -mouse_x, mouse_y);
00305                 a2 = a1 + LLVector3(1.f, 0.f, 0.f);
00306         }
00307         else
00308         {
00309                 a1 = gAgent.getCameraPositionAgent();
00310                 a2 = gAgent.getCameraPositionAgent() + LLVector3(gViewerWindow->mouseDirectionGlobal(x, y));
00311         }
00312 
00313         BOOL parallel = TRUE;
00314         LLVector3 a = a2 - a1;
00315         LLVector3 b = b2 - b1;
00316 
00317         LLVector3 normal;
00318         F32 dist, denom;
00319         normal = (b % a) % b;   // normal to plane (P) through b and (shortest line between a and b)
00320         normal.normVec();
00321         dist = b1 * normal;                     // distance from origin to P
00322 
00323         denom = normal * a; 
00324         if( (denom < -F_APPROXIMATELY_ZERO) || (F_APPROXIMATELY_ZERO < denom) )
00325         {
00326                 a_param = (dist - normal * a1) / denom;
00327                 parallel = FALSE;
00328         }
00329 
00330         normal = (a % b) % a;   // normal to plane (P) through a and (shortest line between a and b)
00331         normal.normVec();
00332         dist = a1 * normal;                     // distance from origin to P
00333         denom = normal * b; 
00334         if( (denom < -F_APPROXIMATELY_ZERO) || (F_APPROXIMATELY_ZERO < denom) )
00335         {
00336                 b_param = (dist - normal * b1) / denom;
00337                 parallel = FALSE;
00338         }
00339 
00340         return parallel;
00341 }
00342 
00343 LLVector3 LLManip::getSavedPivotPoint() const
00344 {
00345         return LLSelectMgr::getInstance()->getSavedBBoxOfSelection().getCenterAgent();
00346 }
00347 
00348 LLVector3 LLManip::getPivotPoint()
00349 {
00350         if (mObjectSelection->getFirstObject() && mObjectSelection->getObjectCount() == 1 && mObjectSelection->getSelectType() != SELECT_TYPE_HUD)
00351         {
00352                 return mObjectSelection->getFirstObject()->getPivotPositionAgent();
00353         }
00354         return LLSelectMgr::getInstance()->getBBoxOfSelection().getCenterAgent();
00355 }
00356 
00357 
00358 void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z)
00359 {
00360         LLVector3 grid_origin;
00361         LLQuaternion grid_rot;
00362         LLVector3 grid_scale;
00363         LLSelectMgr::getInstance()->getGrid(grid_origin, grid_rot, grid_scale);
00364 
00365         const BOOL children_ok = TRUE;
00366         LLViewerObject* object = mObjectSelection->getFirstRootObject(children_ok);
00367         if (!object)
00368         {
00369                 return;
00370         }
00371 
00372         //LLVector3  center_agent  = LLSelectMgr::getInstance()->getBBoxOfSelection().getCenterAgent();
00373         LLVector3  center_agent  = getPivotPoint();
00374 
00375         glPushMatrix();
00376         {
00377                 glTranslatef(center_agent.mV[VX], center_agent.mV[VY], center_agent.mV[VZ]);
00378 
00379                 F32 angle_radians, x, y, z;
00380 
00381                 grid_rot.getAngleAxis(&angle_radians, &x, &y, &z);
00382                 glRotatef(angle_radians * RAD_TO_DEG, x, y, z);
00383 
00384                 F32 region_size = LLWorld::getInstance()->getRegionWidthInMeters();
00385 
00386                 const F32 LINE_ALPHA = 0.33f;
00387 
00388                 LLGLSNoTexture gls_no_texture;
00389                 LLUI::setLineWidth(1.5f);
00390 
00391                 if (draw_x)
00392                 {
00393                         gGL.color4f(1.f, 0.f, 0.f, LINE_ALPHA);
00394                         gGL.begin(LLVertexBuffer::LINES);
00395                         gGL.vertex3f( -region_size, 0.f, 0.f );
00396                         gGL.vertex3f(  region_size, 0.f, 0.f );
00397                         gGL.end();
00398                 }
00399 
00400                 if (draw_y)
00401                 {
00402                         gGL.color4f(0.f, 1.f, 0.f, LINE_ALPHA);
00403                         gGL.begin(LLVertexBuffer::LINES);
00404                         gGL.vertex3f( 0.f, -region_size, 0.f );
00405                         gGL.vertex3f( 0.f,  region_size, 0.f );
00406                         gGL.end();
00407                 }
00408 
00409                 if (draw_z)
00410                 {
00411                         gGL.color4f(0.f, 0.f, 1.f, LINE_ALPHA);
00412                         gGL.begin(LLVertexBuffer::LINES);
00413                         gGL.vertex3f( 0.f, 0.f, -region_size );
00414                         gGL.vertex3f( 0.f, 0.f,  region_size );
00415                         gGL.end();
00416                 }
00417                 LLUI::setLineWidth(1.0f);
00418         }
00419         glPopMatrix();
00420 }
00421 
00422 void LLManip::renderXYZ(const LLVector3 &vec) 
00423 {
00424         const S32 PAD = 10;
00425         char feedback_string[128];              /*Flawfinder: ignore*/
00426         LLVector3 camera_pos = LLViewerCamera::getInstance()->getOrigin() + LLViewerCamera::getInstance()->getAtAxis();
00427         S32 vertical_offset = gViewerWindow->getWindowHeight() / 2 - VERTICAL_OFFSET;
00428         S32 window_center_x = gViewerWindow->getWindowWidth() / 2;
00429         S32 window_center_y = gViewerWindow->getWindowHeight() / 2;
00430 
00431         glPushMatrix();
00432         {
00433                 LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga");
00434                 gViewerWindow->setup2DRender();
00435                 const LLVector2& display_scale = gViewerWindow->getDisplayScale();
00436                 glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f);
00437                 gGL.color4f(0.f, 0.f, 0.f, 0.7f);
00438 
00439                 imagep->draw(
00440                         window_center_x - 115, 
00441                         window_center_y + vertical_offset - PAD, 
00442                         235,
00443                         PAD * 2 + 10, 
00444                         LLColor4(0.f, 0.f, 0.f, 0.7f) );
00445         }
00446         glPopMatrix();
00447 
00448         gViewerWindow->setup3DRender();
00449 
00450         {
00451                 LLLocale locale(LLLocale::USER_LOCALE);
00452                 LLGLDepthTest gls_depth(GL_FALSE);
00453                 // render drop shadowed text
00454                 snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]);                      /* Flawfinder: ignore */
00455                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE);
00456 
00457                 snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]);                      /* Flawfinder: ignore */
00458                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE);
00459                 
00460                 snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]);                      /* Flawfinder: ignore */
00461                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE);
00462 
00463                 // render text on top
00464                 snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]);                      /* Flawfinder: ignore */
00465                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f, (F32)vertical_offset, LLColor4(1.f, 0.5f, 0.5f, 1.f), FALSE);
00466 
00467                 glColor3f(0.5f, 1.f, 0.5f);
00468                 snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]);                      /* Flawfinder: ignore */
00469                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f, (F32)vertical_offset, LLColor4(0.5f, 1.f, 0.5f, 1.f), FALSE);
00470                 
00471                 glColor3f(0.5f, 0.5f, 1.f);
00472                 snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]);                      /* Flawfinder: ignore */
00473                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f, (F32)vertical_offset, LLColor4(0.5f, 0.5f, 1.f, 1.f), FALSE);
00474         }
00475 }
00476 
00477 void LLManip::renderTickText(const LLVector3& pos, const char* text, const LLColor4 &color)
00478 {
00479         const LLFontGL* big_fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
00480 
00481         BOOL hud_selection = mObjectSelection->getSelectType() == SELECT_TYPE_HUD;
00482         glMatrixMode(GL_MODELVIEW);
00483         glPushMatrix();
00484         LLVector3 render_pos = pos;
00485         if (hud_selection)
00486         {
00487                 F32 zoom_amt = gAgent.getAvatarObject()->mHUDCurZoom;
00488                 F32 inv_zoom_amt = 1.f / zoom_amt;
00489                 // scale text back up to counter-act zoom level
00490                 render_pos = pos * zoom_amt;
00491                 glScalef(inv_zoom_amt, inv_zoom_amt, inv_zoom_amt);
00492         }
00493 
00494         // render shadow first
00495         LLColor4 shadow_color = LLColor4::black;
00496         shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f;
00497         gViewerWindow->setupViewport(1, -1);
00498         hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
00499         gViewerWindow->setupViewport();
00500         hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
00501 
00502         glPopMatrix();
00503 }
00504 
00505 void LLManip::renderTickValue(const LLVector3& pos, F32 value, const char* suffix, const LLColor4 &color)
00506 {
00507         LLLocale locale(LLLocale::USER_LOCALE);
00508 
00509         const LLFontGL* big_fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
00510         const LLFontGL* small_fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
00511 
00512         char val_string[128];           /*Flawfinder: ignore*/
00513         char fraction_string[128];              /*Flawfinder: ignore*/
00514         F32 val_to_print = llround(value, 0.001f);
00515         S32 fractional_portion = llround(fmodf(llabs(val_to_print), 1.f) * 100.f);
00516         if (val_to_print < 0.f)
00517         {
00518                 if (fractional_portion == 0)
00519                 {
00520                         snprintf(val_string, sizeof(val_string), "-%d%s", lltrunc(llabs(val_to_print)), suffix);                        /* Flawfinder: ignore */
00521                 }
00522                 else
00523                 {
00524                         snprintf(val_string, sizeof(val_string), "-%d", lltrunc(llabs(val_to_print)));                  /* Flawfinder: ignore */
00525                 }
00526         }
00527         else
00528         {
00529                 if (fractional_portion == 0)
00530                 {
00531                         snprintf(val_string, sizeof(val_string), "%d%s", lltrunc(llabs(val_to_print)), suffix);                 /* Flawfinder: ignore */
00532                 }
00533                 else
00534                 {
00535                         snprintf(val_string, sizeof(val_string), "%d", lltrunc(val_to_print));                  /* Flawfinder: ignore */
00536                 }
00537         }
00538 
00539         BOOL hud_selection = mObjectSelection->getSelectType() == SELECT_TYPE_HUD;
00540         glMatrixMode(GL_MODELVIEW);
00541         glPushMatrix();
00542         LLVector3 render_pos = pos;
00543         if (hud_selection)
00544         {
00545                 F32 zoom_amt = gAgent.getAvatarObject()->mHUDCurZoom;
00546                 F32 inv_zoom_amt = 1.f / zoom_amt;
00547                 // scale text back up to counter-act zoom level
00548                 render_pos = pos * zoom_amt;
00549                 glScalef(inv_zoom_amt, inv_zoom_amt, inv_zoom_amt);
00550         }
00551 
00552         LLColor4 shadow_color = LLColor4::black;
00553         shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f;
00554 
00555         if (fractional_portion != 0)
00556         {
00557                 snprintf(fraction_string, sizeof(fraction_string), "%c%02d%s", LLResMgr::getInstance()->getDecimalPoint(), fractional_portion, suffix);                 /* Flawfinder: ignore */
00558 
00559                 gViewerWindow->setupViewport(1, -1);
00560                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection);
00561                 hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, shadow_color, hud_selection);
00562 
00563                 gViewerWindow->setupViewport();
00564                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
00565                 hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, color, hud_selection);
00566         }
00567         else
00568         {
00569                 gViewerWindow->setupViewport(1, -1);
00570                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection);
00571                 gViewerWindow->setupViewport();
00572                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
00573         }
00574         glPopMatrix();
00575 }
00576 
00577 LLColor4 LLManip::setupSnapGuideRenderPass(S32 pass)
00578 {
00579         static LLColor4 grid_color_fg = gColors.getColor("GridlineColor");
00580         static LLColor4 grid_color_bg = gColors.getColor("GridlineBGColor");
00581         static LLColor4 grid_color_shadow = gColors.getColor("GridlineShadowColor");
00582 
00583         LLColor4 line_color;
00584         F32 line_alpha = gSavedSettings.getF32("GridOpacity");
00585 
00586         switch(pass)
00587         {
00588         case 0:
00589                 // shadow
00590                 gViewerWindow->setupViewport(1, -1);
00591                 line_color = grid_color_shadow;
00592                 line_color.mV[VALPHA] *= line_alpha;
00593                 LLUI::setLineWidth(2.f);
00594                 break;
00595         case 1:
00596                 // hidden lines
00597                 gViewerWindow->setupViewport();
00598                 line_color = grid_color_bg;
00599                 line_color.mV[VALPHA] *= line_alpha;
00600                 LLUI::setLineWidth(1.f);
00601                 break;
00602         case 2:
00603                 // visible lines
00604                 line_color = grid_color_fg;
00605                 line_color.mV[VALPHA] *= line_alpha;
00606                 break;
00607         }
00608 
00609         return line_color;
00610 }

Generated on Fri May 16 08:33:46 2008 for SecondLife by  doxygen 1.5.5