示例#1
0
	virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
	{
		NL3D::UInstance inst = Scene->createInstance("wind.ps");
		if (!inst.empty())
		{
			inst.setPos(MainCam.getPos());
		}
	}
示例#2
0
文件: misc.cpp 项目: AzyxWare/ryzom
// *************************************************************************************************
void setEmissive(NL3D::UInstance instance, const NLMISC::CRGBA &color)
{
	if (instance.empty()) return;
	for(uint k = 0; k < instance.getNumMaterials(); ++k)
	{
		NL3D::UInstanceMaterial mat = instance.getMaterial(k);
		mat.setEmissive(color);
	}
}
示例#3
0
//-----------------------------------------------
// updateVisualPropertyVpb :
// Update the Visual Property B.
//-----------------------------------------------
void CPlayerR2CL::updateVisualPropertyVpb(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop)
{
	// Get the property.
	SPropVisualB visualB = *(SPropVisualB *)(&prop);

	if(_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet)
	{
		NL3D::UInstance itemInstance = (!_Instances[SLOTTYPE::RIGHT_HAND_SLOT].Loading.empty()) ? _Instances[SLOTTYPE::RIGHT_HAND_SLOT].Loading : _Instances[SLOTTYPE::RIGHT_HAND_SLOT].Current;
		if (!itemInstance.empty())
		{
			// update fxs
			if ( _CurrentBehaviour.Behaviour != MBEHAV::EXTRACTING )
				_Items[SLOTTYPE::RIGHT_HAND_SLOT].setTrailSize(visualB.PropertySubData.RTrail);
		}
	}

	if(_Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet)
	{
		NL3D::UInstance itemInstance = (!_Instances[SLOTTYPE::LEFT_HAND_SLOT].Loading.empty()) ? _Instances[SLOTTYPE::LEFT_HAND_SLOT].Loading : _Instances[SLOTTYPE::LEFT_HAND_SLOT].Current;
		if (!itemInstance.empty())
		{
			// update fxs
			_Items[SLOTTYPE::LEFT_HAND_SLOT].setTrailSize(2 * (uint) visualB.PropertySubData.LTrail);
		}
	}

	if(skeleton())
	{
		// HANDS
		equip(SLOTTYPE::HANDS_SLOT, visualB.PropertySubData.HandsModel, visualB.PropertySubData.HandsColor);
		// FEET
		equip(SLOTTYPE::FEET_SLOT, visualB.PropertySubData.FeetModel, visualB.PropertySubData.FeetColor);
	}
	else
		nlinfo("PL::updateVPVpb:%d: Prop Vpb received before prop Vpa.", _Slot);
}// updateVisualPropertyVpb //
示例#4
0
文件: misc.cpp 项目: AzyxWare/ryzom
// *************************************************************************************************
void setDiffuse(NL3D::UInstance instance, bool onOff, const NLMISC::CRGBA &color)
{
	if (instance.empty()) return;
	for(uint k = 0; k < instance.getNumMaterials(); ++k)
	{
		NL3D::UInstanceMaterial mat = instance.getMaterial(k);
		if (mat.isLighted())
		{
			CRGBA src;
			if (onOff)
			{
				src = mat.getDiffuse();
				src.R = color.R;
				src.G = color.G;
				src.B = color.B;
			}
			else
			{
				NL3D::UMaterial			matShape = instance.getShape().getMaterial(k);
				src = matShape.getDiffuse();
				src.A = mat.getDiffuse().A;
			}
			mat.setDiffuse(src);
		}
		else
		{
			CRGBA src;
			if (onOff)
			{
				src = mat.getColor();
				src.R = color.R;
				src.G = color.G;
				src.B = color.B;
			}
			else
			{
				NL3D::UMaterial			matShape = instance.getShape().getMaterial(k);
				src = matShape.getColor();
				src.A = mat.getColor().A;
			}
			mat.setColor(src);
		}
	}
}
示例#5
0
void CIGSeasonCallback::instanceGroupAdded(NL3D::UInstanceGroup *ig)
{
	H_AUTO(RZ_IGSeasonCallback)
	// Set the season texture for all the buildings

	uint8 selectedTextureSet = (uint8) computeCurrSeason();

	const uint numInstances = ig->getNumInstance();
	for(uint k = 0; k < numInstances; k++)
	{
		NL3D::UInstance instance = ig->getInstance (k);
		if (!instance.empty())
			instance.selectTextureSet(selectedTextureSet);  // TODO Nico : instant loading here (async not useful)
	}
	// for all the bot objects, force to rebuild them to update their textures
	for (uint k = 0; k < CLFECOMMON::INVALID_SLOT; ++k)
	{
		CCharacterCL *charCL = dynamic_cast<CCharacterCL *>(EntitiesMngr.entity(k));
		if (charCL && charCL->getSheet())
		{
			std::string sheetName = charCL->getSheet()->Id.toString();
			static const  char *botObjectPrefix = "object_";
			if (NLMISC::nlstricmp(sheetName.substr(0, strlen(botObjectPrefix)), botObjectPrefix) == 0)
			{
				for(uint k = 0; k < charCL->instances().size(); ++k)
				{
					charCL->instances()[k].selectTextureSet(selectedTextureSet, false); // want immediate change here (frozen any way ...)
				}
				if (!charCL->instance().empty())
				{
					charCL->instance().selectTextureSet(selectedTextureSet);
				}
			}
		}
	}
}
示例#6
0
//-----------------------------------------------
// updateVisualPropertyVpa :
// Update the Visual Property A.
// \todo GUIGUI : utiliser l'enum gender.
//-----------------------------------------------
void CPlayerR2CL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop)
{
	CInterfaceManager *IM = CInterfaceManager::getInstance ();

	// Player will now have enough informations to display the character.
	_WaitForAppearance = false;

	// Get the property.
	SPropVisualA visualA = *(SPropVisualA *)(&prop);

	// GENDER
	_Gender = (GSGENDER::EGender)_Sheet->Gender;
	if(_Gender!=GSGENDER::male && _Gender!=GSGENDER::female)
	{
		nlwarning("PL::updateVPVpa:%d: neither a male nor a female -> male selected.", _Slot);
		_Gender = GSGENDER::male;
	}

	// update title when gender changed
	const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw,_Gender == GSGENDER::female));
	if (!replacement.empty())
	{
		// Get extended name
		_NameEx = replacement;
		_Title = replacement;

		// rebuild in scene interface
		buildInSceneInterface();
	}

	// Setup _CharacterScalePos
	_CharacterScalePos = _Sheet->CharacterScalePos;

	// Check if skeleton has changed
	if (_CacheSkeletonShapeName != _Sheet->getSkelFilename())
	{
		_CacheSkeletonShapeName = _Sheet->getSkelFilename();

		// Clean the playlist.
		if(_PlayList)
			_PlayList->resetAllChannels();

		// We can now build the skeleton so do it now.
		skeleton(_CacheSkeletonShapeName);

		// Invalidate instances cache
		for (uint i = 0; i < _Instances.size(); ++i)
			_Instances[i].CurrentName = _Instances[i].LoadingName = "";
		_Face.CurrentName = _Face.LoadingName = "";
	}
	// Check the skeleton.
	if(skeleton() && !ClientCfg.Light)
	{
		// To re-link the skeleton to the mount if needed.
		parent(parent());
		// Set the skeleton scale.
		// \todo GUIGUI: mettre le scale aussi dans race_stats.
		// Setup Lod Character skeleton, if skeleton exist
		// Get Lod Character Id from the sheet.
		sint clodId= getLodCharacterId(*Scene, _Sheet->getLodCharacterName());
		if(clodId>=0)
		{
			// Setup Lod Character shape and distance
			skeleton()->setLodCharacterShape(clodId);
			skeleton()->setLodCharacterDistance(_Sheet->LodCharacterDistance);
		}
		// Compute the
		computeSomeBoneId();

		// CHEST
		equip(SLOTTYPE::CHEST_SLOT, visualA.PropertySubData.JacketModel, visualA.PropertySubData.JacketColor);
		// LEGS
		equip(SLOTTYPE::LEGS_SLOT, visualA.PropertySubData.TrouserModel, visualA.PropertySubData.TrouserColor);
		// ARMS
		equip(SLOTTYPE::ARMS_SLOT, visualA.PropertySubData.ArmModel, visualA.PropertySubData.ArmColor);
		// HAT
		equip(SLOTTYPE::HEAD_SLOT, visualA.PropertySubData.HatModel, visualA.PropertySubData.HatColor);
		// OBJECT in the RIGHT HAND
		bool changeWeapon = false;
		const CItemSheet *  oldRightSheet = _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet;
		const CItemSheet *  newRightSheet = SheetMngr.getItem(SLOTTYPE::RIGHT_HAND_SLOT, visualA.PropertySubData.WeaponRightHand);
		if((oldRightSheet && newRightSheet && oldRightSheet->Id!=newRightSheet->Id) || (!oldRightSheet && newRightSheet))
		{
			changeWeapon = true;
		}
		_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet = SheetMngr.getItem(SLOTTYPE::RIGHT_HAND_SLOT, visualA.PropertySubData.WeaponRightHand);
		// Equip the weapon(object/tool).
		if(_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet)
		{
			if(_Gender == GSGENDER::female)
				equip(SLOTTYPE::RIGHT_HAND_SLOT, _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->getShapeFemale(), _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet);
			else
				equip(SLOTTYPE::RIGHT_HAND_SLOT, _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->getShape(), _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet);

			NL3D::UInstance itemInstance = (!_Instances[SLOTTYPE::RIGHT_HAND_SLOT].Loading.empty()) ? _Instances[SLOTTYPE::RIGHT_HAND_SLOT].Loading : _Instances[SLOTTYPE::RIGHT_HAND_SLOT].Current;
			if (!itemInstance.empty())
			{
				// update fxs
				_Items[SLOTTYPE::RIGHT_HAND_SLOT].enableAdvantageFX(itemInstance);
				if ( _CurrentBehaviour.Behaviour != MBEHAV::EXTRACTING )
					_Items[SLOTTYPE::RIGHT_HAND_SLOT].setTrailSize(0);
					//_Items[SLOTTYPE::RIGHT_HAND_SLOT].setTrailSize(visualA.PropertySubData.RTrail);
			}
		}
		else
		{
			// No Valid item in the right hand.
			equip(SLOTTYPE::RIGHT_HAND_SLOT, "");
		}

		// OBJECT in the LEFT HAND
		const CItemSheet *  oldLeftSheet = _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet;
		const CItemSheet *  newLeftSheet = SheetMngr.getItem(SLOTTYPE::LEFT_HAND_SLOT, visualA.PropertySubData.WeaponLeftHand);
		if((oldLeftSheet && newLeftSheet && oldLeftSheet->Id!=newLeftSheet->Id) || (!oldLeftSheet && newLeftSheet))
		{
			changeWeapon = true;
		}

		_Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet = SheetMngr.getItem(SLOTTYPE::LEFT_HAND_SLOT, visualA.PropertySubData.WeaponLeftHand);
		// Equip the weapon(object/tool).
		if(_Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet)
		{
			equip(SLOTTYPE::LEFT_HAND_SLOT, _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet->getShape(), _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet);
			NL3D::UInstance itemInstance = (!_Instances[SLOTTYPE::LEFT_HAND_SLOT].Loading.empty()) ? _Instances[SLOTTYPE::LEFT_HAND_SLOT].Loading : _Instances[SLOTTYPE::LEFT_HAND_SLOT].Current;
			if (!itemInstance.empty())
			{
				// update fxs
				_Items[SLOTTYPE::LEFT_HAND_SLOT].enableAdvantageFX(itemInstance);
				_Items[SLOTTYPE::LEFT_HAND_SLOT].setTrailSize(0);
				//_Items[SLOTTYPE::LEFT_HAND_SLOT].setTrailSize(2 * (uint) visualA.PropertySubData.LTrail);
			}
		}
		else
		{
			// No Valid item in the left hand.
			equip(SLOTTYPE::LEFT_HAND_SLOT, "");
		}
		// Create face
		// Only create a face when there is no Helmet
		if(_Items[SLOTTYPE::HEAD_SLOT].Sheet == 0 || _Items[SLOTTYPE::HEAD_SLOT].Sheet->Family != ITEMFAMILY::ARMOR)
		{
			CItemSheet *faceItem = getItem(*getGenderInfo(), SLOTTYPE::FACE_SLOT);
			if (faceItem)
			{
				string sFaceName;

				if(_Gender == GSGENDER::female)
					sFaceName = faceItem->getShapeFemale();
				else
					sFaceName = faceItem->getShape();

				if (((!_Face.Loading.empty()) && (_Face.LoadingName != sFaceName)) ||
					((!_Face.Current.empty()) && (_Face.CurrentName != sFaceName)) ||
					(_Face.Current.empty()))
				{
					if (!_Face.Loading.empty())
					{
						Scene->deleteInstance(_Face.Loading);
						_Face.Loading = NULL;
						_Face.LoadingName = sFaceName;
					}
					_Face.Loading = Scene->createInstance(sFaceName);
					if (!_Face.Loading.empty())
					{
						_Face.LoadingName = sFaceName;
						if(!skeleton()->bindSkin(_Face.Loading))
							nlwarning("PL::updateVPVpa:%d: Cannot bind the face.", _Slot);
						_Face.Loading.hide();
						// set it async for texture
						_Face.Loading.enableAsyncTextureMode(true);
					}
					else
						nlwarning("PL::updateVPVpa:%d: Cannot create the face.", _Slot);
				}
				_Face.TextureSet = faceItem->MapVariant;
				applyColorSlot(_Face, skin(), 0, visualA.PropertySubData.HatColor, 0); // Set a default ruflaket color.
			}
			else
				nlwarning("PL::updateVPVpa:%d: Face Item '%s' does not exist.", _Slot,
					getGenderInfo()->Items[SLOTTYPE::FACE_SLOT].c_str());
		}
		else
		{
			// There is a helmet !
			if (!_Face.Loading.empty())
				Scene->deleteInstance(_Face.Loading);
			_Face.Loading = NULL;
			_Face.LoadingName = "";
			if (!_Face.Current.empty())
				Scene->deleteInstance(_Face.Current);
			_Face.Current = NULL;
			_Face.CurrentName = "";
		}
		// Now we have a skeleton, we can update VpB and VpC.
		sint64 vB, vC;
		string propName;
		propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPB);
		vB = IM->getDbProp(propName)->getValue64();
		propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPC);
		vC = IM->getDbProp(propName)->getValue64();
		updateVisualPropertyVpb(0, vB);
		updateVisualPropertyVpc(0, vC);

		// Attach The Light if there is one.
		if(!_Light.empty() && _NameBoneId!=-1)
			_Skeleton.stickObject(_Light, _NameBoneId);

		if(changeWeapon)
		{
			// Compute the new animation set to use (due to weapons).
			computeAnimSet();

			// Set the animation to idle.
			setAnim(CAnimationStateSheet::Idle);
		}
	}
	// No skeleton
	else
		nlwarning("PL::updateVPVpa:%d: Skeleton not allocated.", _Slot);
}// updateVisualPropertyVpa //