// Updates the user's avatar's appearance, replacing this wearables' parameters and textures with default values. // static // <FS:Ansariel> [Legacy Bake] //void LLViewerWearable::removeFromAvatar( LLWearableType::EType type) void LLViewerWearable::removeFromAvatar( LLWearableType::EType type, BOOL upload_bake) { if (!isAgentAvatarValid()) return; // You can't just remove body parts. if( (type == LLWearableType::WT_SHAPE) || (type == LLWearableType::WT_SKIN) || (type == LLWearableType::WT_HAIR) || (type == LLWearableType::WT_EYES) ) { return; } // Pull params for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->isTweakable() ) ) { S32 param_id = param->getID(); // <FS:Ansariel> [Legacy Bake] //gAgentAvatarp->setVisualParamWeight( param_id, param->getDefaultWeight()); gAgentAvatarp->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake); } } if(gAgentCamera.cameraCustomizeAvatar()) { LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "edit_outfit")); } gAgentAvatarp->updateVisualParams(); // <FS:Ansariel> [Legacy Bake] //gAgentAvatarp->wearableUpdated(type); gAgentAvatarp->wearableUpdated(type, FALSE); }
//----------------------------------------------------------------------------- // clearVisualParamWeights() //----------------------------------------------------------------------------- void LLCharacter::clearVisualParamWeights() { for (LLVisualParam *param = getFirstVisualParam(); param; param = getNextVisualParam()) { if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) { param->setWeight( param->getDefaultWeight(), FALSE ); } } }
//----------------------------------------------------------------------------- // clearVisualParamWeights() //----------------------------------------------------------------------------- void LLCharacter::clearVisualParamWeights() { for (LLVisualParam *param = getFirstVisualParam(); param; param = getNextVisualParam()) { if (param->isTweakable()) { param->setWeight( param->getDefaultWeight(), FALSE ); } } }
void LLWearable::setParamsToDefaults() { if (!isAgentAvatarValid()) return; for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->isTweakable() ) ) { setVisualParamWeight(param->getID(),param->getDefaultWeight(), FALSE); } } }
// Updates the user's avatar's appearance, replacing this wearables' parameters and textures with default values. // static void LLWearable::removeFromAvatar( EWearableType type, BOOL set_by_user ) { LLVOAvatar* avatar = gAgent.getAvatarObject(); llassert( avatar ); if( !avatar ) { return; } // You can't just remove body parts. if( (type == WT_SHAPE) || (type == WT_SKIN) || (type == WT_HAIR) || (type == WT_EYES) ) { return; } // Pull params for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) { if (((LLViewerVisualParam*)param)->getWearableType() == type && param->isTweakable()) { S32 param_id = param->getID(); avatar->setVisualParamWeight( param_id, param->getDefaultWeight(), set_by_user ); } } // Pull textures LLViewerImage* image = gImageList.getImage( IMG_DEFAULT_AVATAR ); for( S32 te = 0; te < TEX_NUM_INDICES; te++ ) { if( LLVOAvatar::getTEWearableType((ETextureIndex) te ) == type ) { avatar->setLocTexTE( te, image, set_by_user ); } } if( gFloaterCustomize ) { gFloaterCustomize->setWearable(type, NULL, PERM_ALL, TRUE); } avatar->updateVisualParams(); avatar->updateMeshTextures(); // if( set_by_user ) // { // gAgent.sendAgentSetAppearance(); // } }
//----------------------------------------------------------------------------- // BOOL visualParamWeightsAreDefault() //----------------------------------------------------------------------------- BOOL LLCharacter::visualParamWeightsAreDefault() { for (LLVisualParam *param = getFirstVisualParam(); param; param = getNextVisualParam()) { if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) { if (param->getWeight() != param->getDefaultWeight()) return false; } } return true; }
//----------------------------------------------------------------------------- // BOOL visualParamWeightsAreDefault() //----------------------------------------------------------------------------- BOOL LLCharacter::visualParamWeightsAreDefault() { for (LLVisualParam *param = getFirstVisualParam(); param; param = getNextVisualParam()) { if (param->isTweakable()) { if (param->getWeight() != param->getDefaultWeight()) return false; } } return true; }
void LLWearable::setParamsToDefaults() { LLVOAvatar* avatar = gAgent.getAvatarObject(); llassert( avatar ); if( !avatar ) { return; } for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) { setVisualParamWeight(param->getID(),param->getDefaultWeight(), FALSE); } } }
//----------------------------------------------------------------------------- // updateVisualParams() //----------------------------------------------------------------------------- void LLCharacter::updateVisualParams() { for (LLVisualParam *param = getFirstVisualParam(); param; param = getNextVisualParam()) { if (param->isAnimating()) { continue; } // only apply parameters whose effective weight has changed F32 effective_weight = ( param->getSex() & mSex ) ? param->getWeight() : param->getDefaultWeight(); if (effective_weight != param->getLastWeight()) { param->apply( mSex ); } } }
void LLWearable::setParamsToDefaults() { LLVOAvatar* avatar = gAgent.getAvatarObject(); llassert( avatar ); if( !avatar ) { return; } mVisualParamMap.clear(); for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) { if (((LLViewerVisualParam*)param)->getWearableType() == mType && param->isTweakable()) { mVisualParamMap[param->getID()] = param->getDefaultWeight(); } } }
void LuaDumpVisualParams() { LLViewerInventoryItem* item; item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem(WT_SHAPE); if(!HasPermissions(item)) { LuaError("LuaDumpVisualParams(): You do not have permission to edit this shape."); return; } LLVOAvatar *av=gAgent.getAvatarObject(); std::string param_msg("Params for avatar "); param_msg.append(av->getFullname().c_str()); param_msg.append(": "); LuaSendChat(param_msg.c_str()); param_msg.clear(); for (LLVisualParam *param = av->getFirstVisualParam(); param; param = av->getNextVisualParam()) { param_msg.assign(param->getName().c_str()); param_msg.append(" ("); param_msg.append(toLuaString(param->getDefaultWeight())); param_msg.append("): "); param_msg.append(toLuaString(param->getCurrentWeight())); LuaSendChat(param_msg.c_str()); } std::map<LLUUID,LLWearable *>::const_iterator i; for(i = gWearableList.mList.begin();i!=gWearableList.mList.end();++i) { LLWearable *wear=(LLWearable *)i->second; LLFILE *file = LLFile::fopen(gDirUtilp->getExpandedFilename(FL_PATH_MACROS,"data"+gDirUtilp->getDirDelimiter()+"wearables",wear->getID().asString()).c_str(),"wb"); if(file && wear->exportFile(file)) delete file; std::stringstream s; s << "Wearable ID: "; s << wear->getID().asString(); LuaSendChat(s.str().c_str()); } }
// Updates the user's avatar's appearance, replacing this wearables' parameters and textures with default values. // static void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake ) { LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); llassert( avatar ); if( !avatar ) { return; } // You can't just remove body parts. if( (type == WT_SHAPE) || (type == WT_SKIN) || (type == WT_HAIR) || (type == WT_EYES) ) { return; } // Pull params for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) { S32 param_id = param->getID(); avatar->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake ); } } if( gFloaterCustomize ) { gFloaterCustomize->setWearable(type, NULL, PERM_ALL, TRUE); } avatar->updateVisualParams(); avatar->wearableUpdated(type, TRUE); // if( upload_bake ) // { // gAgent.sendAgentSetAppearance(); // } }
// Updates the user's avatar's appearance, replacing this wearables' parameters and textures with default values. // static void LLViewerWearable::removeFromAvatar( LLWearableType::EType type, bool upload_bake ) { if (!isAgentAvatarValid()) return; // You can't just remove body parts. if( (type == LLWearableType::WT_SHAPE) || (type == LLWearableType::WT_SKIN) || (type == LLWearableType::WT_HAIR) || (type == LLWearableType::WT_EYES) ) { return; } // Pull params for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->isTweakable()) ) { S32 param_id = param->getID(); gAgentAvatarp->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake ); } } if(isAgentAvatarValid() && gAgentAvatarp->isEditingAppearance() && LLFloaterCustomize::instanceExists()) { LLFloaterCustomize::getInstance()->wearablesChanged(type); } gAgentAvatarp->updateVisualParams(); gAgentAvatarp->wearableUpdated(type, FALSE); // if( upload_bake ) // { // gAgent.sendAgentSetAppearance(); // } }
std::string LuaDumpVisualParamsToLuaCode() { LLVOAvatar *av=gAgent.getAvatarObject(); //LuaError("DumpVisualParamsToLuaCode() DEBUG: Dumping vis params. (Checking perms)"); LLViewerInventoryItem* item; item = (LLViewerInventoryItem*)gAgent.getWearableInventoryItem(WT_SHAPE); if(!item) { LuaError(llformat("DumpVisualParamsToLuaCode() (%s:%d): item is null! Cannot check perms; Aborting!\nPlease file a bug report at http://bugs.nexisonline.net/",__FILE__,__LINE__).c_str()); return ""; } if(!HasPermissions(item)) { LuaError("LuaDumpVisualParamsToLuaCode(): You do not have permission to edit this shape."); return std::string(); } std::string param_msg(""); param_msg.assign("--[[ Autogenerated by FlexLife Viewer (Rev. $Rev$)]]--\n\n"); param_msg.append("-- setParamOnSelf(\"name\",weight) -- default, min, max\n"); for (LLVisualParam *param = av->getFirstVisualParam(); param; param = av->getNextVisualParam()) { param_msg.append( llformat( "setParamOnSelf(\"%s\",%f)\t-- %f\t%f\t%f\n", param->getName().c_str(), param->getCurrentWeight(), param->getDefaultWeight(), param->getMinWeight(), param->getMaxWeight() ) ); } param_msg.append("\n\n--[[Wearables]]--\nRemoveAllWearables()\n"); std::map<LLUUID,LLWearable *>::const_iterator i; for(i = gWearableList.mList.begin();i!=gWearableList.mList.end();++i) { LLWearable *wear=(LLWearable *)i->second; if(!LuaSaveWearable(wear)) break; std::stringstream s; s << "wear(\"" << wear->getID().asString() << "\")\n"; param_msg.append(s.str()); } /* for( S32 i = 0; i < BAKED_NUM_INDICES; i++ ) { S32 tex_index=LLmBakedTextureData[i].mTextureIndex //S32 tex_index = LLVOAvatar::sBakedTextureIndices[i]; std::stringstream s; s << "setTEImage(" << tex_index <<",\""<< av->getTEImage(tex_index)->getID() << "\")\n"; param_msg.append(s.str()); } */ param_msg.append("UpdateAppearance()\n"); //LuaError("DumpVisualParamsToLuaCode() DEBUG: Done."); return param_msg; }
// Updates the user's avatar's appearance void LLWearable::writeToAvatar( BOOL set_by_user ) { LLVOAvatar* avatar = gAgent.getAvatarObject(); llassert( avatar ); if( !avatar ) { return; } ESex old_sex = avatar->getSex(); // Pull params for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) { if (((LLViewerVisualParam*)param)->getWearableType() == mType && param->isTweakable()) { S32 param_id = param->getID(); F32 weight = get_if_there(mVisualParamMap, param_id, param->getDefaultWeight()); // only animate with user-originated changes if (set_by_user) { param->setAnimationTarget(weight, set_by_user); } else { avatar->setVisualParamWeight( param_id, weight, set_by_user ); } } } // only interpolate with user-originated changes if (set_by_user) { avatar->startAppearanceAnimation(TRUE, TRUE); } // Pull texture entries for( S32 te = 0; te < TEX_NUM_INDICES; te++ ) { if( LLVOAvatar::getTEWearableType((ETextureIndex) te ) == mType ) { const LLUUID& image_id = get_if_there(mTEMap, te, LLVOAvatar::getDefaultTEImageID((ETextureIndex) te ) ); LLViewerImage* image = gImageList.getImage( image_id ); avatar->setLocTexTE( te, image, set_by_user ); } } avatar->updateVisualParams(); if( gFloaterCustomize ) { LLViewerInventoryItem* item; item = (LLViewerInventoryItem*)gInventory.getItem(gAgent.getWearableItem(mType)); U32 perm_mask = PERM_NONE; BOOL is_complete = FALSE; if(item) { perm_mask = item->getPermissions().getMaskOwner(); is_complete = item->isComplete(); if(!is_complete) { item->fetchFromServer(); } } gFloaterCustomize->setWearable(mType, this, perm_mask, is_complete); LLFloaterCustomize::setCurrentWearableType( mType ); } ESex new_sex = avatar->getSex(); if( old_sex != new_sex ) { avatar->updateSexDependentLayerSets( set_by_user ); } avatar->updateMeshTextures(); // if( set_by_user ) // { // gAgent.sendAgentSetAppearance(); // } }
// Creates new parameters for the given wearable and applies them to the avatar. void LLGenePool::spawn( EWearableType type ) { LLVOAvatar* avatar = gAgent.getAvatarObject(); if( !avatar ) { return; } if( !mLoaded ) { if( !load() ) { return; } } if( mArchetypes.count() < 1 ) { return; } // Only consider archetypes that have the same sex as you have already. LLVisualParam* male_param = avatar->getVisualParam( "male" ); if (!male_param) { llwarns << "The hard coded \'male\' parameter passed to avatar->getVisualParam() in LLGenePool::spawn() is no longer valid." << llendl; return; } S32 male_param_id = male_param->getID(); F32 sex_weight = male_param->getWeight(); S32 i = 0; S32 j = 0; S32 k = 0; const S32 MAX_CYCLES = 1000; S32 cycles = 0; F32 cur_sex_weight = 0.f; do { i = rand() % mArchetypes.count(); cur_sex_weight = mArchetypes[i]->getParam(male_param_id, 0.f); cycles++; if (cur_sex_weight != sex_weight) { break; } } while((cycles < MAX_CYCLES)); if( cycles >= MAX_CYCLES ) { return; } LLAppearance* arch1 = mArchetypes[i]; LLAppearance* arch2 = NULL; LLAppearance* arch3 = NULL; if( mArchetypes.count() > 1 ) { cycles = 0; do { j = rand() % mArchetypes.count(); cur_sex_weight = mArchetypes[j]->getParam(male_param_id, 0.f); cycles++; } while( (cycles < MAX_CYCLES) && ( (i == j) || (cur_sex_weight != sex_weight) ) ); if( cycles >= MAX_CYCLES ) { return; } arch2 = mArchetypes[j]; } if( mArchetypes.count() > 2 ) { cycles = 0; do { k = rand() % mArchetypes.count(); cur_sex_weight = mArchetypes[k]->getParam(male_param_id, 0.f); cycles++; } while( (cycles < MAX_CYCLES) && ( (i == k) || (j == k) || (cur_sex_weight != sex_weight) ) ); if( cycles >= MAX_CYCLES ) { return; } arch3 = mArchetypes[k]; } // Lame generation of barycentric coordinates F32 b1 = F32( rand() ) / RAND_MAX; F32 b2 = (F32( rand() ) / RAND_MAX) * (1.f - b1); F32 b3 = 1.f - b1 - b2; // ESex old_sex = avatar->getSex(); // Pull params for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) ) { S32 param_id = param->getID(); // don't try to blend male/female param...as fp innaccuracy will break the [0 | 1] semantics if (param_id != male_param_id) { F32 weight1 = arch1->getParam( param_id, param->getDefaultWeight() ); F32 net_weight = weight1; if( arch2 && arch3 ) { F32 weight2 = arch2->getParam( param_id, param->getDefaultWeight() ); F32 weight3 = arch3->getParam( param_id, param->getDefaultWeight() ); net_weight = b1 * weight1 + b2 * weight2 + b3 * weight3; } param->setAnimationTarget(net_weight, TRUE); } } } // Find the archetype with the greatest influence LLAppearance* dominant_arch = arch1; if( (b2 > b1) && (b2 > b3) ) { dominant_arch = arch2; } else if( (b3 > b1) && (b3 > b2) ) { dominant_arch = arch3; } // Pull Textures from the dominant archetype for( S32 te = 0; te < LLVOAvatar::TEX_NUM_ENTRIES; te++ ) { if( LLVOAvatar::isTextureIndexBaked( te ) ) { continue; } if( LLVOAvatar::getTEWearableType( te ) == type ) { LLUUID image_id = dominant_arch->getTexture( te ); if( image_id.isNull() ) { image_id = LLVOAvatar::getDefaultTEImageID( te ); } LLViewerImage* image = gImageList.getImage( image_id ); if( image ) { avatar->setLocTexTE( te, image, TRUE ); } } } // avatar->setVisualParamWeight( "male", sex_weight ); avatar->startAppearanceAnimation(TRUE, TRUE); avatar->updateVisualParams(); // ESex new_sex = avatar->getSex(); // if( old_sex != new_sex ) // { // avatar->updateSexDependentLayerSets( TRUE ); // } avatar->updateMeshTextures(); gAgent.sendAgentSetAppearance(); }