void llsdutil_object::test<7>()
	{
		LLSD sd;
		LLQuaternion quat((F32) 1., (F32) -0.98, (F32) 2.3, (F32) 0xffff);
		sd = ll_sd_from_quaternion(quat); 
		LLQuaternion quat1 = ll_quaternion_from_sd(sd);
		ensure_equals("LLQuaternion -> sd -> LLQuaternion", quat, quat1);
		
		LLSD sd2 = ll_sd_from_quaternion(quat1); 
		ensure_equals("sd -> LLQuaternion -> sd ", sd, sd2);
	}
Example #2
0
void primbackup::import_next_object()
{
	toselect.clear();
	rezcount=0;

	this_group=(*group_prim_import_iter)["group_body"];
	prim_import_iter=this_group.beginMap();

	m_curprim=0;
	m_prims=this_group.size();
	updateimportnumbers();
	LLVector3 lgpos=(*group_prim_import_iter)["root_position"];

	group_offset=lgpos-root_root_pos;
	root_pos=offset_agent(LLVector3(2.0,0,0));
	root_rot=ll_quaternion_from_sd((*group_prim_import_iter)["root_rotation"]);
	
	rez_agent_offset(LLVector3(0.0,2.0,0.0));
	// Now we must wait for the callback when ViewerObjectList gets the new objects and we have the correct number selected
}
void LLObjectBackup::importNextObject()
{
	mToSelect.clear();
	mRezCount = 0;

	mThisGroup = (*mGroupPrimImportIter)["group_body"];
	mPrimImportIter = mThisGroup.beginMap();

	mCurPrim = 0;
	mPrims = mThisGroup.size();
	updateImportNumbers();

	LLVector3 lgpos = (*mGroupPrimImportIter)["root_position"];
	mGroupOffset = lgpos - mRootRootPos;
	mRootPos = offsetAgent(LLVector3(2.0, 0.0, 0.0));
	mRootRot = ll_quaternion_from_sd((*mGroupPrimImportIter)["root_rotation"]);

	rezAgentOffset(LLVector3(0.0, 2.0, 0.0));
	// Now we must wait for the callback when ViewerObjectList gets the new objects and we have the correct number selected
}
Example #4
0
void LLAgentListener::startAutoPilot(LLSD const & event_data)
{
    LLQuaternion target_rotation_value;
    LLQuaternion* target_rotation = NULL;
    if (event_data.has("target_rotation"))
    {
        target_rotation_value = ll_quaternion_from_sd(event_data["target_rotation"]);
        target_rotation = &target_rotation_value;
    }
    // *TODO: Use callback_pump and callback_data
    F32 rotation_threshold = 0.03f;
    if (event_data.has("rotation_threshold"))
    {
        rotation_threshold = event_data["rotation_threshold"].asReal();
    }
	
	BOOL allow_flying = TRUE;
	if (event_data.has("allow_flying"))
	{
		allow_flying = (BOOL) event_data["allow_flying"].asBoolean();
		mAgent.setFlying(allow_flying);
	}

	F32 stop_distance = 0.f;
	if (event_data.has("stop_distance"))
	{
		stop_distance = event_data["stop_distance"].asReal();
	}

	// Clear follow target, this is doing a path
	mFollowTarget.setNull();

    mAgent.startAutoPilotGlobal(ll_vector3d_from_sd(event_data["target_global"]),
                                event_data["behavior_name"],
                                target_rotation,
                                NULL, NULL,
                                stop_distance,
                                rotation_threshold,
								allow_flying);
}
Example #5
0
//LLImportObject::LLImportObject(std::string id, std::string parentId)
//	:	LLViewerObject(LLUUID::null, 9, NULL, TRUE),
//		mId(id),
//		mParentId(parentId),
//		mPrimName("Object")
//{
//	importIsAttachment = false;
//}
LLImportObject::LLImportObject(std::string id, LLSD prim)
	:	LLViewerObject(LLUUID::null, 9, NULL, TRUE)
{
	importIsAttachment = false;
	mId = id;
	mParentId = "";
	mPrimName = "Object";
	if(prim.has("parent"))
	{
		mParentId = prim["parent"].asString();
	}
	// Stuff for attach
	if(prim.has("attach"))
	{
		importIsAttachment = true;
		importAttachPoint = (U8)prim["attach"].asInteger();
		importAttachPos = ll_vector3_from_sd(prim["position"]);
		importAttachRot = ll_quaternion_from_sd(prim["rotation"]);
	}
	// Transforms
	setPosition(ll_vector3_from_sd(prim["position"]), FALSE);
	setScale(ll_vector3_from_sd(prim["scale"]), FALSE);
	setRotation(ll_quaternion_from_sd(prim["rotation"]), FALSE);
	// Flags
	setFlags(FLAGS_CAST_SHADOWS, prim["shadows"].asInteger());
	setFlags(FLAGS_PHANTOM, prim["phantom"].asInteger());
	setFlags(FLAGS_USE_PHYSICS, prim["physical"].asInteger());
	// Volume params
	LLVolumeParams volume_params;
	volume_params.fromLLSD(prim["volume"]);
	
	setVolume(volume_params, 0, false);
	// Extra params
	if(prim.has("flexible"))
	{
		LLFlexibleObjectData* wat = new LLFlexibleObjectData();
		wat->fromLLSD(prim["flex"]);
		LLFlexibleObjectData flex = *wat;
		setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, flex, true);
		setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, TRUE, true);
	}
	if(prim.has("light"))
	{
		LLLightParams* wat = new LLLightParams();
		wat->fromLLSD(prim["light"]);
		LLLightParams light = *wat;
		setParameterEntry(LLNetworkData::PARAMS_LIGHT, light, true);
		setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, TRUE, true);
	}
	if(prim.has("sculpt"))
	{
		LLSculptParams *wat = new LLSculptParams();
		wat->fromLLSD(prim["sculpt"]);
		LLSculptParams sculpt = *wat;
		if(sculpt.getSculptType() == 5)//5 is apparently mesh... yeah.
		{
			llinfos << "Oh no mesh, f**k you." << llendl;
			sculpt.setSculptType(0);//f**k you
		}
		setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true);
		setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, true);
	}
	// Textures
	LLSD textures = prim["textures"];
	LLSD::array_iterator array_iter = textures.beginArray();
	LLSD::array_iterator array_end = textures.endArray();
	int i = 0;
	for( ; array_iter != array_end; ++array_iter)
	{
		LLTextureEntry* wat = new LLTextureEntry();
		wat->fromLLSD(*array_iter);
		LLTextureEntry te = *wat;
		delete wat; //clean up yo memory
		mTextures.push_back(te.getID());
		setTE(i, te);
		i++;
	}
	mTextures.unique();
	if(prim.has("name"))
	{
		mPrimName = prim["name"].asString();
	}
	if(prim.has("description"))
	{
		mPrimDescription = prim["description"].asString();
	}
}
//virtual 
void LLSDMessageReader::getQuat(const char *block, const char *var,
								 LLQuaternion &q, S32 blocknum)
{
	q = ll_quaternion_from_sd(getLLSD(mMessage, block, var, blocknum));
}
Example #7
0
// This function takes a pointer to a viewerobject and applys the prim definition that prim_llsd has
void primbackup::xmltoprim(LLSD prim_llsd,LLViewerObject * object)
{
	LLUUID id = object->getID();
	expecting_update = object->getID();
	LLSelectMgr::getInstance()->selectObjectAndFamily(object);

	if(prim_llsd.has("parent"))
	{
		//we are not the root node.
		LLVector3 pos=prim_llsd["position"];
		LLQuaternion rot=ll_quaternion_from_sd(prim_llsd["rotation"]);
		object->setPositionRegion((pos*root_rot)+(root_pos+group_offset));
		object->setRotation(rot*root_rot);
	}
	else
	{
		object->setPositionRegion(root_pos+group_offset);
		LLQuaternion rot=ll_quaternion_from_sd(prim_llsd["rotation"]);
		object->setRotation(rot);
	}

	object->setScale(prim_llsd["scale"]);

	if(prim_llsd.has("shadows"))
		if(prim_llsd["shadows"].asInteger()==1)
			object->setFlags(FLAGS_CAST_SHADOWS,true);

	if(prim_llsd.has("phantom"))
		if(prim_llsd["phantom"].asInteger()==1)
			object->setFlags(FLAGS_PHANTOM,true);

	if(prim_llsd.has("physical"))
		if(prim_llsd["physical"].asInteger()==1)
			object->setFlags(FLAGS_USE_PHYSICS,true);

	// Volume params
	LLVolumeParams volume_params = object->getVolume()->getParams();
	volume_params.fromLLSD(prim_llsd["volume"]) ;
	object->updateVolume(volume_params);
	
	if(prim_llsd.has("sculpt"))
	{
		LLSculptParams* sculpt=new LLSculptParams();
		sculpt->fromLLSD(prim_llsd["sculpt"]);
		
		//TODO check if map is valid and only set texture is map is valid and changes

		if(assetmap[sculpt->getSculptTexture()].notNull())
		{
			LLUUID replacment=assetmap[sculpt->getSculptTexture()];
			sculpt->setSculptTexture(replacment);
		}

		object->setParameterEntry(LLNetworkData::PARAMS_SCULPT,(LLNetworkData&)(*sculpt),true);
	}
		
	if(prim_llsd.has("light"))
	{
		LLLightParams * light=new LLLightParams();
		light->fromLLSD(prim_llsd["light"]);
		object->setParameterEntry(LLNetworkData::PARAMS_LIGHT,(LLNetworkData&)(*light),true);
	}

	if(prim_llsd.has("flexible"))
	{
		LLFlexibleObjectData* flex=new LLFlexibleObjectData();
		flex->fromLLSD(prim_llsd["flexible"]);
		object->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE,(LLNetworkData&)(*flex),true);
	}


	// Textures
	LLSD te_llsd;
	llinfos << "Processing textures for prim" << llendl;

	te_llsd=prim_llsd["textures"];
		
	LLSD::array_iterator text_it;
	U8 i=0;
	i=0;

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

		if(assetmap[te.getID()].notNull())
		{
			LLUUID replacment=assetmap[te.getID()];
			te.setID(replacment);
		}

	    object->setTE(i,te); //	
	    i++;
	}

	llinfos << "Textures done!" << llendl;

	//bump the iterator now so the callbacks hook together nicely
	//if(prim_import_iter!=this_group.endMap())
	//	prim_import_iter++;

    object->sendRotationUpdate();
	object->sendTEUpdate();	
	object->sendShapeUpdate();
	LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_SCALE |UPD_POSITION);

	LLSelectMgr::getInstance()->deselectAll();	
}
// This function takes a pointer to a viewerobject and applies the prim
// definition that prim_llsd has
void LLObjectBackup::xmlToPrim(LLSD prim_llsd, LLViewerObject* object)
{
	LLUUID id = object->getID();
	mExpectingUpdate = object->getID();
	LLSelectMgr::getInstance()->selectObjectAndFamily(object);

	if (prim_llsd.has("name"))
	{
		LLSelectMgr::getInstance()->selectionSetObjectName(prim_llsd["name"]);
	}

	if (prim_llsd.has("description"))
	{
		LLSelectMgr::getInstance()->selectionSetObjectDescription(prim_llsd["description"]);
	}

	if (prim_llsd.has("material"))
	{
		LLSelectMgr::getInstance()->selectionSetMaterial(prim_llsd["material"].asInteger());
	}

	if (prim_llsd.has("clickaction"))
	{
		LLSelectMgr::getInstance()->selectionSetClickAction(prim_llsd["clickaction"].asInteger());
	}

	if (prim_llsd.has("parent"))
	{
		//we are not the root node.
		LLVector3 pos = LLVector3(prim_llsd["position"]);
		LLQuaternion rot = ll_quaternion_from_sd(prim_llsd["rotation"]);
		object->setPositionRegion(pos * mRootRot + mRootPos + mGroupOffset);
		object->setRotation(rot * mRootRot);
	}
	else
	{
		object->setPositionRegion(mRootPos + mGroupOffset);
		LLQuaternion rot=ll_quaternion_from_sd(prim_llsd["rotation"]);
		object->setRotation(rot);
	}

	object->setScale(LLVector3(prim_llsd["scale"]));

	if (prim_llsd.has("flags"))
	{
		U32 flags = (U32)prim_llsd["flags"].asInteger();
		object->setFlags(flags, true);
	}
	else	// Kept for backward compatibility
	{
		/*if (prim_llsd.has("shadows"))
			if (prim_llsd["shadows"].asInteger() == 1)
				object->setFlags(FLAGS_CAST_SHADOWS, true);*/

		if (prim_llsd.has("phantom") && prim_llsd["phantom"].asInteger() == 1)
		{
				object->setFlags(FLAGS_PHANTOM, true);
		}

		if (prim_llsd.has("physical") &&
			prim_llsd["physical"].asInteger() == 1)
		{
			object->setFlags(FLAGS_USE_PHYSICS, true);
		}
	}

	if (mGotExtraPhysics && prim_llsd.has("ExtraPhysics"))
	{
		const LLSD& physics = prim_llsd["ExtraPhysics"];
		object->setPhysicsShapeType(physics["PhysicsShapeType"].asInteger());
		F32 gravity = physics.has("Gravity") ? physics["Gravity"].asReal()
											 : physics["GravityMultiplier"].asReal();
		object->setPhysicsGravity(gravity);
		object->setPhysicsFriction(physics["Friction"].asReal());
		object->setPhysicsDensity(physics["Density"].asReal());
		object->setPhysicsRestitution(physics["Restitution"].asReal());
		object->updateFlags(true);
	}

	// Volume params
	LLVolumeParams volume_params = object->getVolume()->getParams();
	volume_params.fromLLSD(prim_llsd["volume"]);
	object->updateVolume(volume_params);

	if (prim_llsd.has("sculpt"))
	{
		LLSculptParams sculpt;
		sculpt.fromLLSD(prim_llsd["sculpt"]);

		// TODO: check if map is valid and only set texture if map is valid and
		// changes
		LLUUID t_id = sculpt.getSculptTexture();
		if (mAssetMap.count(t_id))
		{
			sculpt.setSculptTexture(mAssetMap[t_id], sculpt.getSculptType());
		}

		object->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true);
	}
		
	if (prim_llsd.has("light"))
	{
		LLLightParams light;
		light.fromLLSD(prim_llsd["light"]);
		object->setParameterEntry(LLNetworkData::PARAMS_LIGHT, light, true);
	}
	if (prim_llsd.has("light_texture"))
	{
		// Light image
		LLLightImageParams lightimg;
		lightimg.fromLLSD(prim_llsd["light_texture"]);
		LLUUID t_id = lightimg.getLightTexture();
		if (mAssetMap.count(t_id))
		{
			lightimg.setLightTexture(mAssetMap[t_id]);
		}
		object->setParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE, lightimg,
								  true);
	}

	if (prim_llsd.has("flexible"))
	{
		LLFlexibleObjectData flex;
		flex.fromLLSD(prim_llsd["flexible"]);
		object->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, flex, true);
	}

	// Textures
	// Check both for "textures" and "texture" since the second (buggy) case
	// has already been seen in some exported prims XML files...
	LL_INFOS() << "Processing textures for prim" << id << LL_ENDL;
	LLSD& te_llsd = prim_llsd.has("textures") ? prim_llsd["textures"]
											  : prim_llsd["texture"];
	U8 i = 0;
	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 (mAssetMap.count(t_id))
		{
			te.setID(mAssetMap[t_id]);
		}

	    object->setTE(i++, te);
	}
	LL_INFOS() << "Textures done !" << LL_ENDL;

	// Materials
	if (prim_llsd.has("materials"))
	{
		LL_INFOS() << "Processing materials for prim " << id << LL_ENDL;
		te_llsd = prim_llsd["materials"];
		i = 0;
		for (LLSD::array_iterator it = te_llsd.beginArray();
			 it != te_llsd.endArray(); ++it)
		{
		    LLSD the_mat = *it;
			LLMaterialPtr mat = new LLMaterial(the_mat);

			LLUUID t_id = mat->getNormalID();
			if (id.notNull() && mAssetMap.count(t_id))
			{
				mat->setNormalID(mAssetMap[t_id]);
			}

			t_id = mat->getSpecularID();
			if (id.notNull() && mAssetMap.count(t_id))
			{
				mat->setSpecularID(mAssetMap[t_id]);
			}

			LLMaterialMgr::getInstance()->put(id, i++, *mat);
		}
		LL_INFOS() << "Materials done !" << LL_ENDL;
	}

	object->sendRotationUpdate();
	object->sendTEUpdate();	
	object->sendShapeUpdate();
	LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_SCALE | UPD_POSITION);

	LLSelectMgr::getInstance()->deselectAll();
}