コード例 #1
0
ファイル: character_3d.cpp プロジェクト: sythaeryn/pndrpg
// ------------------------------------------------------------------------------------------------
void SCharacter3DSetup::setupDefault (EGSPD::CPeople::TPeople eRace, bool bMale)
{
	People = eRace;
	Male = bMale;

	CGenderInfo *pGI = getGenderInfo(eRace, bMale);
	if (pGI == NULL) return;

	Skeleton = pGI->Skelfilename;

	// Read all the default equipement
	for (sint32 i = 0; i < SLOTTYPE::NB_SLOT; ++i)
	{
		string ISstr = pGI->Items[i]; // All the strings are items
		if (!ISstr.empty())
		{
			CItemSheet *pIS = dynamic_cast<CItemSheet*>(SheetMngr.get(CSheetId(ISstr)));
			if (pIS != NULL)
			{
				sint32 cpIndex = convert_VisualSlot_To_Char3DPart ((SLOTTYPE::EVisualSlot)i);
				if (cpIndex != Char3DPart_INVALID)
				{
					Parts[cpIndex].Quality = pIS->MapVariant;
					if (Male)
						Parts[cpIndex].Name = pIS->getShape();
					else
						Parts[cpIndex].Name = pIS->getShapeFemale();
				}
			}
		}
	}
}
コード例 #2
0
ファイル: character_3d.cpp プロジェクト: sythaeryn/pndrpg
// ------------------------------------------------------------------------------------------------
void SCharacter3DSetup::setupFromCS_ModelCol (SLOTTYPE::EVisualSlot s, sint32 model, sint32 col)
{
	TChar3DPart part = convert_VisualSlot_To_Char3DPart (s);
	if (part == Char3DPart_INVALID) return;

	CItemSheet *item = SheetMngr.getItem (s, model);
	if (item != NULL)
	{
		// magician gloves are a weapon but displayed in hands slot(armor gloves)
		if( (s == SLOTTYPE::RIGHT_HAND_SLOT) && (item->ItemType == ITEM_TYPE::MAGICIAN_STAFF) )
		{
			Parts[part].Name = "none.shape";
			part = convert_VisualSlot_To_Char3DPart (SLOTTYPE::HANDS_SLOT);
		}

		Parts[part].Quality = item->MapVariant;
		if (Male)
			Parts[part].Name = item->getShape();
		else
			Parts[part].Name = item->getShapeFemale();

		// FX
		{
			Parts[part].AdvFx = item->FX.getAdvantageFX();
			Parts[part].StatFxNames.clear();
			Parts[part].StatFxBones.clear();
			Parts[part].StatFxOffss.clear();
			for (uint32 fx = 0; fx < item->FX.getNumStaticFX(); ++fx)
			{
				Parts[part].StatFxNames.push_back(item->FX.getStaticFXName(fx));
				Parts[part].StatFxBones.push_back(item->FX.getStaticFXBone(fx));
				Parts[part].StatFxOffss.push_back(item->FX.getStaticFXOffset(fx));
			}
		}

		if (part == Char3DPart_HandLeftItem)
		{
			if ((item->ItemType == ITEM_TYPE::SHIELD) ||  (item->ItemType == ITEM_TYPE::BUCKLER))
				LeftHandItemIsShield = true;
			else
				LeftHandItemIsShield = false;
		}
	}
	else
	{
		if ((part == Char3DPart_HandLeftItem) || (part == Char3DPart_HandRightItem))
			Parts[part].Name = "none.shape";
	}

	Parts[part].Color = col;
}
コード例 #3
0
/*
* draw the view
*/
void CViewBitmapFaberMp::draw ()
{
	///\todo nico : draw icon
	/*xOffset+=_XReal;
	yOffset+=_YReal;
	_SheetText->setText(ucstring(toString(_SheetId.getSInt32())));
	_SheetText->draw(xOffset,yOffset+20);

	_QuantityText->setText(ucstring(toString(_Quantity.getSInt32())));
	_QuantityText->draw(xOffset,yOffset+10);

	_QualityText->setText(ucstring(toString(_Quality.getSInt32())));
	_QualityText->draw(xOffset,yOffset);
*/

	//get the item
	CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer();

	uint32 sheet = (uint32)_SheetId.getSInt64();
	CSheetId sheetId(sheet);
	CEntitySheet *pES = SheetMngr.get (sheetId);

	if ((pES != NULL) && (pES->type() == CEntitySheet::ITEM))
	{
		CItemSheet *pIS = (CItemSheet*)pES;

		if (pIS->getIconBack() != "")
		{
			if (_AccIconBackString != pIS->getIconBack())
			{
				_AccIconBackString = pIS->getIconBack();
				_AccIconBackId = rVR.getTextureIdFromName (_AccIconBackString);
			}
			rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
							_WReal, _HReal, (uint8)_Rot, _Flip,
							_AccIconBackId);
		}

		if (pIS->getIconMain() != "")
		{
			if (_AccIconMainString != pIS->getIconMain())
			{
				_AccIconMainString = pIS->getIconMain();
				_AccIconMainId = rVR.getTextureIdFromName (_AccIconMainString);
			}
			rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
							_WReal, _HReal, (uint8)_Rot, _Flip,
							_AccIconMainId);
		}

		if (pIS->getIconOver() != "")
		{
			if (_AccIconOverString != pIS->getIconOver())
			{
				_AccIconOverString = pIS->getIconOver();
				_AccIconOverId = rVR.getTextureIdFromName (_AccIconOverString);
			}
			rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
							_WReal, _HReal, (uint8)_Rot, _Flip,
							_AccIconOverId);
		}

/*		// draw wanted quantity
		{
		//draw the units
		uint units = _NeededQuantity.getSInt32() % 10;
		rVR.drawRotFlipBitmap (_RenderLayer, _XReal+xOffset+13, _YReal+yOffset,
				8, 8, (uint8)_Rot.getSInt32(), _Flip.getBool(),
				rVR.getFigurTextureId(units), _Color.getRGBA());

		//draw the tens
		uint tens = _NeededQuantity.getSInt32() / 10;
		sint32 tensId;
		if (tens > 9 || tens == 0)
			tensId = rVR.getFigurBlankTextureId();
		else
			tensId = rVR.getFigurTextureId(tens);
		rVR.drawRotFlipBitmap (_RenderLayer, _XReal+xOffset+8, _YReal+yOffset,
			8, 8, (uint8)_Rot.getSInt32(), _Flip.getBool(),
			tensId, _Color.getRGBA());
		}


		// draw current quantity
		if (_Quantity.getSInt32() > 1)
		{
			//draw the units
			uint units = _Quantity.getSInt32() % 10;
			rVR.drawRotFlipBitmap (_RenderLayer, _XReal+xOffset+_WReal-8, _YReal+yOffset,
					8, 8, (uint8)_Rot.getSInt32(), _Flip.getBool(),
					rVR.getFigurTextureId(units), _Color.getRGBA());

			//draw the tens
			uint tens = _Quantity.getSInt32() / 10;
			sint32 tensId;
			if (tens > 9 || tens == 0)
				tensId = rVR.getFigurBlankTextureId();
			else
				tensId = rVR.getFigurTextureId(tens);
			rVR.drawRotFlipBitmap (_RenderLayer, _XReal+xOffset+_WReal-13, _YReal+yOffset,
				8, 8, (uint8)_Rot.getSInt32(), _Flip.getBool(),
				tensId, _Color.getRGBA());
		}
		*/

		uint16 qty = (uint16) ( _NeededQuantity.getSInt32() - _Quantity.getSInt32() );
		// draw missing quantity
		if (qty > 1)
		{
			//draw the units
			uint units = qty % 10;
			rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-8, _YReal,
					8, 8, (uint8)_Rot, _Flip,
					rVR.getFigurTextureId(units), _Color);

			//draw the tens
			uint tens = qty / 10;
			sint32 tensId;
			if (tens > 9 || tens == 0)
				tensId = rVR.getFigurBlankTextureId();
			else
				tensId = rVR.getFigurTextureId(tens);
			rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-13, _YReal,
				8, 8, (uint8)_Rot, _Flip,
				tensId, _Color);
		}
	}
	else
	{
		if (_TextureNoItemId == -2)
			_TextureNoItemId = rVR.getTextureIdFromName (_TextureNoItemName);
		rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
						_WReal, _HReal, (uint8)_Rot, _Flip,
						_TextureNoItemId, _ColorNoItem.getRGBA());
	}
}
コード例 #4
0
ファイル: player_r2_cl.cpp プロジェクト: mixxit/solinia
//-----------------------------------------------
// 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 //
コード例 #5
0
ファイル: sheet_manager.cpp プロジェクト: mixxit/solinia
//-----------------------------------------------
// computeVS :
// compute Visual Slots for this sheet.
//-----------------------------------------------
void CSheetManager::computeVS()
{
	static std::map< std::string, uint16 > ProcessedItem;
	map< string, uint16 >::iterator it;

	CVisualSlotManager::TVisualSlot vs;
	vs.resize(SLOTTYPE::NB_SLOT);

	//
	TEntitySheetMap::iterator itS = _EntitySheetContainer.begin();
	while(itS != _EntitySheetContainer.end())
	{
		// Visual Slots are only valid for Items.
		CItemSheet *item = dynamic_cast<CItemSheet *>((*itS).second.EntitySheet);
		if (item && (*itS).first.getSheetType()==CSheetId::typeFromFileExtension(std::string("sitem")))
		{
			for(uint j=0; j<SLOTTYPE::NB_SLOT_TYPE; ++j)
			{
				SLOTTYPE::TSlotType	slotType= (SLOTTYPE::TSlotType)j;
				if( item->hasSlot(slotType) )
				{
					SLOTTYPE::EVisualSlot visualSlot = SLOTTYPE::convertTypeToVisualSlot(slotType);
					if(visualSlot != SLOTTYPE::HIDDEN_SLOT)
					{
						string currentSheet = ((*itS).first).toString();

						CVisualSlotManager::TElement vsElmt;

						string sheetName = toString("%s%d", currentSheet.c_str(), visualSlot);

						// Is the sheet already process (could be process by a sheet with a different lvl)
						it = ProcessedItem.find( sheetName );
						// Insert if not found
						if(it == ProcessedItem.end())
						{
							uint itemNumber;
							if(vs[visualSlot].Element.size() == 0)
								itemNumber = 1;
							else
								itemNumber = vs[visualSlot].Element[vs[visualSlot].Element.size()-1].Index+1;

							// Item Processed
							ProcessedItem.insert(make_pair(sheetName, itemNumber));

							vsElmt.Index = itemNumber;
						}
						else
						{
							vsElmt.Index = (*it).second;
						}
						//
						vsElmt.SheetId = (*itS).first;
						vs[visualSlot].Element.push_back(vsElmt);
					}
				}
			}
		}

		// Next Sheet
		++itS;
	}


	// Open the file.
	NLMISC::COFile f;
	if(f.open("visual_slot.tab"))
	{
		// Dump entities.
		f.serialCont(vs);

		// Close the File.
		f.close();
	}
	else
		nlwarning("SheetMngr:load: cannot open/create the file 'visual_slot.tab'.");
}// computeVS //