1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
/**
* @file lltoolmorph.cpp
* @brief A tool to manipulate faces..
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2007, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlife.com/developers/opensource/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
// File includes
#include "lltoolmorph.h"
#include "llglimmediate.h"
// Library includes
#include "audioengine.h"
#include "llviewercontrol.h"
#include "llfontgl.h"
#include "sound_ids.h"
#include "v3math.h"
#include "v3color.h"
// Viewer includes
#include "llagent.h"
#include "lldrawable.h"
#include "lldrawpoolavatar.h"
#include "llface.h"
#include "llfloatercustomize.h"
#include "llmorphview.h"
#include "llresmgr.h"
#include "llselectmgr.h"
#include "llsky.h"
#include "lltexlayer.h"
#include "lltoolmgr.h"
#include "lltoolview.h"
#include "llui.h"
#include "llviewercamera.h"
#include "llviewerimagelist.h"
#include "llviewerobject.h"
#include "llviewerwindow.h"
#include "llvoavatar.h"
#include "pipeline.h"
//static
LLVisualParamHint::instance_list_t LLVisualParamHint::sInstances;
BOOL LLVisualParamReset::sDirty = FALSE;
//-----------------------------------------------------------------------------
// LLVisualParamHint()
//-----------------------------------------------------------------------------
// static
LLVisualParamHint::LLVisualParamHint(
S32 pos_x, S32 pos_y,
S32 width, S32 height,
LLViewerJointMesh *mesh,
LLViewerVisualParam *param,
F32 param_weight)
:
LLDynamicTexture(width, height, 3, LLDynamicTexture::ORDER_MIDDLE, TRUE ),
mNeedsUpdate( TRUE ),
mIsVisible( FALSE ),
mJointMesh( mesh ),
mVisualParam( param ),
mVisualParamWeight( param_weight ),
mAllowsUpdates( TRUE ),
mDelayFrames( 0 ),
mRect( pos_x, pos_y + height, pos_x + width, pos_y ),
mLastParamWeight(0.f)
{
LLVisualParamHint::sInstances.insert( this );
mBackgroundp = LLUI::getUIImage("avatar_thumb_bkgrnd.j2c");
llassert(width != 0);
llassert(height != 0);
}
//-----------------------------------------------------------------------------
// ~LLVisualParamHint()
//-----------------------------------------------------------------------------
LLVisualParamHint::~LLVisualParamHint()
{
LLVisualParamHint::sInstances.erase( this );
}
//-----------------------------------------------------------------------------
// static
// requestHintUpdates()
// Requests updates for all instances (excluding two possible exceptions) Grungy but efficient.
//-----------------------------------------------------------------------------
void LLVisualParamHint::requestHintUpdates( LLVisualParamHint* exception1, LLVisualParamHint* exception2 )
{
S32 delay_frames = 0;
for (instance_list_t::iterator iter = sInstances.begin();
iter != sInstances.end(); ++iter)
{
LLVisualParamHint* instance = *iter;
if( (instance != exception1) && (instance != exception2) )
{
if( instance->mAllowsUpdates )
{
instance->mNeedsUpdate = TRUE;
instance->mDelayFrames = delay_frames;
delay_frames++;
}
else
{
instance->mNeedsUpdate = TRUE;
instance->mDelayFrames = 0;
}
}
}
}
BOOL LLVisualParamHint::needsRender()
{
return mNeedsUpdate && mDelayFrames-- <= 0 && !gAgent.getAvatarObject()->mAppearanceAnimating && mAllowsUpdates;
}
void LLVisualParamHint::preRender(BOOL clear_depth)
{
LLVOAvatar* avatarp = gAgent.getAvatarObject();
mLastParamWeight = avatarp->getVisualParamWeight(mVisualParam);
avatarp->setVisualParamWeight(mVisualParam, mVisualParamWeight);
avatarp->setVisualParamWeight("Blink_Left", 0.f);
avatarp->setVisualParamWeight("Blink_Right", 0.f);
avatarp->updateComposites();
avatarp->updateVisualParams();
avatarp->updateGeometry(avatarp->mDrawable);
avatarp->updateLOD();
LLDynamicTexture::preRender(clear_depth);
}
//-----------------------------------------------------------------------------
// render()
//-----------------------------------------------------------------------------
BOOL LLVisualParamHint::render()
{
LLVisualParamReset::sDirty = TRUE;
LLVOAvatar* avatarp = gAgent.getAvatarObject();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
LLGLSUIDefault gls_ui;
//LLGLState::verify(TRUE);
mBackgroundp->draw(0, 0, mWidth, mHeight);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
mNeedsUpdate = FALSE;
mIsVisible = TRUE;
LLViewerJointMesh* cam_target_joint = NULL;
const std::string& cam_target_mesh_name = mVisualParam->getCameraTargetName();
if( !cam_target_mesh_name.empty() )
{
cam_target_joint = (LLViewerJointMesh*)avatarp->getJoint( cam_target_mesh_name );
}
if( !cam_target_joint )
{
cam_target_joint = (LLViewerJointMesh*)gMorphView->getCameraTargetJoint();
}
if( !cam_target_joint )
{
cam_target_joint = (LLViewerJointMesh*)avatarp->getJoint("mHead");
}
LLQuaternion avatar_rotation;
LLJoint* root_joint = avatarp->getRootJoint();
if( root_joint )
{
avatar_rotation = root_joint->getWorldRotation();
}
LLVector3 target_joint_pos = cam_target_joint->getWorldPosition();
LLVector3 target_offset( 0, 0, mVisualParam->getCameraElevation() );
LLVector3 target_pos = target_joint_pos + (target_offset * avatar_rotation);
F32 cam_angle_radians = mVisualParam->getCameraAngle() * DEG_TO_RAD;
LLVector3 camera_snapshot_offset(
mVisualParam->getCameraDistance() * cosf( cam_angle_radians ),
mVisualParam->getCameraDistance() * sinf( cam_angle_radians ),
mVisualParam->getCameraElevation() );
LLVector3 camera_pos = target_joint_pos + (camera_snapshot_offset * avatar_rotation);
gGL.stop();
LLViewerCamera::getInstance()->setAspect((F32)mWidth / (F32)mHeight);
LLViewerCamera::getInstance()->setOriginAndLookAt(
camera_pos, // camera
LLVector3(0.f, 0.f, 1.f), // up
target_pos ); // point of interest
LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE);
if (avatarp->mDrawable.notNull())
{
LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)avatarp->mDrawable->getFace(0)->getPool();
LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE);
avatarPoolp->renderAvatars(avatarp); // renders only one avatar
}
avatarp->setVisualParamWeight(mVisualParam, mLastParamWeight);
gGL.start();
return TRUE;
}
//-----------------------------------------------------------------------------
// draw()
//-----------------------------------------------------------------------------
void LLVisualParamHint::draw()
{
if (!mIsVisible) return;
bindTexture();
gGL.color4f(1.f, 1.f, 1.f, 1.f);
LLGLSUIDefault gls_ui;
gGL.begin(GL_QUADS);
{
gGL.texCoord2i(0, 1);
gGL.vertex2i(0, mHeight);
gGL.texCoord2i(0, 0);
gGL.vertex2i(0, 0);
gGL.texCoord2i(1, 0);
gGL.vertex2i(mWidth, 0);
gGL.texCoord2i(1, 1);
gGL.vertex2i(mWidth, mHeight);
}
gGL.end();
LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
}
//-----------------------------------------------------------------------------
// LLVisualParamReset()
//-----------------------------------------------------------------------------
LLVisualParamReset::LLVisualParamReset() : LLDynamicTexture(1, 1, 1, ORDER_RESET, FALSE)
{
}
//-----------------------------------------------------------------------------
// render()
//-----------------------------------------------------------------------------
BOOL LLVisualParamReset::render()
{
if (sDirty)
{
LLVOAvatar* avatarp = gAgent.getAvatarObject();
avatarp->updateComposites();
avatarp->updateVisualParams();
avatarp->updateGeometry(avatarp->mDrawable);
sDirty = FALSE;
}
return FALSE;
}
|