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
|
/**
* @File llavatarappearance.cpp
* @brief Implementation of LLAvatarAppearance class
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llavatarappearance.h"
#include "lldeleteutils.h"
#include "lltexglobalcolor.h"
#include "llwearabledata.h"
const LLColor4 DUMMY_COLOR = LLColor4(0.5,0.5,0.5,1.0);
LLAvatarAppearance::LLAvatarAppearance(LLWearableData* wearable_data) :
LLCharacter(),
mIsDummy(FALSE),
mTexSkinColor( NULL ),
mTexHairColor( NULL ),
mTexEyeColor( NULL ),
mWearableData(wearable_data)
{
llassert(mWearableData);
}
// virtual
LLAvatarAppearance::~LLAvatarAppearance()
{
deleteAndClear(mTexSkinColor);
deleteAndClear(mTexHairColor);
deleteAndClear(mTexEyeColor);
}
using namespace LLAvatarAppearanceDefines;
// virtual
BOOL LLAvatarAppearance::isValid() const
{
// This should only be called on ourself.
if (!isSelf())
{
llerrs << "Called LLAvatarAppearance::isValid() on when isSelf() == false" << llendl;
}
return TRUE;
}
//static
BOOL LLAvatarAppearance::teToColorParams( ETextureIndex te, U32 *param_name )
{
switch( te )
{
case TEX_UPPER_SHIRT:
param_name[0] = 803; //"shirt_red";
param_name[1] = 804; //"shirt_green";
param_name[2] = 805; //"shirt_blue";
break;
case TEX_LOWER_PANTS:
param_name[0] = 806; //"pants_red";
param_name[1] = 807; //"pants_green";
param_name[2] = 808; //"pants_blue";
break;
case TEX_LOWER_SHOES:
param_name[0] = 812; //"shoes_red";
param_name[1] = 813; //"shoes_green";
param_name[2] = 817; //"shoes_blue";
break;
case TEX_LOWER_SOCKS:
param_name[0] = 818; //"socks_red";
param_name[1] = 819; //"socks_green";
param_name[2] = 820; //"socks_blue";
break;
case TEX_UPPER_JACKET:
case TEX_LOWER_JACKET:
param_name[0] = 834; //"jacket_red";
param_name[1] = 835; //"jacket_green";
param_name[2] = 836; //"jacket_blue";
break;
case TEX_UPPER_GLOVES:
param_name[0] = 827; //"gloves_red";
param_name[1] = 829; //"gloves_green";
param_name[2] = 830; //"gloves_blue";
break;
case TEX_UPPER_UNDERSHIRT:
param_name[0] = 821; //"undershirt_red";
param_name[1] = 822; //"undershirt_green";
param_name[2] = 823; //"undershirt_blue";
break;
case TEX_LOWER_UNDERPANTS:
param_name[0] = 824; //"underpants_red";
param_name[1] = 825; //"underpants_green";
param_name[2] = 826; //"underpants_blue";
break;
case TEX_SKIRT:
param_name[0] = 921; //"skirt_red";
param_name[1] = 922; //"skirt_green";
param_name[2] = 923; //"skirt_blue";
break;
case TEX_HEAD_TATTOO:
case TEX_LOWER_TATTOO:
case TEX_UPPER_TATTOO:
param_name[0] = 1071; //"tattoo_red";
param_name[1] = 1072; //"tattoo_green";
param_name[2] = 1073; //"tattoo_blue";
break;
default:
llassert(0);
return FALSE;
}
return TRUE;
}
void LLAvatarAppearance::setClothesColor( ETextureIndex te, const LLColor4& new_color, BOOL upload_bake )
{
U32 param_name[3];
if( teToColorParams( te, param_name ) )
{
setVisualParamWeight( param_name[0], new_color.mV[VX], upload_bake );
setVisualParamWeight( param_name[1], new_color.mV[VY], upload_bake );
setVisualParamWeight( param_name[2], new_color.mV[VZ], upload_bake );
}
}
LLColor4 LLAvatarAppearance::getClothesColor( ETextureIndex te )
{
LLColor4 color;
U32 param_name[3];
if( teToColorParams( te, param_name ) )
{
color.mV[VX] = getVisualParamWeight( param_name[0] );
color.mV[VY] = getVisualParamWeight( param_name[1] );
color.mV[VZ] = getVisualParamWeight( param_name[2] );
}
return color;
}
// static
LLColor4 LLAvatarAppearance::getDummyColor()
{
return DUMMY_COLOR;
}
LLColor4 LLAvatarAppearance::getGlobalColor( const std::string& color_name ) const
{
if (color_name=="skin_color" && mTexSkinColor)
{
return mTexSkinColor->getColor();
}
else if(color_name=="hair_color" && mTexHairColor)
{
return mTexHairColor->getColor();
}
if(color_name=="eye_color" && mTexEyeColor)
{
return mTexEyeColor->getColor();
}
else
{
// return LLColor4( .5f, .5f, .5f, .5f );
return LLColor4( 0.f, 1.f, 1.f, 1.f ); // good debugging color
}
}
// Unlike most wearable functions, this works for both self and other.
// virtual
BOOL LLAvatarAppearance::isWearingWearableType(LLWearableType::EType type) const
{
if (mIsDummy) return TRUE;
switch(type)
{
case LLWearableType::WT_SHAPE:
case LLWearableType::WT_SKIN:
case LLWearableType::WT_HAIR:
case LLWearableType::WT_EYES:
return TRUE; // everyone has all bodyparts
default:
break; // Do nothing
}
/* switch(type)
case LLWearableType::WT_SHIRT:
indicator_te = TEX_UPPER_SHIRT; */
for (LLAvatarAppearanceDictionary::Textures::const_iterator tex_iter = LLAvatarAppearanceDictionary::getInstance()->getTextures().begin();
tex_iter != LLAvatarAppearanceDictionary::getInstance()->getTextures().end();
++tex_iter)
{
const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = tex_iter->second;
if (texture_dict->mWearableType == type)
{
// If you're checking another avatar's clothing, you don't have component textures.
// Thus, you must check to see if the corresponding baked texture is defined.
// NOTE: this is a poor substitute if you actually want to know about individual pieces of clothing
// this works for detecting a skirt (most important), but is ineffective at any piece of clothing that
// gets baked into a texture that always exists (upper or lower).
if (texture_dict->mIsUsedByBakedTexture)
{
const EBakedTextureIndex baked_index = texture_dict->mBakedTextureIndex;
return isTextureDefined(LLAvatarAppearanceDictionary::getInstance()->getBakedTexture(baked_index)->mTextureIndex);
}
return FALSE;
}
}
return FALSE;
}
|