Пример #1
0
//-----------------------------------------------
// makeUp :
// \param face : pointer on the face to make up (must not be null).
// \param idMakeUp : index of the make-up to apply.
// \warning This function does not check if 'face'  is valid.
//-----------------------------------------------
void makeUp(NL3D::UInstance face, sint idMakeUp)
{
	static const char *tattooStr = "visage_makeup";

	// look for tattoo texture
	uint numMat = face.getNumMaterials();
	std::string texFilename;
	for(uint k = 0; k < numMat; ++k)
	{
		UInstanceMaterial im = face.getMaterial(k);
		sint numTex = im.getLastTextureStage();
		for(sint l = 0; l <= numTex; ++l)
		{
			if (im.isTextureFile(l)) // one texture from a file ?
			{
				// see if it is the texture used for tattoos
				texFilename = im.getTextureFileName(l);
				// nlinfo("visage tex = %s", texFilename.c_str());
				std::string::size_type pos = texFilename.find(tattooStr, 0);
				if (pos != std::string::npos)
				{
					uint charIndex = (uint)(pos + strlen(tattooStr));
					if (texFilename.length() >= charIndex + 2)
					{
						texFilename[charIndex] = '0' + (unsigned char) (idMakeUp / 10);
						texFilename[charIndex + 1] = '0' + (unsigned char) (idMakeUp % 10);
						im.setTextureFileName(texFilename, l);
					}
				}
			}
		}
	}
}// makeUp //
Пример #2
0
	virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
	{
		NL3D::UInstance inst = Scene->createInstance("wind.ps");
		if (!inst.empty())
		{
			inst.setPos(MainCam.getPos());
		}
	}
Пример #3
0
// *************************************************************************************************
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);
	}
}
Пример #4
0
void initInventoryScene()
{
	map<uint32, NL3D::UInstance*>::iterator	itu;
	for(itu = InventoryItems.begin(); itu!=InventoryItems.end(); itu++)
	{
		InventoryScene->deleteInstance( (*itu).second);
	}
	InventoryItems.clear();
//	invSelectPS->setPos (0.0f, 0.0f, 0.0f);
//	invSelectPS->setScale( 1.0f, 1.0f, 1.0f );
	if (ShowDebugInChat) nlinfo("InvScene cleared");
	placeInList=0;
	map<uint32,uint8>::iterator	it;
	for(it = CharacterInventory._Inventory.begin(); it!=CharacterInventory._Inventory.end(); it++)
	{
	if (ShowDebugInChat) nlinfo(". %d",placeInList);
		placeInList++;
		if ((*it).second==1)
		{
//			DIT dynamicObject = DynamicObjects.find ((*it).first);
//			CClientDynamicObject	&dynamicObjecta = dynamicObject->second; // hack
//			if (dynamicObjecta.MeshName=="") dynamicObjecta.MeshName = "MagicWand01.shape";
//			UInstance* dynamicInventoryItem = InventoryScene->createInstance( dynamicObjecta.MeshName );
//			dynamicInventoryItem->setPos (-1.0f, 3.5f, placeInList*-0.5f);
//			dynamicInventoryItem->setScale( CVector(0.2f, 0.2f, 0.2f	 ));
//			InventoryItems.insert(make_pair (dynamicObjecta.Id, dynamicInventoryItem));
//			PlaceInInventoryList.insert(make_pair (dynamicObjecta.Id, placeInList));
		}
		else if ((*it).second==2)
		{
			FIT dynamicFirearmObject = Firearms.find ((*it).first);
			CClientFirearm &dynamicFirearmObjecta = dynamicFirearmObject->second; // hack
			if (dynamicFirearmObjecta.MeshName=="") dynamicFirearmObjecta.MeshName = "handgun.shape";
			NL3D::UInstance* dynamicInventoryItem = InventoryScene->createInstance( dynamicFirearmObjecta.MeshName );
			dynamicInventoryItem->setPos (-2.0f, 4.5f, placeInList*-0.4f);
			InventoryItems.insert(make_pair (dynamicFirearmObjecta.Id, dynamicInventoryItem));
			PlaceInInventoryList.insert(make_pair (dynamicFirearmObjecta.Id, placeInList));
		}
		if ((*it).first==CharacterInventory.getSelected())
		{
//			nlinfo("setting select particle system");
//			invSelectPS->show();
//			invSelectPS->setPos (-2.0f, 4.5f, (placeInList*-1.0f)+0.7f);
//			invSelectPS->setScale( 0.3f, 0.3f, 0.3f );
		}

	}
	sendSelectedInInventory( CharacterInventory.getSelected() );
	
}
Пример #5
0
// *********************************************************
void CPrimRender::updateEdge(NL3D::UInstance edge,const NLMISC::CVector &start, const NLMISC::CVector &end)
{
	//H_AUTO(R2_CPrimRender_updateEdge)
	CVector I = end - start;
	CVector INormed = I.normed();
	CVector K = (CVector::K - (CVector::K * INormed) * INormed).normed();
	CVector J = K ^ INormed;
	CMatrix connectorMat;
	static volatile float scale =0.5f;
	connectorMat.setRot(I, scale * J, scale * K);
	connectorMat.setPos(start);
	edge.setTransformMode(UTransform::DirectMatrix);
	edge.setMatrix(connectorMat);
	edge.show();
}
Пример #6
0
// *************************************************************************************************
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);
		}
	}
}
Пример #7
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 //
Пример #8
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);
				}
			}
		}
	}
}
Пример #9
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 //