LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list, bool is_attachment) { LLViewerObject* object; LLSD llsd; char localid[16]; for (LLViewerObject::child_list_t::iterator i = child_list.begin(); i != child_list.end(); ++i) { object = (*i); LLUUID id = object->getID(); LL_INFOS("ObjectBackup") << "Exporting prim " << object->getID().asString() << LL_ENDL; // Create an LLSD object that represents this prim. It will be injected in to the overall LLSD // tree structure LLSD prim_llsd; if (!object->isRoot()) { // Parent id snprintf(localid, sizeof(localid), "%u", object->getSubParent()->getLocalID()); prim_llsd["parent"] = localid; } // Name and description LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->findNode(object); if (node) { prim_llsd["name"] = node->mName; prim_llsd["description"] = node->mDescription; } // Transforms if (is_attachment) { prim_llsd["position"] = object->getPositionEdit().getValue(); prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotationEdit()); } else { prim_llsd["position"] = object->getPosition().getValue(); prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotation()); } prim_llsd["scale"] = object->getScale().getValue(); // Flags prim_llsd["shadows"] = FALSE; prim_llsd["phantom"] = object->flagPhantom(); prim_llsd["physical"] = object->flagUsePhysics(); // Volume params LLVolumeParams params = object->getVolume()->getParams(); prim_llsd["volume"] = params.asLLSD(); // Extra paramsb6fab961-af18-77f8-cf08-f021377a7244 if (object->isFlexible()) { // Flexible LLFlexibleObjectData* flex = (LLFlexibleObjectData*)object->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE); prim_llsd["flexible"] = flex->asLLSD(); } if (object->getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT)) { // Light LLLightParams* light = (LLLightParams*)object->getParameterEntry(LLNetworkData::PARAMS_LIGHT); prim_llsd["light"] = light->asLLSD(); } if (object->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT)) { // Sculpt LLSculptParams* sculpt = (LLSculptParams*)object->getParameterEntry(LLNetworkData::PARAMS_SCULPT); prim_llsd["sculpt"] = sculpt->asLLSD(); LLUUID sculpt_texture = sculpt->getSculptTexture(); if (sculpt_texture == validateTextureID(sculpt_texture)) { bool alreadyseen = false; std::list<LLUUID>::iterator iter; for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++) { if ((*iter) == sculpt_texture) alreadyseen = true; } if (alreadyseen == false) { LL_INFOS("ObjectBackup") << "Found a sculpt texture, adding to list " << sculpt_texture << LL_ENDL; mTexturesList.push_back(sculpt_texture); } } else { LL_WARNS("ObjectBackup") << "Incorrect permission to export a sculpt texture." << LL_ENDL; LLObjectBackup::getInstance()->mExportState = EXPORT_FAILED; } } // Textures LLSD te_llsd; LLSD this_te_llsd; LLUUID t_id; U8 te_count = object->getNumTEs(); for (U8 i = 0; i < te_count; i++) { bool alreadyseen = false; t_id = validateTextureID(object->getTE(i)->getID()); this_te_llsd = object->getTE(i)->asLLSD(); this_te_llsd["imageid"] = t_id; te_llsd.append(this_te_llsd); // Do not export Linden textures even though they don't taint creation. if (t_id != LL_TEXTURE_PLYWOOD && t_id != LL_TEXTURE_BLANK && t_id != LL_TEXTURE_TRANSPARENT && t_id != LL_TEXTURE_INVISIBLE && t_id != LL_TEXTURE_MEDIA) { std::list<LLUUID>::iterator iter; for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++) { if ((*iter) == t_id) alreadyseen = true; } if (alreadyseen == false) mTexturesList.push_back(t_id); } } prim_llsd["textures"] = te_llsd; // The keys in the primitive maps do not have to be localids, they can be any // string. We simply use localids because they are a unique identifier snprintf(localid, sizeof(localid), "%u", object->getLocalID()); llsd[(const char*)localid] = prim_llsd; } updateExportNumbers(); return llsd; }
LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list, bool is_attachment) { LLViewerObject* object; LLSD llsd; char localid[16]; LLUUID t_id; for (LLViewerObject::child_list_t::iterator i = child_list.begin(); i != child_list.end(); ++i) { object = (*i); LLUUID id = object->getID(); LL_INFOS() << "Exporting prim " << object->getID().asString() << LL_ENDL; // Create an LLSD object that represents this prim. It will be injected // in to the overall LLSD tree structure LLSD prim_llsd; if (!object->isRoot()) { // Parent id snprintf(localid, sizeof(localid), "%u", object->getSubParent()->getLocalID()); prim_llsd["parent"] = localid; } // Name and description LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->findNode(object); if (node) { prim_llsd["name"] = node->mName; prim_llsd["description"] = node->mDescription; } // Transforms if (is_attachment) { prim_llsd["position"] = object->getPositionEdit().getValue(); prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotationEdit()); } else { prim_llsd["position"] = object->getPosition().getValue(); prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotation()); } prim_llsd["scale"] = object->getScale().getValue(); // Flags prim_llsd["phantom"] = object->flagPhantom(); // legacy prim_llsd["physical"] = object->flagUsePhysics(); // legacy prim_llsd["flags"] = (S32)object->getFlags(); // new way // Extra physics flags if (mGotExtraPhysics) { LLSD& physics = prim_llsd["ExtraPhysics"]; physics["PhysicsShapeType"] = object->getPhysicsShapeType(); physics["Gravity"] = object->getPhysicsGravity(); physics["Friction"] = object->getPhysicsFriction(); physics["Density"] = object->getPhysicsDensity(); physics["Restitution"] = object->getPhysicsRestitution(); } // Click action if (S32 action = object->getClickAction()) // Non-zero prim_llsd["clickaction"] = action; // Prim material prim_llsd["material"] = object->getMaterial(); // Volume params LLVolumeParams params = object->getVolume()->getParams(); prim_llsd["volume"] = params.asLLSD(); // Extra paramsb6fab961-af18-77f8-cf08-f021377a7244 if (object->isFlexible()) { // Flexible LLFlexibleObjectData* flex; flex = (LLFlexibleObjectData*)object->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE); prim_llsd["flexible"] = flex->asLLSD(); } if (object->getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT)) { // Light LLLightParams* light; light = (LLLightParams*)object->getParameterEntry(LLNetworkData::PARAMS_LIGHT); prim_llsd["light"] = light->asLLSD(); } if (object->getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE)) { // Light image LLLightImageParams* light_param; light_param = (LLLightImageParams*)object->getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE); t_id = validateTextureID(light_param->getLightTexture()); if (mTexturesList.count(t_id) == 0) { LL_INFOS() << "Found a light texture, adding to list " << t_id << LL_ENDL; mTexturesList.insert(t_id); } prim_llsd["light_texture"] = light_param->asLLSD(); } if (object->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT)) { // Sculpt LLSculptParams* sculpt; sculpt = (LLSculptParams*)object->getParameterEntry(LLNetworkData::PARAMS_SCULPT); prim_llsd["sculpt"] = sculpt->asLLSD(); if ((sculpt->getSculptType() & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH) { LLUUID sculpt_texture = sculpt->getSculptTexture(); if (sculpt_texture == validateTextureID(sculpt_texture)) { if (mTexturesList.count(sculpt_texture) == 0) { LL_INFOS() << "Found a sculpt texture, adding to list " << sculpt_texture << LL_ENDL; mTexturesList.insert(sculpt_texture); } } else { LL_WARNS() << "Incorrect permission to export a sculpt texture." << LL_ENDL; mExportState = EXPORT_FAILED; } } } // Textures and materials LLSD te_llsd; LLSD this_te_llsd; LLSD te_mat_llsd; LLSD this_te_mat_llsd; bool has_materials = false; for (U8 i = 0, count = object->getNumTEs(); i < count; ++i) { LLTextureEntry* te = object->getTE(i); if (!te) continue; // Paranoia // Normal texture/diffuse map t_id = validateTextureID(te->getID()); this_te_llsd = te->asLLSD(); this_te_llsd["imageid"] = t_id; te_llsd.append(this_te_llsd); // Do not export non-existent default textures if (t_id != LL_TEXTURE_BLANK && t_id != LL_TEXTURE_INVISIBLE) { if (mTexturesList.count(t_id) == 0) { mTexturesList.insert(t_id); } } // Materials LLMaterial* mat = te->getMaterialParams().get(); if (mat) { has_materials = true; this_te_mat_llsd = mat->asLLSD(); t_id = validateTextureID(mat->getNormalID()); this_te_mat_llsd["NormMap"] = t_id; if (mTexturesList.count(t_id) == 0) { mTexturesList.insert(t_id); } t_id = validateTextureID(mat->getSpecularID()); this_te_mat_llsd["SpecMap"] = t_id; if (mTexturesList.count(t_id) == 0) { mTexturesList.insert(t_id); } te_mat_llsd.append(this_te_mat_llsd); } } prim_llsd["textures"] = te_llsd; if (has_materials) { prim_llsd["materials"] = te_mat_llsd; } // The keys in the primitive maps do not have to be localids, they can // be any string. We simply use localids because they are a unique // identifier snprintf(localid, sizeof(localid), "%u", object->getLocalID()); llsd[(const char*)localid] = prim_llsd; } updateExportNumbers(); return llsd; }
void LLFloaterTools::refresh() { const S32 INFO_WIDTH = getRect().getWidth(); const S32 INFO_HEIGHT = 384; LLRect object_info_rect(0, 0, INFO_WIDTH, -INFO_HEIGHT); BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME ); S32 idx_features = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_FEATURES]); S32 idx_face = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_FACE]); S32 idx_contents = mTab->getPanelIndexByTitle(PANEL_NAMES[PANEL_CONTENTS]); S32 selected_index = mTab->getCurrentPanelIndex(); if (!all_volume && (selected_index == idx_features || selected_index == idx_face || selected_index == idx_contents)) { mTab->selectFirstTab(); } mTab->enableTabButton(idx_features, all_volume); mTab->enableTabButton(idx_face, all_volume); mTab->enableTabButton(idx_contents, all_volume); // Refresh object and prim count labels LLLocale locale(LLLocale::USER_LOCALE); // Added in Link Num value -HgB S32 object_count = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount(); S32 prim_count = LLSelectMgr::getInstance()->getEditSelection()->getObjectCount(); std::string value_string; std::string desc_string; if ((gSavedSettings.getBOOL("EditLinkedParts"))&&(prim_count == 1)) //Selecting a single prim in "Edit Linked" mode, show link number { desc_string = "Link number:"; LLViewerObject* selected = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); if (selected && selected->getRootEdit()) { LLViewerObject::child_list_t children = selected->getRootEdit()->getChildren(); if (children.empty()) { value_string = "0"; // An unlinked prim is "link 0". } else { children.push_front(selected->getRootEdit()); // need root in the list too S32 index = 0; for (LLViewerObject::child_list_t::iterator iter = children.begin(); iter != children.end(); ++iter) { index++; if ((*iter)->isSelected()) { LLResMgr::getInstance()->getIntegerString(value_string, index); break; } } } } } else { desc_string = "Selected objects:"; LLResMgr::getInstance()->getIntegerString(value_string, object_count); } childSetTextArg("link_num_obj_count", "[DESC]", desc_string); childSetTextArg("link_num_obj_count", "[NUM]", value_string); LLStringUtil::format_map_t selection_args; selection_args["COUNT"] = llformat("%.1d", (S32)prim_count); if(gMeshRepo.meshRezEnabled()) { F32 link_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectCost(); LLStringUtil::format_map_t prim_equiv_args; prim_equiv_args["SEL_WEIGHT"] = llformat("%.1d", (S32)link_cost); selection_args["PE_STRING"] = getString("status_selectprimequiv", prim_equiv_args); } else { selection_args["PE_STRING"] = ""; } std::string prim_count_string = getString("status_selectcount",selection_args); childSetText("prim_count", prim_count_string); // Refresh child tabs mPanelPermissions->refresh(); mPanelObject->refresh(); mPanelVolume->refresh(); mPanelFace->refresh(); mPanelContents->refresh(); mPanelLandInfo->refresh(); }
LLSD primbackup::prims_to_llsd(LLViewerObject::child_list_t child_list) { LLViewerObject* object; LLSD llsd; char localid[16]; for (LLViewerObject::child_list_t::iterator i = child_list.begin(); i != child_list.end(); ++i) { object=(*i); LLUUID id = object->getID(); llinfos << "Exporting prim " << object->getID().asString() << llendl; // Create an LLSD object that represents this prim. It will be injected in to the overall LLSD // tree structure LLSD prim_llsd; if (!object->isRoot()) { // Parent id snprintf(localid, sizeof(localid), "%u", object->getSubParent()->getLocalID()); prim_llsd["parent"] = localid; } // Transforms prim_llsd["position"] = object->getPosition().getValue(); prim_llsd["scale"] = object->getScale().getValue(); prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotation()); // Flags prim_llsd["shadows"] = object->flagCastShadows(); prim_llsd["phantom"] = object->flagPhantom(); prim_llsd["physical"] = (BOOL)(object->mFlags & FLAGS_USE_PHYSICS); // Volume params LLVolumeParams params = object->getVolume()->getParams(); prim_llsd["volume"] = params.asLLSD(); // Extra paramsb6fab961-af18-77f8-cf08-f021377a7244 if (object->isFlexible()) { // Flexible LLFlexibleObjectData* flex = (LLFlexibleObjectData*)object->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE); prim_llsd["flexible"] = flex->asLLSD(); } if (object->getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT)) { // Light LLLightParams* light = (LLLightParams*)object->getParameterEntry(LLNetworkData::PARAMS_LIGHT); prim_llsd["light"] = light->asLLSD(); } if (object->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT)) { // Sculpt LLSculptParams* sculpt = (LLSculptParams*)object->getParameterEntry(LLNetworkData::PARAMS_SCULPT); prim_llsd["sculpt"] = sculpt->asLLSD(); LLUUID sculpt_texture=sculpt->getSculptTexture(); bool alreadyseen=false; std::list<LLUUID>::iterator iter; for(iter = textures.begin(); iter != textures.end() ; iter++) { if( (*iter)==sculpt_texture) alreadyseen=true; } if(alreadyseen==false) { llinfos << "Found a sculpt texture, adding to list "<<sculpt_texture<<llendl; textures.push_back(sculpt_texture); } } // Textures LLSD te_llsd; U8 te_count = object->getNumTEs(); for (U8 i = 0; i < te_count; i++) { bool alreadyseen=false; te_llsd.append(object->getTE(i)->asLLSD()); std::list<LLUUID>::iterator iter; for(iter = textures.begin(); iter != textures.end() ; iter++) { if( (*iter)==object->getTE(i)->getID()) alreadyseen=true; } if(alreadyseen==false) textures.push_back(object->getTE(i)->getID()); } prim_llsd["textures"] = te_llsd; // The keys in the primitive maps do not have to be localids, they can be any // string. We simply use localids because they are a unique identifier snprintf(localid, sizeof(localid), "%u", object->getLocalID()); llsd[(const char*)localid] = prim_llsd; } updateexportnumbers(); return llsd; }