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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
/**
* @file llpanelmorph.cpp
* @brief LLPanelMorph class implementation
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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$
*/
// file include
#include "llviewerprecompiledheaders.h"
/*
#include "llpanelmorph.h"
// library includes
#include "llerror.h"
#include "llrect.h"
#include "llstring.h"
#include "llfontgl.h"
// project includes
#include "llui.h"
#include "llspinctrl.h"
#include "llcheckboxctrl.h"
#include "lltextbox.h"
#include "llbutton.h"
//#include "lldraghandle.h"
#include "llviewerwindow.h"
#include "llviewerobject.h"
#include "llresmgr.h"
#include "llcontrol.h"
#include "llagent.h"
#include "llvoavatar.h"
#include "lltoolmgr.h"
#include "lltoolmorph.h"
#include "llquantize.h"
//
// Constants
//
const S32 VPAD = 2;
const S32 HPAD = 4;
const S32 TITLE_WIDTH = 100;
const S32 TITLE_HEIGHT = 16;
const S32 CLOSE_BOX_SIZE = 16;
const S32 LABEL_HOFF = 8;
const S32 LABEL_WIDTH = 140;
const S32 SPIN_WIDTH = 250;
// minimum and maximum morph weight values (a UI/network constraint, not inherent to morphs)
const F32 MORPH_WEIGHT_MIN = (-1.f);
const F32 MORPH_WEIGHT_MAX = (1.f);
// this is the magic number that morph values are quantized to for network transmission purposes
// the 200 value is a result of encoding the weights as a string (and avoiding NULL terminators
// and avoiding \n (the between-NV-pair delimiter). Map -1 to 1 to 50-250. HACK. JC
const S32 MORPH_WEIGHT_OFFSET = (50);
const S32 MORPH_WEIGHT_QUANTUM = ((MORPH_WEIGHT_MAX - MORPH_WEIGHT_MIN) / MAXSTRINGVAL);
//#define MORPH_PANEL_SHOW_SPINNERS
//
// Globals
//
LLPanelMorph *gPanelMorph = NULL;
//
// Methods
//
//static
//-----------------------------------------------------------------------------
// LLPanelMorph()
//-----------------------------------------------------------------------------
LLPanelMorph::LLPanelMorph(const std::string& name, const LLRect& rect)
: LLPanel( name, rect )
{
mParamSpinners = NULL;
mSexRadioGroup = NULL;
mRect = rect;
mMesh = NULL;
setBackgroundVisible( TRUE );
}
//-----------------------------------------------------------------------------
// ~LLPanelMorph()
//-----------------------------------------------------------------------------
LLPanelMorph::~LLPanelMorph()
{
#ifdef MORPH_PANEL_SHOW_SPINNERS
for (S32 i = 0; i < mNumParamSpinners; i++)
{
removeChild(mParamSpinners[i]);
delete mParamSpinners[i];
}
delete [] mParamSpinners;
#endif
}
// static
//-----------------------------------------------------------------------------
// onCommitSexChange()
//-----------------------------------------------------------------------------
void LLPanelMorph::onCommitSexChange( void *data)
{
// LLRadioGroup *group = (LLRadioGroup *)data;
// LLVOAvatar *avatarp = gAgent.getAvatarObject();
//
// LLNameValue* avatarSexNV = avatarp->getNVPair("AvatarSex");
// if (!avatarSexNV)
// {
// avatarp->addNVPair( "AvatarSex U32 READ_WRITE SIM_SPACE_VIEWER 0");
// avatarSexNV = avatarp->getNVPair("AvatarSex");
// }
//
// avatarSexNV->setU32(gSavedSettings.getU32("AvatarSex"));
//
// avatarp->sendNVPairToSimulator("AvatarSex");
//
// // preemptively update sex based on local value
// avatarp->updateSex();
//
// LLVisualParamHint::requestHintUpdates();
}
// static
//-----------------------------------------------------------------------------
// onCommitMorphChange()
//-----------------------------------------------------------------------------
void LLPanelMorph::onCommitMorphChange( LLUICtrl* ctrl, void* userdata )
{
//#ifdef MORPH_PANEL_SHOW_SPINNERS
// LLVOAvatar *avatarp = gAgent.getAvatarObject();
//
// LLPanelMorph* self = (LLPanelMorph*) userdata;
//
// S32 i = 0;
// for(LLPolyMorphTarget* morphTargetp = self->mMesh->getFirstVisualParam();
// morphTargetp;
// morphTargetp = self->mMesh->getNextVisualParam())
// {
// for(S32 j = 0; j < self->mNumParamSpinners; j++)
// {
// if (!strcmp(self->mParamSpinners[j]->getName(), morphTargetp->getName()))
// {
// avatarp->mHeadMesh0.getMesh()->setDistortionWeight(morphTargetp, self->mParamSpinners[j]->get());
// }
// }
// i++;
// }
// avatarp->updateDistortions();
// avatarp->sendVisualParams();
//#endif
}
//-----------------------------------------------------------------------------
// updateSpinners()
//-----------------------------------------------------------------------------
void LLPanelMorph::updateSpinners(LLPolyMesh *mesh)
{
if (mesh != mMesh) return;
#ifdef MORPH_PANEL_SHOW_SPINNERS
for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
param;
param = gAgent.getAvatarObject()->getNextVisualParam())
{
if (param->getID() == -1 ||
param->getGroup() != LLVisualParam::VISUAL_PARAM_GROUP_TWEAKABLE) continue;
F32 paramWeight = gAgent.getAvatarObject()->getVisualParamWeight(morphTargetp);
for (S32 i = 0; i < mNumParamSpinners; i++)
{
if (!strcmp(mParamSpinners[i]->getName() , morphTargetp->getName()))
{
mParamSpinners[i]->set(paramWeight);
}
}
}
#endif
}
//-----------------------------------------------------------------------------
// createSpinners()
//-----------------------------------------------------------------------------
void LLPanelMorph::createSpinners(LLPolyMesh *mesh)
{
const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
S32 cur_y;
S32 new_height;
S32 control_focus = -1;
if (mSexRadioGroup)
{
removeChild(mSexRadioGroup);
delete mSexRadioGroup;
}
if (mParamSpinners)
{
for (S32 i = 0; i < mNumParamSpinners; i++)
{
if (mParamSpinners[i]->hasFocus())
{
control_focus = i;
mParamSpinners[i]->setFocus(FALSE);
}
}
for (i = 0; i < mNumParamSpinners; i++)
{
removeChild(mParamSpinners[i]);
delete mParamSpinners[i];
}
delete [] mParamSpinners;
mParamSpinners = NULL;
}
#ifdef MORPH_PANEL_SHOW_SPINNERS
S32 numSpinners = 0;
for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
param;
param = gAgent.getAvatarObject()->getNextVisualParam())
{
if(param->getID() != -1 &&
param->getGroup() == LLVisualParam::VISUAL_PARAM_GROUP_TWEAKABLE)
{
numSpinners++;
}
}
if (numSpinners != 0)
{
mParamSpinners = new LLSpinCtrl*[numSpinners];
}
// set focus back to control #n
if (control_focus >= 0 && control_focus < numSpinners)
{
mParamSpinners[control_focus]->setFocus(TRUE);
}
new_height = numSpinners * (SPINCTRL_HEIGHT + VPAD) + (VPAD * 3) + CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
#else
new_height = (VPAD * 3) + CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
#endif
LLRect panelRect = getRect();
reshape(panelRect.getWidth(), new_height, TRUE);
cur_y = new_height - VPAD - VPAD;
LLRect radio_rect;
radio_rect.setLeftTopAndSize(HPAD + LABEL_HOFF,
cur_y,
getRect().getWidth() - HPAD - HPAD - LABEL_HOFF,
CHECKBOXCTRL_HEIGHT + VPAD);
mSexRadioGroup = new LLRadioGroup("sex radio",
radio_rect,
"AvatarSex",
&LLPanelMorph::onCommitSexChange,
(void *)this);
addChild(mSexRadioGroup);
radio_rect.setLeftTopAndSize(HPAD + LABEL_HOFF,
0,
(getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f,
0);
mSexRadioGroup->addRadioButton("Female", "Female", radio_rect, font);
radio_rect.setLeftTopAndSize(((getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f) + HPAD + LABEL_HOFF,
0,
(getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f,
0);
mSexRadioGroup->addRadioButton("Male", "Male", radio_rect, font);
cur_y -= CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
#ifdef MORPH_PANEL_SHOW_SPINNERS
S32 i = 0;
for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
param;
param = gAgent.getAvatarObject()->getNextVisualParam())
{
if (param->getID() == -1 ||
param->getGroup() != LLVisualParam::VISUAL_PARAM_GROUP_TWEAKABLE) continue;
LLRect spinnerRect;
spinnerRect.setLeftTopAndSize(HPAD + LABEL_HOFF,
cur_y,
getRect().getWidth() - HPAD - HPAD - LABEL_HOFF,
cur_y - SPINCTRL_HEIGHT);
mParamSpinners[i] = new LLSpinCtrl(param->getName(),
spinnerRect,
font,
param->getName(),
&LLPanelMorph::onCommitMorphChange,
this,
param->getWeight(),
param->getMinWeight(),
param->getMaxWeight(),
MORPH_WEIGHT_QUANTUM * 2,
NULL,
LABEL_WIDTH );
mParamSpinners[i]->setPrecision(2);
mParamSpinners[i]->setFollowsTop();
mParamSpinners[i]->setFollowsLeft();
addChild(mParamSpinners[i]);
cur_y -= VPAD + SPINCTRL_HEIGHT;
i++;
}
mNumParamSpinners = numSpinners;
#endif
mMesh = mesh;
}
*/
|