BOOL LLPolySkeletalDistortionInfo::parseXml(LLXmlTreeNode* node) { llassert( node->hasName( "param" ) && node->getChildByName( "param_skeleton" ) ); if (!LLViewerVisualParamInfo::parseXml(node)) return FALSE; LLXmlTreeNode* skeletalParam = node->getChildByName("param_skeleton"); if (NULL == skeletalParam) { LL_WARNS() << "Failed to getChildByName(\"param_skeleton\")" << LL_ENDL; return FALSE; } for( LLXmlTreeNode* bone = skeletalParam->getFirstChild(); bone; bone = skeletalParam->getNextChild() ) { if (bone->hasName("bone")) { std::string name; LLVector3 scale; LLVector3 pos; BOOL haspos = FALSE; static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); if (!bone->getFastAttributeString(name_string, name)) { LL_WARNS() << "No bone name specified for skeletal param." << LL_ENDL; continue; } static LLStdStringHandle scale_string = LLXmlTree::addAttributeString("scale"); if (!bone->getFastAttributeVector3(scale_string, scale)) { LL_WARNS() << "No scale specified for bone " << name << "." << LL_ENDL; continue; } // optional offset deformation (translation) static LLStdStringHandle offset_string = LLXmlTree::addAttributeString("offset"); if (bone->getFastAttributeVector3(offset_string, pos)) { haspos = TRUE; } mBoneInfoList.push_back(LLPolySkeletalBoneInfo(name, scale, pos, haspos)); } else { LL_WARNS() << "Unrecognized element " << bone->getName() << " in skeletal distortion" << LL_ENDL; continue; } } return TRUE; }
BOOL LLPolyMorphTargetInfo::parseXml(LLXmlTreeNode* node) { llassert( node->hasName( "param" ) && node->getChildByName( "param_morph" ) ); if (!LLViewerVisualParamInfo::parseXml(node)) return FALSE; // Get mixed-case name static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); if( !node->getFastAttributeString( name_string, mMorphName ) ) { LL_WARNS() << "Avatar file: <param> is missing name attribute" << LL_ENDL; return FALSE; // Continue, ignoring this tag } static LLStdStringHandle clothing_morph_string = LLXmlTree::addAttributeString("clothing_morph"); node->getFastAttributeBOOL(clothing_morph_string, mIsClothingMorph); LLXmlTreeNode *paramNode = node->getChildByName("param_morph"); if (NULL == paramNode) { LL_WARNS() << "Failed to getChildByName(\"param_morph\")" << LL_ENDL; return FALSE; } for (LLXmlTreeNode* child_node = paramNode->getFirstChild(); child_node; child_node = paramNode->getNextChild()) { static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); if (child_node->hasName("volume_morph")) { std::string volume_name; if (child_node->getFastAttributeString(name_string, volume_name)) { LLVector3 scale; static LLStdStringHandle scale_string = LLXmlTree::addAttributeString("scale"); child_node->getFastAttributeVector3(scale_string, scale); LLVector3 pos; static LLStdStringHandle pos_string = LLXmlTree::addAttributeString("pos"); child_node->getFastAttributeVector3(pos_string, pos); mVolumeInfoList.push_back(LLPolyVolumeMorphInfo(volume_name,scale,pos)); } } } return TRUE; }
bool LLViewerFolderDictionary::initEnsemblesFromFile() { std::string xml_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"foldertypes.xml"); LLXmlTree folder_def; if (!folder_def.parseFile(xml_filename)) { llerrs << "Failed to parse folders file " << xml_filename << llendl; return false; } LLXmlTreeNode* rootp = folder_def.getRoot(); for (LLXmlTreeNode* ensemble = rootp->getFirstChild(); ensemble; ensemble = rootp->getNextChild()) { if (!ensemble->hasName("ensemble")) { llwarns << "Invalid ensemble definition node " << ensemble->getName() << llendl; continue; } S32 ensemble_type; static LLStdStringHandle ensemble_num_string = LLXmlTree::addAttributeString("foldertype_num"); if (!ensemble->getFastAttributeS32(ensemble_num_string, ensemble_type)) { llwarns << "No ensemble type defined" << llendl; continue; } if (ensemble_type < S32(LLFolderType::FT_ENSEMBLE_START) || ensemble_type > S32(LLFolderType::FT_ENSEMBLE_END)) { llwarns << "Exceeded maximum ensemble index" << LLFolderType::FT_ENSEMBLE_END << llendl; break; } std::string xui_name; static LLStdStringHandle xui_name_string = LLXmlTree::addAttributeString("xui_name"); if (!ensemble->getFastAttributeString(xui_name_string, xui_name)) { llwarns << "No xui name defined" << llendl; continue; } std::string icon_name; static LLStdStringHandle icon_name_string = LLXmlTree::addAttributeString("icon_name"); if (!ensemble->getFastAttributeString(icon_name_string, icon_name)) { llwarns << "No ensemble icon name defined" << llendl; continue; } std::string allowed_names; static LLStdStringHandle allowed_names_string = LLXmlTree::addAttributeString("allowed"); if (!ensemble->getFastAttributeString(allowed_names_string, allowed_names)) { } // Add the entry and increment the asset number. const static std::string new_ensemble_name = "New Ensemble"; addEntry(LLFolderType::EType(ensemble_type), new ViewerFolderEntry(xui_name, new_ensemble_name, icon_name, allowed_names)); } return true; }
// Returns number of controls loaded, so 0 if failure U32 LLControlGroup::loadFromFile(const LLString& filename, BOOL require_declaration, eControlType declare_as) { LLString name; LLXmlTree xml_controls; if (!xml_controls.parseFile(filename)) { llwarns << "Unable to open control file " << filename << llendl; return 0; } LLXmlTreeNode* rootp = xml_controls.getRoot(); if (!rootp || !rootp->hasAttribute("version")) { llwarns << "No valid settings header found in control file " << filename << llendl; return 0; } U32 item = 0; U32 validitems = 0; S32 version; rootp->getAttributeS32("version", version); // Check file version if (version != CURRENT_VERSION) { llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl; return 0; } LLXmlTreeNode* child_nodep = rootp->getFirstChild(); while(child_nodep) { name = child_nodep->getName(); BOOL declared = controlExists(name); if (require_declaration && !declared) { // Declaration required, but this name not declared. // Complain about non-empty names. if (!name.empty()) { //read in to end of line llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; } child_nodep = rootp->getNextChild(); continue; } // Got an item. Load it up. item++; // If not declared, assume it's a string if (!declared) { switch(declare_as) { case TYPE_COL4: declareColor4(name, LLColor4::white, "", NO_PERSIST); break; case TYPE_COL4U: declareColor4U(name, LLColor4U::white, "", NO_PERSIST); break; case TYPE_STRING: default: declareString(name, LLString::null, "", NO_PERSIST); break; } } // Control name has been declared in code. LLControlBase *control = getControl(name); llassert(control); mLoadedSettings.insert(name); switch(control->mType) { case TYPE_F32: { F32 initial = 0.f; child_nodep->getAttributeF32("value", initial); control->set(initial); validitems++; } break; case TYPE_S32: { S32 initial = 0; child_nodep->getAttributeS32("value", initial); control->set(initial); validitems++; } break; case TYPE_U32: { U32 initial = 0; child_nodep->getAttributeU32("value", initial); control->set((LLSD::Integer) initial); validitems++; } break; case TYPE_BOOLEAN: { BOOL initial = FALSE; child_nodep->getAttributeBOOL("value", initial); control->set(initial); validitems++; } break; case TYPE_STRING: { LLString string; child_nodep->getAttributeString("value", string); if (string == LLString::null) { string = ""; } control->set(string); validitems++; } break; case TYPE_VEC3: { LLVector3 vector; child_nodep->getAttributeVector3("value", vector); control->set(vector.getValue()); validitems++; } break; case TYPE_VEC3D: { LLVector3d vector; child_nodep->getAttributeVector3d("value", vector); control->set(vector.getValue()); validitems++; } break; case TYPE_RECT: { //RN: hack to support reading rectangles from a string LLString rect_string; child_nodep->getAttributeString("value", rect_string); std::istringstream istream(rect_string); S32 left, bottom, width, height; istream >> left >> bottom >> width >> height; LLRect rect; rect.setOriginAndSize(left, bottom, width, height); control->set(rect.getValue()); validitems++; } break; case TYPE_COL4U: { LLColor4U color; child_nodep->getAttributeColor4U("value", color); control->set(color.getValue()); validitems++; } break; case TYPE_COL4: { LLColor4 color; child_nodep->getAttributeColor4("value", color); control->set(color.getValue()); validitems++; } break; case TYPE_COL3: { LLVector3 color; child_nodep->getAttributeVector3("value", color); control->set(LLColor3(color.mV).getValue()); validitems++; } break; } child_nodep = rootp->getNextChild(); } return validitems; }
// static void LLVOTree::initClass() { std::string xml_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"trees.xml"); LLXmlTree tree_def_tree; if (!tree_def_tree.parseFile(xml_filename)) { llerrs << "Failed to parse tree file." << llendl; } LLXmlTreeNode* rootp = tree_def_tree.getRoot(); for (LLXmlTreeNode* tree_def = rootp->getFirstChild(); tree_def; tree_def = rootp->getNextChild()) { if (!tree_def->hasName("tree")) { llwarns << "Invalid tree definition node " << tree_def->getName() << llendl; continue; } F32 F32_val; LLUUID id; S32 S32_val; BOOL success = TRUE; S32 species; static LLStdStringHandle species_id_string = LLXmlTree::addAttributeString("species_id"); if (!tree_def->getFastAttributeS32(species_id_string, species)) { llwarns << "No species id defined" << llendl; continue; } if (species < 0) { llwarns << "Invalid species id " << species << llendl; continue; } if (sSpeciesTable.count(species)) { llwarns << "Tree species " << species << " already defined! Duplicate discarded." << llendl; continue; } TreeSpeciesData* newTree = new TreeSpeciesData(); static LLStdStringHandle texture_id_string = LLXmlTree::addAttributeString("texture_id"); success &= tree_def->getFastAttributeUUID(texture_id_string, id); newTree->mTextureID = id; static LLStdStringHandle droop_string = LLXmlTree::addAttributeString("droop"); success &= tree_def->getFastAttributeF32(droop_string, F32_val); newTree->mDroop = F32_val; static LLStdStringHandle twist_string = LLXmlTree::addAttributeString("twist"); success &= tree_def->getFastAttributeF32(twist_string, F32_val); newTree->mTwist = F32_val; static LLStdStringHandle branches_string = LLXmlTree::addAttributeString("branches"); success &= tree_def->getFastAttributeF32(branches_string, F32_val); newTree->mBranches = F32_val; static LLStdStringHandle depth_string = LLXmlTree::addAttributeString("depth"); success &= tree_def->getFastAttributeS32(depth_string, S32_val); newTree->mDepth = S32_val; static LLStdStringHandle scale_step_string = LLXmlTree::addAttributeString("scale_step"); success &= tree_def->getFastAttributeF32(scale_step_string, F32_val); newTree->mScaleStep = F32_val; static LLStdStringHandle trunk_depth_string = LLXmlTree::addAttributeString("trunk_depth"); success &= tree_def->getFastAttributeS32(trunk_depth_string, S32_val); newTree->mTrunkDepth = S32_val; static LLStdStringHandle branch_length_string = LLXmlTree::addAttributeString("branch_length"); success &= tree_def->getFastAttributeF32(branch_length_string, F32_val); newTree->mBranchLength = F32_val; static LLStdStringHandle trunk_length_string = LLXmlTree::addAttributeString("trunk_length"); success &= tree_def->getFastAttributeF32(trunk_length_string, F32_val); newTree->mTrunkLength = F32_val; static LLStdStringHandle leaf_scale_string = LLXmlTree::addAttributeString("leaf_scale"); success &= tree_def->getFastAttributeF32(leaf_scale_string, F32_val); newTree->mLeafScale = F32_val; static LLStdStringHandle billboard_scale_string = LLXmlTree::addAttributeString("billboard_scale"); success &= tree_def->getFastAttributeF32(billboard_scale_string, F32_val); newTree->mBillboardScale = F32_val; static LLStdStringHandle billboard_ratio_string = LLXmlTree::addAttributeString("billboard_ratio"); success &= tree_def->getFastAttributeF32(billboard_ratio_string, F32_val); newTree->mBillboardRatio = F32_val; static LLStdStringHandle trunk_aspect_string = LLXmlTree::addAttributeString("trunk_aspect"); success &= tree_def->getFastAttributeF32(trunk_aspect_string, F32_val); newTree->mTrunkAspect = F32_val; static LLStdStringHandle branch_aspect_string = LLXmlTree::addAttributeString("branch_aspect"); success &= tree_def->getFastAttributeF32(branch_aspect_string, F32_val); newTree->mBranchAspect = F32_val; static LLStdStringHandle leaf_rotate_string = LLXmlTree::addAttributeString("leaf_rotate"); success &= tree_def->getFastAttributeF32(leaf_rotate_string, F32_val); newTree->mRandomLeafRotate = F32_val; static LLStdStringHandle noise_mag_string = LLXmlTree::addAttributeString("noise_mag"); success &= tree_def->getFastAttributeF32(noise_mag_string, F32_val); newTree->mNoiseMag = F32_val; static LLStdStringHandle noise_scale_string = LLXmlTree::addAttributeString("noise_scale"); success &= tree_def->getFastAttributeF32(noise_scale_string, F32_val); newTree->mNoiseScale = F32_val; static LLStdStringHandle taper_string = LLXmlTree::addAttributeString("taper"); success &= tree_def->getFastAttributeF32(taper_string, F32_val); newTree->mTaper = F32_val; static LLStdStringHandle repeat_z_string = LLXmlTree::addAttributeString("repeat_z"); success &= tree_def->getFastAttributeF32(repeat_z_string, F32_val); newTree->mRepeatTrunkZ = F32_val; sSpeciesTable[species] = newTree; if (species >= sMaxTreeSpecies) sMaxTreeSpecies = species + 1; if (!success) { std::string name; static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); tree_def->getFastAttributeString(name_string, name); llwarns << "Incomplete definition of tree " << name << llendl; } } BOOL have_all_trees = TRUE; std::string err; for (S32 i=0;i<sMaxTreeSpecies;++i) { if (!sSpeciesTable.count(i)) { err.append(llformat(" %d",i)); have_all_trees = FALSE; } } if (!have_all_trees) { LLSD args; args["SPECIES"] = err; LLNotifications::instance().add("ErrorUndefinedTrees", args); } };