diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llglsandbox.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llglsandbox.cpp | 1241 |
1 files changed, 1241 insertions, 0 deletions
diff --git a/linden/indra/newview/llglsandbox.cpp b/linden/indra/newview/llglsandbox.cpp new file mode 100644 index 0000000..cc4ec9d --- /dev/null +++ b/linden/indra/newview/llglsandbox.cpp | |||
@@ -0,0 +1,1241 @@ | |||
1 | /** | ||
2 | * @file llglsandbox.cpp | ||
3 | * @brief GL functionality access | ||
4 | * | ||
5 | * Copyright (c) 2003-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | /** | ||
29 | * Contains ALL methods which directly access GL functionality | ||
30 | * except for core rendering engine functionality. | ||
31 | */ | ||
32 | |||
33 | #include "llviewerprecompiledheaders.h" | ||
34 | |||
35 | #include "llviewercontrol.h" | ||
36 | |||
37 | #include "llgl.h" | ||
38 | #include "llglheaders.h" | ||
39 | #include "llparcel.h" | ||
40 | #include "llui.h" | ||
41 | |||
42 | #include "lldrawable.h" | ||
43 | #include "lltextureentry.h" | ||
44 | #include "llviewercamera.h" | ||
45 | |||
46 | #include "llvoavatar.h" | ||
47 | #include "llagent.h" | ||
48 | #include "lltoolmgr.h" | ||
49 | #include "llselectmgr.h" | ||
50 | #include "llhudmanager.h" | ||
51 | #include "llsphere.h" | ||
52 | #include "llviewerobjectlist.h" | ||
53 | #include "lltoolselectrect.h" | ||
54 | #include "llviewerwindow.h" | ||
55 | #include "viewer.h" | ||
56 | #include "llcompass.h" | ||
57 | #include "llsurface.h" | ||
58 | #include "llwind.h" | ||
59 | #include "llworld.h" | ||
60 | #include "llviewerparcelmgr.h" | ||
61 | #include "llviewerregion.h" | ||
62 | #include "llpreviewtexture.h" | ||
63 | #include "llresmgr.h" | ||
64 | #include "pipeline.h" | ||
65 | |||
66 | BOOL LLAgent::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) | ||
67 | { | ||
68 | if(object && object->isAttachment()) | ||
69 | { | ||
70 | LLViewerObject* parent = object; | ||
71 | while(parent) | ||
72 | { | ||
73 | if (parent == mAvatarObject) | ||
74 | { | ||
75 | // looking at an attachment on ourselves, which we don't want to do | ||
76 | object = mAvatarObject; | ||
77 | position.clearVec(); | ||
78 | } | ||
79 | parent = (LLViewerObject*)parent->getParent(); | ||
80 | } | ||
81 | } | ||
82 | if(!mLookAt || mLookAt->isDead()) | ||
83 | { | ||
84 | mLookAt = (LLHUDEffectLookAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); | ||
85 | mLookAt->setSourceObject(mAvatarObject); | ||
86 | } | ||
87 | |||
88 | return mLookAt->setLookAt(target_type, object, position); | ||
89 | } | ||
90 | |||
91 | BOOL LLAgent::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position) | ||
92 | { | ||
93 | // disallow pointing at attachments and avatars | ||
94 | if (object && (object->isAttachment() || object->isAvatar())) | ||
95 | { | ||
96 | return FALSE; | ||
97 | } | ||
98 | |||
99 | if(!mPointAt || mPointAt->isDead()) | ||
100 | { | ||
101 | mPointAt = (LLHUDEffectPointAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); | ||
102 | mPointAt->setSourceObject(mAvatarObject); | ||
103 | } | ||
104 | |||
105 | return mPointAt->setPointAt(target_type, object, position); | ||
106 | } | ||
107 | |||
108 | ELookAtType LLAgent::getLookAtType() | ||
109 | { | ||
110 | if (mLookAt) | ||
111 | { | ||
112 | return mLookAt->getLookAtType(); | ||
113 | } | ||
114 | |||
115 | return LOOKAT_TARGET_NONE; | ||
116 | } | ||
117 | |||
118 | EPointAtType LLAgent::getPointAtType() | ||
119 | { | ||
120 | if (mPointAt) | ||
121 | { | ||
122 | return mPointAt->getPointAtType(); | ||
123 | } | ||
124 | |||
125 | return POINTAT_TARGET_NONE; | ||
126 | } | ||
127 | |||
128 | // Draw a representation of current autopilot target | ||
129 | void LLAgent::renderAutoPilotTarget() | ||
130 | { | ||
131 | if (mAutoPilot) | ||
132 | { | ||
133 | F32 height_meters; | ||
134 | LLVector3d target_global; | ||
135 | |||
136 | glMatrixMode(GL_MODELVIEW); | ||
137 | glPushMatrix(); | ||
138 | |||
139 | // not textured | ||
140 | LLGLSNoTexture no_texture; | ||
141 | |||
142 | // lovely green | ||
143 | glColor4f(0.f, 1.f, 1.f, 1.f); | ||
144 | |||
145 | target_global = mAutoPilotTargetGlobal; | ||
146 | |||
147 | glTranslatef((F32)(target_global.mdV[VX]), (F32)(target_global.mdV[VY]), (F32)(target_global.mdV[VZ])); | ||
148 | |||
149 | /* | ||
150 | LLVector3 offset = target_global - mCamera.getOrigin(); | ||
151 | F32 range = offset.magVec(); | ||
152 | if (range > 0.001f) | ||
153 | { | ||
154 | // range != zero | ||
155 | F32 fraction_of_fov = height_pixels / (F32) mCamera.getViewHeightInPixels(); | ||
156 | F32 apparent_angle = fraction_of_fov * mCamera.getView(); | ||
157 | height_meters = range * tan(apparent_angle); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | // range == zero | ||
162 | height_meters = 1.0f; | ||
163 | } | ||
164 | */ | ||
165 | height_meters = 1.f; | ||
166 | |||
167 | glScalef(height_meters, height_meters, height_meters); | ||
168 | |||
169 | gSphere.render(1500.f); | ||
170 | |||
171 | glPopMatrix(); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | extern BOOL gDebugSelect; | ||
176 | |||
177 | // Returns true if you got at least one object | ||
178 | void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) | ||
179 | { | ||
180 | LLVector3 av_pos = gAgent.getPositionAgent(); | ||
181 | F32 select_dist_squared = gSavedSettings.getF32("MaxSelectDistance"); | ||
182 | select_dist_squared = select_dist_squared * select_dist_squared; | ||
183 | |||
184 | x = llround((F32)x * LLUI::sGLScaleFactor.mV[VX]); | ||
185 | y = llround((F32)y * LLUI::sGLScaleFactor.mV[VY]); | ||
186 | |||
187 | BOOL deselect = (mask == MASK_CONTROL); | ||
188 | S32 left = llmin(x, mDragStartX); | ||
189 | S32 right = llmax(x, mDragStartX); | ||
190 | S32 top = llmax(y, mDragStartY); | ||
191 | S32 bottom =llmin(y, mDragStartY); | ||
192 | |||
193 | F32 old_far_plane = gCamera->getFar(); | ||
194 | F32 old_near_plane = gCamera->getNear(); | ||
195 | |||
196 | S32 width = right - left + 1; | ||
197 | S32 height = top - bottom + 1; | ||
198 | |||
199 | BOOL grow_selection = FALSE; | ||
200 | BOOL shrink_selection = FALSE; | ||
201 | |||
202 | if (height > mDragLastHeight || width > mDragLastWidth) | ||
203 | { | ||
204 | grow_selection = TRUE; | ||
205 | } | ||
206 | if (height < mDragLastHeight || width < mDragLastWidth) | ||
207 | { | ||
208 | shrink_selection = TRUE; | ||
209 | } | ||
210 | |||
211 | if (!grow_selection && !shrink_selection) | ||
212 | { | ||
213 | // nothing to do | ||
214 | return; | ||
215 | } | ||
216 | |||
217 | mDragLastHeight = height; | ||
218 | mDragLastWidth = width; | ||
219 | |||
220 | S32 center_x = (left + right) / 2; | ||
221 | S32 center_y = (top + bottom) / 2; | ||
222 | |||
223 | // save drawing mode | ||
224 | glMatrixMode(GL_PROJECTION); | ||
225 | glPushMatrix(); | ||
226 | |||
227 | BOOL limit_select_distance = gSavedSettings.getBOOL("LimitSelectDistance"); | ||
228 | if (limit_select_distance) | ||
229 | { | ||
230 | // ...select distance from control | ||
231 | LLVector3 relative_av_pos = av_pos; | ||
232 | relative_av_pos -= gCamera->getOrigin(); | ||
233 | |||
234 | F32 new_far = relative_av_pos * gCamera->getAtAxis() + gSavedSettings.getF32("MaxSelectDistance"); | ||
235 | F32 new_near = relative_av_pos * gCamera->getAtAxis() - gSavedSettings.getF32("MaxSelectDistance"); | ||
236 | |||
237 | new_near = llmax(new_near, 0.1f); | ||
238 | |||
239 | gCamera->setFar(new_far); | ||
240 | gCamera->setNear(new_near); | ||
241 | } | ||
242 | gCamera->setPerspective(FOR_SELECTION, | ||
243 | center_x-width/2, center_y-height/2, width, height, | ||
244 | limit_select_distance); | ||
245 | |||
246 | if (shrink_selection) | ||
247 | { | ||
248 | for (LLViewerObject* vobjp = gSelectMgr->getFirstHighlightedObject(); | ||
249 | vobjp; | ||
250 | vobjp = gSelectMgr->getNextHighlightedObject()) | ||
251 | { | ||
252 | LLDrawable* drawable = vobjp->mDrawable; | ||
253 | if (!drawable || vobjp->getPCode() != LL_PCODE_VOLUME || vobjp->isAttachment()) | ||
254 | { | ||
255 | continue; | ||
256 | } | ||
257 | |||
258 | S32 result = gCamera->sphereInFrustum(drawable->getWorldPosition(), drawable->getRadius()); | ||
259 | switch (result) | ||
260 | { | ||
261 | case 0: | ||
262 | gSelectMgr->unhighlightObjectOnly(vobjp); | ||
263 | break; | ||
264 | case 1: | ||
265 | // check vertices | ||
266 | if (!gCamera->areVertsVisible(vobjp, LLSelectMgr::sRectSelectInclusive)) | ||
267 | { | ||
268 | gSelectMgr->unhighlightObjectOnly(vobjp); | ||
269 | } | ||
270 | break; | ||
271 | default: | ||
272 | break; | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | |||
277 | if (grow_selection) | ||
278 | { | ||
279 | std::vector<LLDrawable*> potentials; | ||
280 | |||
281 | if (gPipeline.mObjectPartition) | ||
282 | { | ||
283 | gPipeline.mObjectPartition->cull(*gCamera, &potentials, TRUE); | ||
284 | } | ||
285 | |||
286 | for (std::vector<LLDrawable*>::iterator iter = potentials.begin(); | ||
287 | iter != potentials.end(); iter++) | ||
288 | { | ||
289 | LLDrawable* drawable = *iter; | ||
290 | LLViewerObject* vobjp = drawable->getVObj(); | ||
291 | |||
292 | if (!drawable || !vobjp || | ||
293 | vobjp->getPCode() != LL_PCODE_VOLUME || | ||
294 | vobjp->isAttachment() || | ||
295 | (deselect && !vobjp->isSelected())) | ||
296 | { | ||
297 | continue; | ||
298 | } | ||
299 | |||
300 | if (limit_select_distance && dist_vec_squared(drawable->getWorldPosition(), av_pos) > select_dist_squared) | ||
301 | { | ||
302 | continue; | ||
303 | } | ||
304 | |||
305 | S32 result = gCamera->sphereInFrustum(drawable->getWorldPosition(), drawable->getRadius()); | ||
306 | if (result) | ||
307 | { | ||
308 | switch (result) | ||
309 | { | ||
310 | case 1: | ||
311 | // check vertices | ||
312 | if (gCamera->areVertsVisible(vobjp, LLSelectMgr::sRectSelectInclusive)) | ||
313 | { | ||
314 | gSelectMgr->highlightObjectOnly(vobjp); | ||
315 | } | ||
316 | break; | ||
317 | case 2: | ||
318 | gSelectMgr->highlightObjectOnly(vobjp); | ||
319 | break; | ||
320 | default: | ||
321 | break; | ||
322 | } | ||
323 | } | ||
324 | } | ||
325 | } | ||
326 | |||
327 | // restore drawing mode | ||
328 | glMatrixMode(GL_PROJECTION); | ||
329 | glPopMatrix(); | ||
330 | glMatrixMode(GL_MODELVIEW); | ||
331 | |||
332 | // restore camera | ||
333 | gCamera->setFar(old_far_plane); | ||
334 | gCamera->setNear(old_near_plane); | ||
335 | gViewerWindow->setup3DRender(); | ||
336 | } | ||
337 | |||
338 | |||
339 | const F32 COMPASS_SIZE = 64; | ||
340 | static const F32 COMPASS_RANGE = 0.33f; | ||
341 | |||
342 | void LLCompass::draw() | ||
343 | { | ||
344 | // S32 left, top, right, bottom; | ||
345 | |||
346 | if (!getVisible()) return; | ||
347 | |||
348 | glMatrixMode(GL_MODELVIEW); | ||
349 | glPushMatrix(); | ||
350 | |||
351 | S32 width = 32; | ||
352 | S32 height = 32; | ||
353 | |||
354 | LLGLSUIDefault gls_ui; | ||
355 | |||
356 | glTranslatef( COMPASS_SIZE/2.f, COMPASS_SIZE/2.f, 0.f); | ||
357 | |||
358 | if (mBkgndTexture) | ||
359 | { | ||
360 | mBkgndTexture->bind(); | ||
361 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | ||
362 | |||
363 | glBegin(GL_QUADS); | ||
364 | |||
365 | glTexCoord2f(1.f, 1.f); | ||
366 | glVertex2i(width, height); | ||
367 | |||
368 | glTexCoord2f(0.f, 1.f); | ||
369 | glVertex2i(-width, height); | ||
370 | |||
371 | glTexCoord2f(0.f, 0.f); | ||
372 | glVertex2i(-width, -height); | ||
373 | |||
374 | glTexCoord2f(1.f, 0.f); | ||
375 | glVertex2i(width, -height); | ||
376 | |||
377 | glEnd(); | ||
378 | } | ||
379 | |||
380 | // rotate subsequent draws to agent rotation | ||
381 | F32 rotation = atan2( gAgent.getFrameAgent().getAtAxis().mV[VX], gAgent.getFrameAgent().getAtAxis().mV[VY] ); | ||
382 | glRotatef( - rotation * RAD_TO_DEG, 0.f, 0.f, -1.f); | ||
383 | |||
384 | if (mTexture) | ||
385 | { | ||
386 | mTexture->bind(); | ||
387 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | ||
388 | |||
389 | glBegin(GL_QUADS); | ||
390 | |||
391 | glTexCoord2f(1.f, 1.f); | ||
392 | glVertex2i(width, height); | ||
393 | |||
394 | glTexCoord2f(0.f, 1.f); | ||
395 | glVertex2i(-width, height); | ||
396 | |||
397 | glTexCoord2f(0.f, 0.f); | ||
398 | glVertex2i(-width, -height); | ||
399 | |||
400 | glTexCoord2f(1.f, 0.f); | ||
401 | glVertex2i(width, -height); | ||
402 | |||
403 | glEnd(); | ||
404 | } | ||
405 | |||
406 | glPopMatrix(); | ||
407 | |||
408 | } | ||
409 | |||
410 | |||
411 | |||
412 | void LLHorizontalCompass::draw() | ||
413 | { | ||
414 | if (!getVisible()) return; | ||
415 | |||
416 | LLGLSUIDefault gls_ui; | ||
417 | |||
418 | S32 width = mRect.getWidth(); | ||
419 | S32 height = mRect.getHeight(); | ||
420 | S32 half_width = width / 2; | ||
421 | |||
422 | if( mTexture ) | ||
423 | { | ||
424 | const LLVector3& at_axis = gCamera->getAtAxis(); | ||
425 | F32 center = atan2( at_axis.mV[VX], at_axis.mV[VY] ); | ||
426 | |||
427 | center += F_PI; | ||
428 | center = llclamp( center, 0.0f, F_TWO_PI ); // probably not necessary... | ||
429 | center /= F_TWO_PI; | ||
430 | F32 left = center - COMPASS_RANGE; | ||
431 | F32 right = center + COMPASS_RANGE; | ||
432 | |||
433 | mTexture->bind(); | ||
434 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f ); | ||
435 | glBegin( GL_QUADS ); | ||
436 | |||
437 | glTexCoord2f(right, 1.f); | ||
438 | glVertex2i(width, height); | ||
439 | |||
440 | glTexCoord2f(left, 1.f); | ||
441 | glVertex2i(0, height); | ||
442 | |||
443 | glTexCoord2f(left, 0.f); | ||
444 | glVertex2i(0, 0); | ||
445 | |||
446 | glTexCoord2f(right, 0.f); | ||
447 | glVertex2i(width, 0); | ||
448 | |||
449 | glEnd(); | ||
450 | } | ||
451 | |||
452 | // Draw the focus line | ||
453 | { | ||
454 | LLGLSNoTexture gls_no_texture; | ||
455 | glColor4fv( mFocusColor.mV ); | ||
456 | gl_line_2d( half_width, 0, half_width, height ); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | |||
461 | const F32 WIND_ALTITUDE = 180.f; | ||
462 | |||
463 | |||
464 | void LLWind::renderVectors() | ||
465 | { | ||
466 | // Renders the wind as vectors (used for debug) | ||
467 | S32 i,j; | ||
468 | F32 x,y; | ||
469 | |||
470 | F32 region_width_meters = gWorldPointer->getRegionWidthInMeters(); | ||
471 | |||
472 | LLGLSNoTexture gls_no_texture; | ||
473 | glPushMatrix(); | ||
474 | LLVector3 origin_agent; | ||
475 | origin_agent = gAgent.getPosAgentFromGlobal(mOriginGlobal); | ||
476 | glTranslatef(origin_agent.mV[VX], origin_agent.mV[VY], WIND_ALTITUDE); | ||
477 | for (j = 0; j < mSize; j++) | ||
478 | { | ||
479 | for (i = 0; i < mSize; i++) | ||
480 | { | ||
481 | x = mCloudVelX[i + j*mSize] * WIND_SCALE_HACK; | ||
482 | y = mCloudVelY[i + j*mSize] * WIND_SCALE_HACK; | ||
483 | glPushMatrix(); | ||
484 | glTranslatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.0); | ||
485 | glColor3f(0,1,0); | ||
486 | glBegin(GL_POINTS); | ||
487 | glVertex3f(0,0,0); | ||
488 | glEnd(); | ||
489 | glColor3f(1,0,0); | ||
490 | glBegin(GL_LINES); | ||
491 | glVertex3f(x * 0.1f, y * 0.1f ,0.f); | ||
492 | glVertex3f(x, y, 0.f); | ||
493 | glEnd(); | ||
494 | glPopMatrix(); | ||
495 | } | ||
496 | } | ||
497 | glPopMatrix(); | ||
498 | } | ||
499 | |||
500 | |||
501 | |||
502 | |||
503 | // Used by lltoolselectland | ||
504 | void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, | ||
505 | const LLVector3d &east_north_top_global ) | ||
506 | { | ||
507 | LLGLSUIDefault gls_ui; | ||
508 | LLGLSNoTexture gls_no_texture; | ||
509 | LLGLDepthTest gls_depth(GL_TRUE); | ||
510 | |||
511 | LLVector3 west_south_bottom_agent = gAgent.getPosAgentFromGlobal(west_south_bottom_global); | ||
512 | F32 west = west_south_bottom_agent.mV[VX]; | ||
513 | F32 south = west_south_bottom_agent.mV[VY]; | ||
514 | // F32 bottom = west_south_bottom_agent.mV[VZ] - 1.f; | ||
515 | |||
516 | LLVector3 east_north_top_agent = gAgent.getPosAgentFromGlobal(east_north_top_global); | ||
517 | F32 east = east_north_top_agent.mV[VX]; | ||
518 | F32 north = east_north_top_agent.mV[VY]; | ||
519 | // F32 top = east_north_top_agent.mV[VZ] + 1.f; | ||
520 | |||
521 | // HACK: At edge of last region of world, we need to make sure the region | ||
522 | // resolves correctly so we can get a height value. | ||
523 | const F32 FUDGE = 0.01f; | ||
524 | |||
525 | F32 sw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); | ||
526 | F32 se_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); | ||
527 | F32 ne_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); | ||
528 | F32 nw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); | ||
529 | |||
530 | F32 sw_top = sw_bottom + PARCEL_POST_HEIGHT; | ||
531 | F32 se_top = se_bottom + PARCEL_POST_HEIGHT; | ||
532 | F32 ne_top = ne_bottom + PARCEL_POST_HEIGHT; | ||
533 | F32 nw_top = nw_bottom + PARCEL_POST_HEIGHT; | ||
534 | |||
535 | LLUI::setLineWidth(2.f); | ||
536 | glColor4f(1.f, 1.f, 0.f, 1.f); | ||
537 | |||
538 | // Cheat and give this the same pick-name as land | ||
539 | glBegin(GL_LINES); | ||
540 | |||
541 | glVertex3f(west, north, nw_bottom); | ||
542 | glVertex3f(west, north, nw_top); | ||
543 | |||
544 | glVertex3f(east, north, ne_bottom); | ||
545 | glVertex3f(east, north, ne_top); | ||
546 | |||
547 | glVertex3f(east, south, se_bottom); | ||
548 | glVertex3f(east, south, se_top); | ||
549 | |||
550 | glVertex3f(west, south, sw_bottom); | ||
551 | glVertex3f(west, south, sw_top); | ||
552 | |||
553 | glEnd(); | ||
554 | |||
555 | glColor4f(1.f, 1.f, 0.f, 0.2f); | ||
556 | glBegin(GL_QUADS); | ||
557 | |||
558 | glVertex3f(west, north, nw_bottom); | ||
559 | glVertex3f(west, north, nw_top); | ||
560 | glVertex3f(east, north, ne_top); | ||
561 | glVertex3f(east, north, ne_bottom); | ||
562 | |||
563 | glVertex3f(east, north, ne_bottom); | ||
564 | glVertex3f(east, north, ne_top); | ||
565 | glVertex3f(east, south, se_top); | ||
566 | glVertex3f(east, south, se_bottom); | ||
567 | |||
568 | glVertex3f(east, south, se_bottom); | ||
569 | glVertex3f(east, south, se_top); | ||
570 | glVertex3f(west, south, sw_top); | ||
571 | glVertex3f(west, south, sw_bottom); | ||
572 | |||
573 | glVertex3f(west, south, sw_bottom); | ||
574 | glVertex3f(west, south, sw_top); | ||
575 | glVertex3f(west, north, nw_top); | ||
576 | glVertex3f(west, north, nw_bottom); | ||
577 | |||
578 | glEnd(); | ||
579 | |||
580 | LLUI::setLineWidth(1.f); | ||
581 | } | ||
582 | |||
583 | /* | ||
584 | void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) | ||
585 | { | ||
586 | S32 i; | ||
587 | S32 count = parcel->getBoxCount(); | ||
588 | for (i = 0; i < count; i++) | ||
589 | { | ||
590 | const LLParcelBox& box = parcel->getBox(i); | ||
591 | |||
592 | F32 west = box.mMin.mV[VX]; | ||
593 | F32 south = box.mMin.mV[VY]; | ||
594 | |||
595 | F32 east = box.mMax.mV[VX]; | ||
596 | F32 north = box.mMax.mV[VY]; | ||
597 | |||
598 | // HACK: At edge of last region of world, we need to make sure the region | ||
599 | // resolves correctly so we can get a height value. | ||
600 | const F32 FUDGE = 0.01f; | ||
601 | |||
602 | F32 sw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); | ||
603 | F32 se_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); | ||
604 | F32 ne_bottom = gWorldp->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); | ||
605 | F32 nw_bottom = gWorldp->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); | ||
606 | |||
607 | // little hack to make nearby lines not Z-fight | ||
608 | east -= 0.1f; | ||
609 | north -= 0.1f; | ||
610 | |||
611 | F32 sw_top = sw_bottom + POST_HEIGHT; | ||
612 | F32 se_top = se_bottom + POST_HEIGHT; | ||
613 | F32 ne_top = ne_bottom + POST_HEIGHT; | ||
614 | F32 nw_top = nw_bottom + POST_HEIGHT; | ||
615 | |||
616 | LLGLSNoTexture gls_no_texture; | ||
617 | LLGLDepthTest gls_depth(GL_TRUE); | ||
618 | |||
619 | LLUI::setLineWidth(2.f); | ||
620 | glColor4f(0.f, 1.f, 1.f, 1.f); | ||
621 | |||
622 | // Cheat and give this the same pick-name as land | ||
623 | glBegin(GL_LINES); | ||
624 | |||
625 | glVertex3f(west, north, nw_bottom); | ||
626 | glVertex3f(west, north, nw_top); | ||
627 | |||
628 | glVertex3f(east, north, ne_bottom); | ||
629 | glVertex3f(east, north, ne_top); | ||
630 | |||
631 | glVertex3f(east, south, se_bottom); | ||
632 | glVertex3f(east, south, se_top); | ||
633 | |||
634 | glVertex3f(west, south, sw_bottom); | ||
635 | glVertex3f(west, south, sw_top); | ||
636 | |||
637 | glEnd(); | ||
638 | |||
639 | glColor4f(0.f, 1.f, 1.f, 0.2f); | ||
640 | glBegin(GL_QUADS); | ||
641 | |||
642 | glVertex3f(west, north, nw_bottom); | ||
643 | glVertex3f(west, north, nw_top); | ||
644 | glVertex3f(east, north, ne_top); | ||
645 | glVertex3f(east, north, ne_bottom); | ||
646 | |||
647 | glVertex3f(east, north, ne_bottom); | ||
648 | glVertex3f(east, north, ne_top); | ||
649 | glVertex3f(east, south, se_top); | ||
650 | glVertex3f(east, south, se_bottom); | ||
651 | |||
652 | glVertex3f(east, south, se_bottom); | ||
653 | glVertex3f(east, south, se_top); | ||
654 | glVertex3f(west, south, sw_top); | ||
655 | glVertex3f(west, south, sw_bottom); | ||
656 | |||
657 | glVertex3f(west, south, sw_bottom); | ||
658 | glVertex3f(west, south, sw_top); | ||
659 | glVertex3f(west, north, nw_top); | ||
660 | glVertex3f(west, north, nw_bottom); | ||
661 | |||
662 | glEnd(); | ||
663 | |||
664 | LLUI::setLineWidth(1.f); | ||
665 | } | ||
666 | } | ||
667 | */ | ||
668 | |||
669 | |||
670 | // north = a wall going north/south. Need that info to set up texture | ||
671 | // coordinates correctly. | ||
672 | void LLViewerParcelMgr::renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 height, U8 direction, LLViewerRegion* regionp) | ||
673 | { | ||
674 | // HACK: At edge of last region of world, we need to make sure the region | ||
675 | // resolves correctly so we can get a height value. | ||
676 | const F32 BORDER = REGION_WIDTH_METERS - 0.1f; | ||
677 | |||
678 | F32 clamped_x1 = x1; | ||
679 | F32 clamped_y1 = y1; | ||
680 | F32 clamped_x2 = x2; | ||
681 | F32 clamped_y2 = y2; | ||
682 | |||
683 | if (clamped_x1 > BORDER) clamped_x1 = BORDER; | ||
684 | if (clamped_y1 > BORDER) clamped_y1 = BORDER; | ||
685 | if (clamped_x2 > BORDER) clamped_x2 = BORDER; | ||
686 | if (clamped_y2 > BORDER) clamped_y2 = BORDER; | ||
687 | |||
688 | F32 z; | ||
689 | F32 z1; | ||
690 | F32 z2; | ||
691 | |||
692 | z1 = regionp->getLand().resolveHeightRegion( LLVector3( clamped_x1, clamped_y1, 0.f ) ); | ||
693 | z2 = regionp->getLand().resolveHeightRegion( LLVector3( clamped_x2, clamped_y2, 0.f ) ); | ||
694 | |||
695 | // Convert x1 and x2 from region-local to agent coords. | ||
696 | LLVector3 origin = regionp->getOriginAgent(); | ||
697 | x1 += origin.mV[VX]; | ||
698 | x2 += origin.mV[VX]; | ||
699 | y1 += origin.mV[VY]; | ||
700 | y2 += origin.mV[VY]; | ||
701 | |||
702 | if (height < 1.f) | ||
703 | { | ||
704 | z = z1+height; | ||
705 | glVertex3f(x1, y1, z); | ||
706 | |||
707 | glVertex3f(x1, y1, z1); | ||
708 | |||
709 | glVertex3f(x2, y2, z2); | ||
710 | |||
711 | z = z2+height; | ||
712 | glVertex3f(x2, y2, z); | ||
713 | } | ||
714 | else | ||
715 | { | ||
716 | F32 tex_coord1; | ||
717 | F32 tex_coord2; | ||
718 | |||
719 | if (WEST_MASK == direction) | ||
720 | { | ||
721 | tex_coord1 = y1; | ||
722 | tex_coord2 = y2; | ||
723 | } | ||
724 | else if (SOUTH_MASK == direction) | ||
725 | { | ||
726 | tex_coord1 = x1; | ||
727 | tex_coord2 = x2; | ||
728 | } | ||
729 | else if (EAST_MASK == direction) | ||
730 | { | ||
731 | tex_coord1 = y2; | ||
732 | tex_coord2 = y1; | ||
733 | } | ||
734 | else /* (NORTH_MASK == direction) */ | ||
735 | { | ||
736 | tex_coord1 = x2; | ||
737 | tex_coord2 = x1; | ||
738 | } | ||
739 | |||
740 | |||
741 | glTexCoord2f(tex_coord1*0.5f+0.5f, z1*0.5f); | ||
742 | glVertex3f(x1, y1, z1); | ||
743 | |||
744 | glTexCoord2f(tex_coord2*0.5f+0.5f, z2*0.5f); | ||
745 | glVertex3f(x2, y2, z2); | ||
746 | |||
747 | // top edge stairsteps | ||
748 | z = llmax(z2+height, z1+height); | ||
749 | glTexCoord2f(tex_coord2*0.5f+0.5f, z*0.5f); | ||
750 | glVertex3f(x2, y2, z); | ||
751 | |||
752 | glTexCoord2f(tex_coord1*0.5f+0.5f, z*0.5f); | ||
753 | glVertex3f(x1, y1, z); | ||
754 | } | ||
755 | } | ||
756 | |||
757 | |||
758 | void LLViewerParcelMgr::renderHighlightSegments(const U8* segments, LLViewerRegion* regionp) | ||
759 | { | ||
760 | S32 x, y; | ||
761 | F32 x1, y1; // start point | ||
762 | F32 x2, y2; // end point | ||
763 | |||
764 | LLGLSUIDefault gls_ui; | ||
765 | LLGLSNoTexture gls_no_texture; | ||
766 | LLGLDepthTest gls_depth(GL_TRUE); | ||
767 | |||
768 | glColor4f(1.f, 1.f, 0.f, 0.2f); | ||
769 | |||
770 | // Cheat and give this the same pick-name as land | ||
771 | glBegin(GL_QUADS); | ||
772 | |||
773 | const S32 STRIDE = (mParcelsPerEdge+1); | ||
774 | for (y = 0; y < STRIDE; y++) | ||
775 | { | ||
776 | for (x = 0; x < STRIDE; x++) | ||
777 | { | ||
778 | U8 segment_mask = segments[x + y*STRIDE]; | ||
779 | |||
780 | if (segment_mask & SOUTH_MASK) | ||
781 | { | ||
782 | x1 = x * PARCEL_GRID_STEP_METERS; | ||
783 | y1 = y * PARCEL_GRID_STEP_METERS; | ||
784 | |||
785 | x2 = x1 + PARCEL_GRID_STEP_METERS; | ||
786 | y2 = y1; | ||
787 | |||
788 | renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, SOUTH_MASK, regionp); | ||
789 | } | ||
790 | |||
791 | if (segment_mask & WEST_MASK) | ||
792 | { | ||
793 | x1 = x * PARCEL_GRID_STEP_METERS; | ||
794 | y1 = y * PARCEL_GRID_STEP_METERS; | ||
795 | |||
796 | x2 = x1; | ||
797 | y2 = y1 + PARCEL_GRID_STEP_METERS; | ||
798 | |||
799 | renderOneSegment(x1, y1, x2, y2, PARCEL_POST_HEIGHT, WEST_MASK, regionp); | ||
800 | } | ||
801 | } | ||
802 | } | ||
803 | |||
804 | glEnd(); | ||
805 | } | ||
806 | |||
807 | |||
808 | void LLViewerParcelMgr::renderCollisionSegments(U8* segments, BOOL use_pass, LLViewerRegion* regionp) | ||
809 | { | ||
810 | |||
811 | S32 x, y; | ||
812 | F32 x1, y1; // start point | ||
813 | F32 x2, y2; // end point | ||
814 | F32 alpha = 0; | ||
815 | F32 dist = 0; | ||
816 | F32 dx, dy; | ||
817 | F32 collision_height; | ||
818 | |||
819 | const S32 STRIDE = (mParcelsPerEdge+1); | ||
820 | |||
821 | LLVector3 pos = gAgent.getPositionAgent(); | ||
822 | |||
823 | F32 pos_x = pos.mV[VX]; | ||
824 | F32 pos_y = pos.mV[VY]; | ||
825 | |||
826 | LLGLSUIDefault gls_ui; | ||
827 | LLGLDepthTest gls_depth(GL_TRUE); | ||
828 | LLGLDisable cull(GL_CULL_FACE); | ||
829 | |||
830 | if (mCollisionBanned == BA_BANNED) | ||
831 | { | ||
832 | collision_height = BAN_HEIGHT; | ||
833 | } | ||
834 | else | ||
835 | { | ||
836 | collision_height = PARCEL_HEIGHT; | ||
837 | } | ||
838 | |||
839 | |||
840 | if (use_pass && (mCollisionBanned == BA_NOT_ON_LIST)) | ||
841 | { | ||
842 | LLViewerImage::bindTexture(mPassImage); | ||
843 | } | ||
844 | else | ||
845 | { | ||
846 | LLViewerImage::bindTexture(mBlockedImage); | ||
847 | } | ||
848 | |||
849 | glBegin(GL_QUADS); | ||
850 | |||
851 | for (y = 0; y < STRIDE; y++) | ||
852 | { | ||
853 | for (x = 0; x < STRIDE; x++) | ||
854 | { | ||
855 | U8 segment_mask = segments[x + y*STRIDE]; | ||
856 | U8 direction; | ||
857 | const F32 MAX_ALPHA = 0.95f; | ||
858 | const S32 DIST_OFFSET = 5; | ||
859 | const S32 MIN_DIST_SQ = DIST_OFFSET*DIST_OFFSET; | ||
860 | const S32 MAX_DIST_SQ = 169; | ||
861 | |||
862 | if (segment_mask & SOUTH_MASK) | ||
863 | { | ||
864 | x1 = x * PARCEL_GRID_STEP_METERS; | ||
865 | y1 = y * PARCEL_GRID_STEP_METERS; | ||
866 | |||
867 | x2 = x1 + PARCEL_GRID_STEP_METERS; | ||
868 | y2 = y1; | ||
869 | |||
870 | if (gRenderForSelect) | ||
871 | { | ||
872 | LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL); | ||
873 | glColor4ubv(color.mV); | ||
874 | } | ||
875 | else | ||
876 | { | ||
877 | dy = (pos_y - y1) + DIST_OFFSET; | ||
878 | |||
879 | if (pos_x < x1) | ||
880 | dx = pos_x - x1; | ||
881 | else if (pos_x > x2) | ||
882 | dx = pos_x - x2; | ||
883 | else | ||
884 | dx = 0; | ||
885 | |||
886 | dist = dx*dx+dy*dy; | ||
887 | |||
888 | if (dist < MIN_DIST_SQ) | ||
889 | alpha = MAX_ALPHA; | ||
890 | else if (dist > MAX_DIST_SQ) | ||
891 | alpha = 0.0f; | ||
892 | else | ||
893 | alpha = 30/dist; | ||
894 | |||
895 | alpha = llclamp(alpha, 0.0f, MAX_ALPHA); | ||
896 | |||
897 | glColor4f(1.f, 1.f, 1.f, alpha); | ||
898 | } | ||
899 | |||
900 | if ((pos_y - y1) < 0) direction = SOUTH_MASK; | ||
901 | else direction = NORTH_MASK; | ||
902 | |||
903 | // avoid Z fighting | ||
904 | renderOneSegment(x1+0.1f, y1+0.1f, x2+0.1f, y2+0.1f, collision_height, direction, regionp); | ||
905 | |||
906 | } | ||
907 | |||
908 | if (segment_mask & WEST_MASK) | ||
909 | { | ||
910 | x1 = x * PARCEL_GRID_STEP_METERS; | ||
911 | y1 = y * PARCEL_GRID_STEP_METERS; | ||
912 | |||
913 | x2 = x1; | ||
914 | y2 = y1 + PARCEL_GRID_STEP_METERS; | ||
915 | |||
916 | if (gRenderForSelect) | ||
917 | { | ||
918 | LLColor4U color((U8)(GL_NAME_PARCEL_WALL >> 16), (U8)(GL_NAME_PARCEL_WALL >> 8), (U8)GL_NAME_PARCEL_WALL); | ||
919 | glColor4ubv(color.mV); | ||
920 | } | ||
921 | else | ||
922 | { | ||
923 | dx = (pos_x - x1) + DIST_OFFSET; | ||
924 | |||
925 | if (pos_y < y1) | ||
926 | dy = pos_y - y1; | ||
927 | else if (pos_y > y2) | ||
928 | dy = pos_y - y2; | ||
929 | else | ||
930 | dy = 0; | ||
931 | |||
932 | dist = dx*dx+dy*dy; | ||
933 | |||
934 | if (dist < MIN_DIST_SQ) | ||
935 | alpha = MAX_ALPHA; | ||
936 | else if (dist > MAX_DIST_SQ) | ||
937 | alpha = 0.0f; | ||
938 | else | ||
939 | alpha = 30/dist; | ||
940 | |||
941 | alpha = llclamp(alpha, 0.0f, MAX_ALPHA); | ||
942 | |||
943 | glColor4f(1.f, 1.f, 1.f, alpha); | ||
944 | } | ||
945 | |||
946 | if ((pos_x - x1) > 0) direction = WEST_MASK; | ||
947 | else direction = EAST_MASK; | ||
948 | |||
949 | // avoid Z fighting | ||
950 | renderOneSegment(x1+0.1f, y1+0.1f, x2+0.1f, y2+0.1f, collision_height, direction, regionp); | ||
951 | |||
952 | } | ||
953 | } | ||
954 | } | ||
955 | |||
956 | glEnd(); | ||
957 | } | ||
958 | |||
959 | |||
960 | const S32 CLIENT_RECT_VPAD = 4; | ||
961 | void LLPreviewTexture::draw() | ||
962 | { | ||
963 | if( getVisible() ) | ||
964 | { | ||
965 | updateAspectRatio(); | ||
966 | |||
967 | LLPreview::draw(); | ||
968 | |||
969 | if (!mMinimized) | ||
970 | { | ||
971 | LLGLSUIDefault gls_ui; | ||
972 | LLGLSNoTexture gls_notex; | ||
973 | |||
974 | const LLRect& border = mClientRect; | ||
975 | LLRect interior = mClientRect; | ||
976 | interior.stretch( -PREVIEW_BORDER_WIDTH ); | ||
977 | |||
978 | // ...border | ||
979 | gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f)); | ||
980 | gl_rect_2d_checkerboard( interior ); | ||
981 | |||
982 | if ( mImage.notNull() ) | ||
983 | { | ||
984 | LLGLSTexture gls_no_texture; | ||
985 | // Draw the texture | ||
986 | glColor3f( 1.f, 1.f, 1.f ); | ||
987 | gl_draw_scaled_image(interior.mLeft, | ||
988 | interior.mBottom, | ||
989 | interior.getWidth(), | ||
990 | interior.getHeight(), | ||
991 | mImage); | ||
992 | |||
993 | // Pump the texture priority | ||
994 | F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() ); | ||
995 | mImage->addTextureStats( pixel_area ); | ||
996 | |||
997 | // Don't bother decoding more than we can display, unless | ||
998 | // we're loading the full image. | ||
999 | if (!mLoadingFullImage) | ||
1000 | { | ||
1001 | S32 int_width = interior.getWidth(); | ||
1002 | S32 int_height = interior.getHeight(); | ||
1003 | mImage->setKnownDrawSize(int_width, int_height); | ||
1004 | } | ||
1005 | else | ||
1006 | { | ||
1007 | // Don't use this feature | ||
1008 | mImage->setKnownDrawSize(0, 0); | ||
1009 | } | ||
1010 | |||
1011 | if( mLoadingFullImage ) | ||
1012 | { | ||
1013 | LLFontGL::sSansSerif->renderUTF8("Receiving:", 0, | ||
1014 | interior.mLeft + 4, | ||
1015 | interior.mBottom + 4, | ||
1016 | LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, | ||
1017 | LLFontGL::DROP_SHADOW); | ||
1018 | |||
1019 | F32 data_progress = 0.0f; | ||
1020 | F32 decode_progress = mImage->getDecodeProgress(&data_progress); | ||
1021 | |||
1022 | // Draw the progress bar. | ||
1023 | const S32 BAR_HEIGHT = 12; | ||
1024 | const S32 BAR_LEFT_PAD = 80; | ||
1025 | S32 left = interior.mLeft + 4 + BAR_LEFT_PAD; | ||
1026 | S32 bar_width = mRect.getWidth() - left - RESIZE_HANDLE_WIDTH - 2; | ||
1027 | S32 top = interior.mBottom + 4 + BAR_HEIGHT; | ||
1028 | S32 right = left + bar_width; | ||
1029 | S32 bottom = top - BAR_HEIGHT; | ||
1030 | |||
1031 | LLColor4 background_color(0.f, 0.f, 0.f, 0.75f); | ||
1032 | LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f); | ||
1033 | LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f); | ||
1034 | |||
1035 | gl_rect_2d(left, top, right, bottom, background_color); | ||
1036 | |||
1037 | if (data_progress > 0.0f) | ||
1038 | { | ||
1039 | // Decoded bytes | ||
1040 | right = left + llfloor(decode_progress * (F32)bar_width); | ||
1041 | |||
1042 | if (left < right) | ||
1043 | { | ||
1044 | gl_rect_2d(left, top, right, bottom, decoded_color); | ||
1045 | } | ||
1046 | |||
1047 | // Downloaded bytes | ||
1048 | left = right; | ||
1049 | right = left + llfloor((data_progress - decode_progress) * (F32)bar_width); | ||
1050 | |||
1051 | if (left < right) | ||
1052 | { | ||
1053 | gl_rect_2d(left, top, right, bottom, downloaded_color); | ||
1054 | } | ||
1055 | } | ||
1056 | } | ||
1057 | else | ||
1058 | if( !mSavedFileTimer.hasExpired() ) | ||
1059 | { | ||
1060 | LLFontGL::sSansSerif->renderUTF8("File Saved", 0, | ||
1061 | interior.mLeft + 4, | ||
1062 | interior.mBottom + 4, | ||
1063 | LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, | ||
1064 | LLFontGL::DROP_SHADOW); | ||
1065 | } | ||
1066 | } | ||
1067 | } | ||
1068 | } | ||
1069 | } | ||
1070 | |||
1071 | |||
1072 | void draw_line_cube(F32 width, const LLVector3& center) | ||
1073 | { | ||
1074 | width = 0.5f * width; | ||
1075 | glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width); | ||
1076 | glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width); | ||
1077 | glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width); | ||
1078 | glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width); | ||
1079 | glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width); | ||
1080 | glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width); | ||
1081 | glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width); | ||
1082 | glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width); | ||
1083 | |||
1084 | glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width); | ||
1085 | glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width); | ||
1086 | glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width); | ||
1087 | glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width); | ||
1088 | glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width); | ||
1089 | glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width); | ||
1090 | glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width); | ||
1091 | glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width); | ||
1092 | |||
1093 | glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] + width); | ||
1094 | glVertex3f(center.mV[VX] + width ,center.mV[VY] + width,center.mV[VZ] - width); | ||
1095 | glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] + width); | ||
1096 | glVertex3f(center.mV[VX] - width ,center.mV[VY] + width,center.mV[VZ] - width); | ||
1097 | glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width); | ||
1098 | glVertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width); | ||
1099 | glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width); | ||
1100 | glVertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width); | ||
1101 | } | ||
1102 | |||
1103 | |||
1104 | void LLViewerObjectList::renderObjectBeacons() | ||
1105 | { | ||
1106 | S32 i; | ||
1107 | //const LLFontGL *font = gResMgr->getRes(LLFONT_SANSSERIF); | ||
1108 | |||
1109 | LLGLSUIDefault gls_ui; | ||
1110 | |||
1111 | S32 last_line_width = -1; | ||
1112 | |||
1113 | { | ||
1114 | LLGLSNoTexture gls_ui_no_texture; | ||
1115 | glBegin(GL_LINES); | ||
1116 | for (i = 0; i < mDebugBeacons.count(); i++) | ||
1117 | { | ||
1118 | const LLDebugBeacon &debug_beacon = mDebugBeacons[i]; | ||
1119 | LLColor4 color = debug_beacon.mColor; | ||
1120 | color.mV[3] *= 0.25f; | ||
1121 | S32 line_width = debug_beacon.mLineWidth; | ||
1122 | if (line_width != last_line_width) | ||
1123 | { | ||
1124 | glEnd(); | ||
1125 | glLineWidth( (F32)line_width ); | ||
1126 | last_line_width = line_width; | ||
1127 | glBegin(GL_LINES); | ||
1128 | } | ||
1129 | |||
1130 | const LLVector3 &thisline = debug_beacon.mPositionAgent; | ||
1131 | glColor4fv(color.mV); | ||
1132 | glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 50.f); | ||
1133 | glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 50.f); | ||
1134 | glVertex3f(thisline.mV[VX] - 2.f,thisline.mV[VY],thisline.mV[VZ]); | ||
1135 | glVertex3f(thisline.mV[VX] + 2.f,thisline.mV[VY],thisline.mV[VZ]); | ||
1136 | glVertex3f(thisline.mV[VX],thisline.mV[VY] - 2.f,thisline.mV[VZ]); | ||
1137 | glVertex3f(thisline.mV[VX],thisline.mV[VY] + 2.f,thisline.mV[VZ]); | ||
1138 | |||
1139 | draw_line_cube(0.10f, thisline); | ||
1140 | } | ||
1141 | glEnd(); | ||
1142 | } | ||
1143 | |||
1144 | { | ||
1145 | LLGLSNoTexture gls_ui_no_texture; | ||
1146 | LLGLDepthTest gls_depth(GL_TRUE); | ||
1147 | |||
1148 | glBegin(GL_LINES); | ||
1149 | last_line_width = -1; | ||
1150 | for (i = 0; i < mDebugBeacons.count(); i++) | ||
1151 | { | ||
1152 | const LLDebugBeacon &debug_beacon = mDebugBeacons[i]; | ||
1153 | |||
1154 | S32 line_width = debug_beacon.mLineWidth; | ||
1155 | if (line_width != last_line_width) | ||
1156 | { | ||
1157 | glEnd(); | ||
1158 | glLineWidth( (F32)line_width ); | ||
1159 | last_line_width = line_width; | ||
1160 | glBegin(GL_LINES); | ||
1161 | } | ||
1162 | |||
1163 | const LLVector3 &thisline = debug_beacon.mPositionAgent; | ||
1164 | glColor4fv(debug_beacon.mColor.mV); | ||
1165 | glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 0.5f); | ||
1166 | glVertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 0.5f); | ||
1167 | glVertex3f(thisline.mV[VX] - 0.5f,thisline.mV[VY],thisline.mV[VZ]); | ||
1168 | glVertex3f(thisline.mV[VX] + 0.5f,thisline.mV[VY],thisline.mV[VZ]); | ||
1169 | glVertex3f(thisline.mV[VX],thisline.mV[VY] - 0.5f,thisline.mV[VZ]); | ||
1170 | glVertex3f(thisline.mV[VX],thisline.mV[VY] + 0.5f,thisline.mV[VZ]); | ||
1171 | |||
1172 | draw_line_cube(0.10f, thisline); | ||
1173 | } | ||
1174 | glEnd(); | ||
1175 | |||
1176 | glLineWidth(1.f); | ||
1177 | |||
1178 | for (i = 0; i < mDebugBeacons.count(); i++) | ||
1179 | { | ||
1180 | LLDebugBeacon &debug_beacon = mDebugBeacons[i]; | ||
1181 | if (debug_beacon.mString == "") | ||
1182 | { | ||
1183 | continue; | ||
1184 | } | ||
1185 | LLHUDText *hud_textp = (LLHUDText *)LLHUDObject::addHUDObject(LLHUDObject::LL_HUD_TEXT); | ||
1186 | |||
1187 | hud_textp->setZCompare(FALSE); | ||
1188 | LLColor4 color; | ||
1189 | color = debug_beacon.mTextColor; | ||
1190 | color.mV[3] *= 1.f; | ||
1191 | |||
1192 | hud_textp->setString(utf8str_to_wstring(debug_beacon.mString.c_str())); | ||
1193 | hud_textp->setColor(color); | ||
1194 | hud_textp->setPositionAgent(debug_beacon.mPositionAgent); | ||
1195 | debug_beacon.mHUDObject = hud_textp; | ||
1196 | } | ||
1197 | } | ||
1198 | } | ||
1199 | |||
1200 | |||
1201 | void pre_show_depth_buffer() | ||
1202 | { | ||
1203 | glClear(GL_STENCIL_BUFFER_BIT); | ||
1204 | glEnable(GL_STENCIL_TEST); | ||
1205 | glStencilFunc(GL_ALWAYS,0,0); | ||
1206 | glStencilOp(GL_INCR,GL_INCR,GL_INCR); | ||
1207 | } | ||
1208 | |||
1209 | void post_show_depth_buffer() | ||
1210 | { | ||
1211 | int xsize =500, ysize =500; | ||
1212 | U8 *buf = new U8[xsize*ysize]; | ||
1213 | |||
1214 | glReadPixels(0,0,xsize,ysize,GL_STENCIL_INDEX,GL_UNSIGNED_BYTE, buf); | ||
1215 | |||
1216 | int total = 0; | ||
1217 | int i; | ||
1218 | for (i=0;i<xsize*ysize;i++) | ||
1219 | { | ||
1220 | total += buf[i]; | ||
1221 | buf[i] <<= 3; | ||
1222 | } | ||
1223 | |||
1224 | float DC = (float)total/(float)(ysize*xsize); | ||
1225 | int DCline = llfloor((xsize-20) * DC / 10.0f); | ||
1226 | int stride = xsize / 10; | ||
1227 | |||
1228 | int y = 2; | ||
1229 | |||
1230 | for (i=0;i<DCline;i++) | ||
1231 | { | ||
1232 | if (i % stride == 0) i+=2; | ||
1233 | if (i > xsize) y=6; | ||
1234 | buf[ysize*(y+0)+i]=255; | ||
1235 | buf[ysize*(y+1)+i]=255; | ||
1236 | buf[ysize*(y+2)+i]=255; | ||
1237 | } | ||
1238 | glDrawPixels(xsize,ysize,GL_RED,GL_UNSIGNED_BYTE,buf); | ||
1239 | |||
1240 | delete buf; | ||
1241 | } | ||