Exemplo n.º 1
0
void LLObjectBackup::uploadNextAsset()
{
	if (mTexturesList.empty())
	{
		llinfos << "Texture list is empty, moving to rez stage." << llendl;
		mCurrentAsset = LLUUID::null;
		importFirstObject();
		return;
	}

	updateImportNumbers();

	std::list<LLUUID>::iterator iter;
	iter = mTexturesList.begin();
	LLUUID id = *iter;
	mTexturesList.pop_front();

	llinfos << "Got texture ID " << id << ": trying to upload" << llendl;

	mCurrentAsset = id;
	std::string struid;
	id.toString(struid);
	std::string filename = mFolder + "//" + struid;
	LLAssetID uuid;
	LLTransactionID tid;

	// generate a new transaction ID for this asset
	tid.generate();
	uuid = tid.makeAssetID(gAgent.getSecureSessionID());

	S32 file_size;
	LLAPRFile outfile;
	outfile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size);
	if (outfile.getFileHandle())
	{
		const S32 buf_size = 65536;	
		U8 copy_buf[buf_size];
		LLVFile file(gVFS, uuid,  LLAssetType::AT_TEXTURE, LLVFile::WRITE);
		file.setMaxSize(file_size);
		while ((file_size = outfile.read(copy_buf, buf_size)))
		{
			file.write(copy_buf, file_size);
		}
		outfile.close();
	}
	else
	{
		llwarns << "Unable to access output file " << filename << llendl;
		uploadNextAsset();
		return;
	}

	 myupload_new_resource(tid, LLAssetType::AT_TEXTURE, struid, struid, 0,
		LLAssetType::AT_TEXTURE, LLInventoryType::defaultForAssetType(LLAssetType::AT_TEXTURE),
		0x0, "Uploaded texture", NULL, NULL);
}
void LLObjectBackup::importObject_continued(AIFilePicker* filepicker)
{
	if (!filepicker->hasFilename())
	{
		// User canceled save.
		return;
	}
	
	std::string file_name = filepicker->getFilename();	
	mFolder = gDirUtilp->getDirName(file_name);
	llifstream import_file(file_name);
	LLSDSerialize::fromXML(mLLSD, import_file);
	import_file.close();
	show(false);

	mAgentPos = gAgent.getPositionAgent();
	mAgentRot = LLQuaternion(gAgent.getAtAxis(), gAgent.getLeftAxis(), gAgent.getUpAxis());

	// Get the texture map
	
	LLSD::map_const_iterator prim_it;
	LLSD::array_const_iterator prim_arr_it;
		
	mCurObject = 1;
	mCurPrim = 1;
	mObjects = mLLSD["data"].size();
	mPrims = 0;
	mRezCount = 0;
	updateImportNumbers();

	for (prim_arr_it = mLLSD["data"].beginArray(); prim_arr_it != mLLSD["data"].endArray(); prim_arr_it++)
	{
		LLSD llsd2 = (*prim_arr_it)["group_body"];

		for (prim_it = llsd2.beginMap(); prim_it != llsd2.endMap(); prim_it++)
		{
			LLSD prim_llsd = llsd2[prim_it->first];
			LLSD::array_iterator text_it;
			std::list<LLUUID>::iterator iter;

			if (prim_llsd.has("sculpt"))
			{
				LLSculptParams* sculpt = new LLSculptParams();
				sculpt->fromLLSD(prim_llsd["sculpt"]);
				LLUUID orig = sculpt->getSculptTexture();
				bool alreadyseen = false;
				for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++)
				{
					if ((*iter) == orig)
						alreadyseen = true;
				}
				if (alreadyseen == false)
				{
					LL_INFOS("ObjectBackup") << "Found a new SCULPT texture to upload " << orig << LL_ENDL;			
					mTexturesList.push_back(orig);
				}
			}

			LLSD te_llsd = prim_llsd["textures"];

			for (text_it = te_llsd.beginArray(); text_it != te_llsd.endArray(); text_it++)
			{
				LLSD the_te = (*text_it);
				LLTextureEntry te;
				te.fromLLSD(the_te);

				LLUUID id = te.getID();
				if (id != LL_TEXTURE_PLYWOOD && id != LL_TEXTURE_BLANK && id != LL_TEXTURE_INVISIBLE) // Do not upload the default textures
 				{
					bool alreadyseen = false;

					for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++)
					{
						if ((*iter) == te.getID())
							alreadyseen = true;
					}
					if (alreadyseen == false)
					{
						LL_INFOS("ObjectBackup") << "Found a new texture to upload "<< te.getID() << LL_ENDL;			
						mTexturesList.push_back(te.getID());
					}
				}	     
			}
		}
	}

	if (mRetexture == TRUE)
		uploadNextAsset();
	else
		importFirstObject();
}
void LLObjectBackup::importObject_continued(AIFilePicker* filepicker)
{
	if (!filepicker->hasFilename())
	{
		// User canceled save.
		return;
	}

	std::string file_name = filepicker->getFilename();
	mFolder = gDirUtilp->getDirName(file_name);
	llifstream import_file(file_name);
	LLSDSerialize::fromXML(mLLSD, import_file);
	import_file.close();
	if (!mLLSD.has("data"))
	{
		LLNotificationsUtil::add("ImportFailed");
		destroy();
		return;
	}

	showFloater(false);

	mAgentPos = gAgent.getPositionAgent();
	mAgentRot = LLQuaternion(gAgent.getAtAxis(), gAgent.getLeftAxis(),
							 gAgent.getUpAxis());

	// Get the texture map

	mCurObject = 1;
	mCurPrim = 1;
	mObjects = mLLSD["data"].size();
	mPrims = 0;
	mRezCount = 0;
	updateImportNumbers();

	for (LLSD::array_const_iterator prim_arr_it = mLLSD["data"].beginArray(),
									prim_arr_end = mLLSD["data"].endArray();
		 prim_arr_it != prim_arr_end; ++prim_arr_it)
	{
		LLSD llsd2 = (*prim_arr_it)["group_body"];

		for (LLSD::map_const_iterator prim_it = llsd2.beginMap(),
									  prim_end = llsd2.endMap();
			 prim_it != prim_end; ++prim_it)
		{
			LLSD prim_llsd = llsd2[prim_it->first];
			if (prim_llsd.has("sculpt"))
			{
				LLSculptParams sculpt;
				sculpt.fromLLSD(prim_llsd["sculpt"]);
				if ((sculpt.getSculptType() & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH)
				{
					LLUUID orig = sculpt.getSculptTexture();
					if (mTexturesList.count(orig) == 0)
					{
						LL_INFOS() << "Found a new SCULPT texture to upload "
								<< orig << LL_ENDL;
						mTexturesList.insert(orig);
					}
				}
			}

			if (prim_llsd.has("light_texture"))
			{
				LLLightImageParams lightimg;
				lightimg.fromLLSD(prim_llsd["light_texture"]);
				LLUUID t_id = lightimg.getLightTexture();
				if (!is_default_texture(t_id) &&
					mTexturesList.count(t_id) == 0)
				{
					LL_INFOS() << "Found a new light texture to upload: " << t_id
							<< LL_ENDL;
					mTexturesList.insert(t_id);
				}
			}

			// Check both for "textures" and "texture" since the second (buggy)
			// case has already been seen in some exported prims XML files...
			LLSD& te_llsd = prim_llsd.has("textures") ? prim_llsd["textures"]
													  : prim_llsd["texture"];
			for (LLSD::array_iterator it = te_llsd.beginArray();
				 it != te_llsd.endArray(); ++it)
			{
				LLSD the_te = *it;
				LLTextureEntry te;
				te.fromLLSD(the_te);

				LLUUID t_id = te.getID();
				if (!is_default_texture(t_id) &&
					mTexturesList.count(t_id) == 0)
				{
					LL_INFOS() << "Found a new texture to upload: " << t_id
							<< LL_ENDL;
						mTexturesList.insert(t_id);
				}
			}

			if (prim_llsd.has("materials"))
			{
				LLSD mat_llsd = prim_llsd["materials"];
				for (LLSD::array_iterator it = mat_llsd.beginArray();
					 it != mat_llsd.endArray(); ++it)
				{
					LLSD the_mat = *it;
					LLMaterial mat;
					mat.fromLLSD(the_mat);

					LLUUID t_id = mat.getNormalID();
					if (!is_default_texture(t_id) &&
						mTexturesList.count(t_id) == 0)
					{
						LL_INFOS() << "Found a new normal map to upload: "
								<< t_id << LL_ENDL;
						mTexturesList.insert(t_id);
					}

					t_id = mat.getSpecularID();
					if (!is_default_texture(t_id) &&
						mTexturesList.count(t_id) == 0)
					{
						LL_INFOS() << "Found a new specular map to upload: "
								<< t_id << LL_ENDL;
						mTexturesList.insert(t_id);
					}
				}
			}
		}
	}

	if (mRetexture)
	{
		uploadNextAsset();
	}
	else
	{
		importFirstObject();
	}
}
Exemplo n.º 4
0
void LLObjectBackup::importObject(bool upload)
{
	mTexturesList.clear();
	mAssetMap.clear();
	mCurrentAsset = LLUUID::null;

	mRetexture = upload;

	// Open the file open dialog
	LLFilePicker& file_picker = LLFilePicker::instance();
	if (!file_picker.getOpenFile(LLFilePicker::FFLOAD_XML))
	{
		// User canceled save.
		return;
	}

	std::string file_name = file_picker.getFirstFile().c_str();
	mFolder = gDirUtilp->getDirName(file_name);
	llifstream import_file(file_name);
	LLSDSerialize::fromXML(mLLSD, import_file);
	import_file.close();

	mAgentPos = gAgent.getPositionAgent();
	mAgentRot = LLQuaternion(gAgent.getAtAxis(), gAgent.getLeftAxis(), gAgent.getUpAxis());

	// Get the texture map
	
	LLSD::map_const_iterator prim_it;
	LLSD::array_const_iterator prim_arr_it;
		
	mCurObject = 1;
	mCurPrim = 1;
	mObjects = mLLSD["data"].size();
	mPrims = 0;
	mRezCount = 0;

	if (mObjects <= 0) {
		LLSD args;
		args["MESSAGE"] = std::string("Object import failed.\nThe XML file has an incompatble format or does not contain any objects.");
		LLNotifications::instance().add("GenericAlert", args);
		llwarns << "Trying to import illegal XML object file." << llendl;
		return;
	}

	show(false);

	updateImportNumbers();

	for (prim_arr_it = mLLSD["data"].beginArray(); prim_arr_it != mLLSD["data"].endArray(); prim_arr_it++)
	{
		LLSD llsd2 = (*prim_arr_it)["group_body"];

		for (prim_it = llsd2.beginMap(); prim_it != llsd2.endMap(); prim_it++)
		{
			LLSD prim_llsd = llsd2[prim_it->first];
			LLSD::array_iterator text_it;
			std::list<LLUUID>::iterator iter;

			if (prim_llsd.has("sculpt"))
			{
				LLSculptParams* sculpt = new LLSculptParams();
				sculpt->fromLLSD(prim_llsd["sculpt"]);
				LLUUID orig = sculpt->getSculptTexture();
				bool alreadyseen = false;
				for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++)
				{
					if ((*iter) == orig)
						alreadyseen = true;
				}
				if (alreadyseen == false)
				{
					llinfos << "Found a new SCULPT texture to upload " << orig << llendl;			
					mTexturesList.push_back(orig);
				}
			}

			LLSD te_llsd = prim_llsd["textures"];

			for (text_it = te_llsd.beginArray(); text_it != te_llsd.endArray(); text_it++)
			{
				LLSD the_te = (*text_it);
				LLTextureEntry te;
				te.fromLLSD(the_te);

				te.getID();
				bool alreadyseen = false;

				for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++)
				{
					if ((*iter) == te.getID())
						alreadyseen = true;
				}
				if (alreadyseen == false)
				{
					llinfos << "Found a new texture to upload "<< te.getID() << llendl;			
					mTexturesList.push_back(te.getID());
				}	     
			}
		}
	}

	if (mRetexture == TRUE)
		uploadNextAsset();
	else
		importFirstObject();
}