コード例 #1
0
ファイル: ItemEffect.cpp プロジェクト: AiYong/CryGame
//------------------------------------------------------------------------
IParticleEmitter *CItem::GetEffectEmitter(uint32 id) const
{
	TEffectInfoMap::const_iterator it = m_effects.find(id);
	if (it == m_effects.end()) 
		return 0;

	const SEffectInfo &info = it->second;
	SEntitySlotInfo slotInfo;

	if (GetEntity()->GetSlotInfo(info.slot, slotInfo) && slotInfo.pParticleEmitter)
		return slotInfo.pParticleEmitter;

	if (GetEntity()->GetSlotInfo(info.characterSlot, slotInfo) && slotInfo.pCharacter)
	{
		ICharacterInstance *pCharacter = slotInfo.pCharacter;
		IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
		IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(info.helper.c_str());
		if (pAttachment)
		{
			CEffectAttachment *pEffectAttachment = static_cast<CEffectAttachment *>(pAttachment->GetIAttachmentObject());
			if (!pEffectAttachment)
			{
				// commenting out for silencer functionality
				//GameWarning("CItem::GetEffectEmitter: no effect attachment on %s (helper %s)", GetEntity()->GetName(), info.helper.c_str());
				return 0;
			}
			return pEffectAttachment->GetEmitter();
		}
	}

	return 0;
}
コード例 #2
0
//------------------------------------------------------------------------
void CItem::SetCharacterAttachment(int slot, const char *name, ICharacterInstance *pAttachedCharacter, int flags)
{
	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);

	if(!pCharacter)
		return;

	IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);

	if(!pAttachment)
	{
		GameWarning("Item '%s' trying to attach character on '%s' which does not exist!", GetEntity()->GetName(), name);
		return;
	}

	CCHRAttachment *pCharacterAttachment = new CCHRAttachment();
	pCharacterAttachment->m_pCharInstance  = pAttachedCharacter;

	// sub skin ?
	if(pAttachment->GetType() == CA_SKIN)
	{
		pAttachment->AddBinding(pCharacterAttachment);
	}
	else
	{
		pAttachment->AddBinding(pCharacterAttachment);
	}
}
コード例 #3
0
void CKVoltEffect::ResetScreenEffect()
{
	if(m_screenEffect && m_ownerActor->IsClient())
	{
		IAttachment* screenAttachment = GetScreenAttachment();
		
		if(screenAttachment)
		{
			CEffectAttachment* pEffectAttachment = new CEffectAttachment(m_screenEffect->GetName(), Vec3(0,0,0), Vec3(0,1,0), 1.f);
			if (pEffectAttachment->GetEmitter())
			{
				screenAttachment->AddBinding(pEffectAttachment);
				pEffectAttachment->ProcessAttachment(screenAttachment);
			}
			else
			{
				delete pEffectAttachment;
			}
		}
		else
		{
			GameWarning("Failed to find #camera attachment");
		}

		//FadeCrosshair();
		DisableScopeReticule();
	}
}
コード例 #4
0
	void CEffectsController::DetachEffect(const TAttachedEffectId effectId)
	{
		CRY_ASSERT(m_pOwnerEntity);

		TAttachedEffects::iterator effectIt = std::find(m_attachedEffects.begin(), m_attachedEffects.end(), effectId);

		if (effectIt != m_attachedEffects.end())
		{
			const SEffectInfo& effectInfo = *effectIt;

			if (effectInfo.entityEffectSlot >= 0)
			{
				m_pOwnerEntity->FreeSlot(effectInfo.entityEffectSlot);
			}	
			else
			{
				ICharacterInstance *pCharacter = m_pOwnerEntity->GetCharacter(effectInfo.characterEffectSlot);
				if (pCharacter)
				{
					IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
					IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(effectInfo.helperName.c_str());
					if(pAttachment)
					{
						pAttachment->ClearBinding();
					}
				}
			}

			m_attachedEffects.erase(effectIt);
		}
	}
コード例 #5
0
//=======================================================================
void CWeaponAttachmentManager::CreatePlayerProjectedAttachments()
{

	Vec3 c4FrontPos(-0.0105f,0.2233f,1.297f),c4BackPos(0.00281f,-0.2493f,1.325f);
	Quat c4FrontRot(-0.0368f,-0.0278f,0.0783f,-0.9958f),c4BackRot(1,0,0,0);
	//Creates on init c4 face attachments
	if (ICharacterInstance* pCharInstance = m_pOwner->GetEntity()->GetCharacter(0))
	{
		IAttachmentManager* pAttachmentManager = pCharInstance->GetIAttachmentManager(); 
		IAttachment *pAttachment = NULL;
		pAttachment = pAttachmentManager->GetInterfaceByName("c4_front");
		if(!pAttachment)
		{
			//Attachment doesn't exist, create it
			pAttachment= pAttachmentManager->CreateAttachment("c4_front",CA_FACE,0);
			if(pAttachment)
			{
				pAttachment->SetAttAbsoluteDefault( QuatT(c4FrontRot,c4FrontPos) );
				pAttachment->ProjectAttachment();
			}
		}
		pAttachment = NULL;
		pAttachment = pAttachmentManager->GetInterfaceByName("c4_back");
		if(!pAttachment)
		{
			//Attachment doesn't exist, create it
			pAttachment= pAttachmentManager->CreateAttachment("c4_back",CA_FACE,0);
			if(pAttachment)
			{
				pAttachment->SetAttAbsoluteDefault( QuatT(c4BackRot,c4BackPos) );
				pAttachment->ProjectAttachment();
			}
		}
	}
}
コード例 #6
0
bool CStickyProjectile::AttachToCharacter(CProjectile* pProjectile, IEntity& pEntity, ICharacterInstance& pCharacter, const char* boneName)
{
	IEntity* pProjectileEntity = pProjectile->GetEntity();

	char attachName[16] = "";		
	sprintf(attachName, "StickyProj_%d", s_attachNameID++);

	IAttachment* pCharacterAttachment = pCharacter.GetIAttachmentManager()->CreateAttachment(attachName, CA_BONE, boneName, false); 

	if(!pCharacterAttachment)
	{
		CryLogAlways("Could not create attachment for StickyProjectile[%s]. AttachmentName[%s] BoneName[%s]", pProjectileEntity->GetName(), attachName, boneName );
		CRY_ASSERT_MESSAGE(pCharacterAttachment, "Could not create attachment for StickyProjectile. This must be fixed.");
		return false;
	}

	m_characterAttachmentCrC = pCharacterAttachment->GetNameCRC();

	SetProjectilePhysics(pProjectile, ePT_None);

	pCharacterAttachment->SetAttRelativeDefault(QuatT(m_stuckRot, m_stuckPos));

	CEntityAttachment *pEntityAttachment = new CEntityAttachment();
	pEntityAttachment->SetEntityId(pProjectileEntity->GetId());

	pCharacterAttachment->AddBinding(pEntityAttachment);

	return true;
}
コード例 #7
0
ファイル: LTagSingle.cpp プロジェクト: Xydrel/Infected
void CLTagSingle::UpdateGrenadeAttachment( ICharacterInstance* pCharacter, const char* attachmentName, const char* model )
{
	CRY_ASSERT(pCharacter);

	IAttachment* pAttachment = pCharacter->GetIAttachmentManager()->GetInterfaceByName(attachmentName);
	if (pAttachment == NULL)
		return;

	IStatObj* pGrenadeModel = gEnv->p3DEngine->LoadStatObj(model);
	if (pGrenadeModel == NULL)
		return;

	IAttachmentObject* pAttachmentObject = pAttachment->GetIAttachmentObject();
	if (pAttachmentObject && (pAttachmentObject->GetAttachmentType() == IAttachmentObject::eAttachment_StatObj))
	{
		CCGFAttachment* pCGFAttachment = static_cast<CCGFAttachment*>(pAttachmentObject);
		pCGFAttachment->pObj = pGrenadeModel;  //pObj is an smart pointer, it should take care of releasing/AddRef
	}
	else
	{
		CCGFAttachment* pCGFAttachment = new CCGFAttachment();
		pCGFAttachment->pObj = pGrenadeModel;
		pAttachment->AddBinding(pCGFAttachment);
	}
}
コード例 #8
0
//======================================================================
void CWeaponAttachmentManager::CreatePlayerBoneAttachments()
{
		
	if (ICharacterInstance* pCharInstance = m_pOwner->GetEntity()->GetCharacter(0))
	{
		IAttachmentManager* pAttachmentManager = pCharInstance->GetIAttachmentManager(); 
		IAttachment *pAttachment = NULL;
		
		for(int i=0; i<MAX_WEAPON_ATTACHMENTS; i++)
		{
			pAttachment = pAttachmentManager->GetInterfaceByName(gAttachmentTable[i]);
			if(!pAttachment)
			{
				//Attachment doesn't exist, create it
				pAttachment = pAttachmentManager->CreateAttachment(gAttachmentTable[i],CA_BONE,gBoneTable[i]);
				if(pAttachment)
				{
					m_boneAttachmentMap.insert(TBoneAttachmentMap::value_type(gAttachmentTable[i],0));
					if(pAttachment && !gOffsetTable[i].IsZero())
					{
						pAttachment->SetAttAbsoluteDefault( QuatT(gRotationTable[i],gOffsetTable[i]) );
						pAttachment->ProjectAttachment();
					}
				}
			}
		}

	}

}
コード例 #9
0
ファイル: AICorpse.cpp プロジェクト: aronarts/FireNET
void CAICorpse::AboutToBeRemoved()
{
	IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();

	ICharacterInstance* pCharacter = GetEntity()->GetCharacter(0);
	IAttachmentManager* pAttachmentManager = (pCharacter != NULL) ? pCharacter->GetIAttachmentManager() : NULL;

	for (uint32 i = 0; i < (uint32)m_attachedItemsInfo.size(); ++i)
	{
		AttachedItem& attachedItem = m_attachedItemsInfo[i];

		IItem* pItem = pItemSystem->GetItem( attachedItem.id );
		if((pItem != NULL) && ShouldDropOnCorpseRemoval( pItem->GetEntity()->GetClass() ))
		{
			IAttachment* pAttachment = (pAttachmentManager != NULL) ? pAttachmentManager->GetInterfaceByName( attachedItem.attachmentName.c_str() ) : NULL;
			if(pAttachment != NULL)
			{
				pAttachment->ClearBinding();
			}

			pItem->Drop( 1.0f, false, true );
			pItem->GetEntity()->SetFlags( pItem->GetEntity()->GetFlags() & ~ENTITY_FLAG_NO_SAVE );

			attachedItem.id = 0;
		}
	}
}
コード例 #10
0
ファイル: GameEffect.cpp プロジェクト: amrhead/eaascode
//--------------------------------------------------------------------------------------------------
// Name: SetMaterialOnEntity
// Desc: Sets material on entity
//--------------------------------------------------------------------------------------------------
void CGameEffect::SetMaterialOnEntity(IMaterial* pMaterial,EntityId entityId,PodArray<ItemString>*	bodyAttachmentNameArray)
{
	if(pMaterial && bodyAttachmentNameArray)
	{
		IEntity* pEntity = gEnv->pEntitySystem->GetEntity(entityId);
		if(pEntity)
		{
			SEntitySlotInfo slotInfo;
			bool gotSlotInfo = pEntity->GetSlotInfo(0, slotInfo);
			if(gotSlotInfo && slotInfo.pCharacter)
			{
				IAttachmentManager* pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
				if(pAttachmentManager)
				{
					int attachmentCount = bodyAttachmentNameArray->size();
					for(int i=0; i<attachmentCount; i++)
					{
						IAttachment* attachment = pAttachmentManager->GetInterfaceByName(((*bodyAttachmentNameArray)[i]).c_str());

						if(attachment)
						{
							IAttachmentObject* attachmentObj = attachment->GetIAttachmentObject();
							if(attachmentObj)
							{
								attachmentObj->SetReplacementMaterial(pMaterial);
							}
						}
					}
				}
			}
		}
	}
}//-------------------------------------------------------------------------------------------------
コード例 #11
0
	void DetachObject(SActivationInfo *pActInfo)
	{
		IAttachment *pAttachment = GetAttachment(pActInfo);
		if (pAttachment)
		{
			pAttachment->ClearBinding();
			ActivateOutput(pActInfo, eOP_Detached, 0);
		}
	}
コード例 #12
0
ファイル: ItemResource.cpp プロジェクト: Xydrel/Infected
//------------------------------------------------------------------------
const Matrix33 &CItem::GetSlotHelperRotation(int slot, const char *helper, bool worldSpace, bool relative)
{
	static Matrix33 rotation;
	rotation.SetIdentity();

	IEntity* pEntity = GetEntity();
	if(!pEntity)
		return rotation;

	SEntitySlotInfo info;
	if (pEntity->GetSlotInfo(slot, info))
	{
    if (info.pStatObj)
    {
      IStatObj *pStatObj = info.pStatObj;
      rotation = Matrix33(pStatObj->GetHelperTM(helper));
      rotation.OrthonormalizeFast();
      rotation = Matrix33(GetEntity()->GetSlotLocalTM(slot, false))*rotation;        
    }
		else if (info.pCharacter)
		{
			ICharacterInstance *pCharacter = info.pCharacter;
			if(!pCharacter)
				return rotation;

			IAttachment* pAttachment = pCharacter->GetIAttachmentManager()->GetInterfaceByName(helper);
			if(pAttachment)
			{
				rotation = Matrix33(worldSpace ? pAttachment->GetAttWorldAbsolute().q : pAttachment->GetAttModelRelative().q);
				return rotation;
			}
			else
			{
				ICharacterModelSkeleton* pICharacterModelSkeleton = pCharacter->GetICharacterModel()->GetICharacterModelSkeleton();
				ISkeletonPose* pSkeletonPose = pCharacter->GetISkeletonPose();
				int16 id = pICharacterModelSkeleton->GetJointIDByName(helper);
				if (id > -1)
				{
					rotation = relative ? Matrix33(pSkeletonPose->GetRelJointByID(id).q) : Matrix33(pSkeletonPose->GetAbsJointByID(id).q);
				}
			}

			if (!relative)
			{
				rotation = Matrix33(pEntity->GetSlotLocalTM(slot, false)) * rotation;
			}
		}    
	}

	if (worldSpace)
	{
		rotation = Matrix33(pEntity->GetWorldTM()) * rotation;
	}

	return rotation;
}
bool CMFXParticleEffect::AttachToCharacter( IEntity& targetEntity, const SMFXParticleEntry& particleParams, const SMFXRunTimeEffectParams& params, const Vec3& dir, float scale )
{
	if (params.partID >= 0)
	{
		//Assume character is loaded in first slot 
		//We could iterate through all available slots, but first one should be good enough
		ICharacterInstance* pCharacterInstace = targetEntity.GetCharacter(0);
		ISkeletonPose* pSkeletonPose = pCharacterInstace ? pCharacterInstace->GetISkeletonPose() : NULL;
		if (pSkeletonPose)
		{
			IDefaultSkeleton& rIDefaultSkeleton	= pCharacterInstace->GetIDefaultSkeleton();
			//It hit the character, but probably in a physicalized attached part, like armor plates, etc
			if (params.partID >= rIDefaultSkeleton.GetJointCount())
			{
				return false;
			}

			//It hit some valid joint, create an attachment
			const char* boneName = rIDefaultSkeleton.GetJointNameByID(params.partID);
			TAttachmentName attachmentName;
			GetNextCharacterAttachmentName(attachmentName);

			IAttachmentManager* pAttachmentManager = pCharacterInstace->GetIAttachmentManager();
			CRY_ASSERT(pAttachmentManager);
			
			//Remove the attachment first (in case was created before)
			pAttachmentManager->RemoveAttachmentByName(attachmentName.c_str());

			//Create attachment on nearest hit bone
			IAttachment* pAttachment = pAttachmentManager->CreateAttachment(attachmentName.c_str(), CA_BONE, boneName, false);
			if (pAttachment)
			{
				//Apply relative offsets
				const QuatT boneLocation = pSkeletonPose->GetAbsJointByID(params.partID);
				Matrix34 inverseJointTM = targetEntity.GetWorldTM() * Matrix34(boneLocation);
				inverseJointTM.Invert();
				Vec3 attachmentOffsetPosition = inverseJointTM * params.pos;
				Quat attachmentOffsetRotation = Quat(inverseJointTM) * targetEntity.GetRotation();

				CRY_ASSERT(attachmentOffsetPosition.IsValid());
				//CRY_ASSERT(attachmentOffsetRotation.IsUnit());

				pAttachment->SetAttRelativeDefault(QuatT(attachmentOffsetRotation, attachmentOffsetPosition));

				//Finally attach the effect
				CEffectAttachment* pEffectAttachment = new CEffectAttachment(particleParams.name.c_str(), Vec3(0,0,0), dir, scale);
				pAttachment->AddBinding(pEffectAttachment);
				
				return true;
			}
		}
	}

	return false;
}
コード例 #14
0
	void UpdateOffset(SActivationInfo *pActInfo)
	{
		IAttachment *pAttachment = GetAttachment(pActInfo);
		if (pAttachment)
		{
			const Vec3& rotationOffsetEuler = GetPortVec3(pActInfo, eIP_RotationOffset);
			QuatT offset = QuatT::CreateRotationXYZ(Ang3(DEG2RAD(rotationOffsetEuler)));
			offset.t = GetPortVec3(pActInfo, eIP_TranslationOffset);
			pAttachment->SetAttRelativeDefault(offset);
		}
	}
コード例 #15
0
void CLocalPlayerComponent::UpdateFPBodyPartsVisibility()
{
	if (m_rPlayer.m_stats.isThirdPerson == false)
	{
		ICharacterInstance *pMainCharacter	= m_rPlayer.GetEntity()->GetCharacter(0);
		IAttachmentManager *pAttachmentManager		= pMainCharacter ? pMainCharacter->GetIAttachmentManager() : NULL;

		if (pAttachmentManager)
		{
			CRY_ASSERT(m_rPlayer.HasBoneID(BONE_CALF_L));
			CRY_ASSERT(m_rPlayer.HasBoneID(BONE_CALF_R));

			const CCamera& camera = gEnv->p3DEngine->GetRenderingCamera();
			const Matrix34& playerWorldTM = m_rPlayer.GetEntity()->GetWorldTM();

			bool visible = true;
			if (m_rPlayer.m_linkStats.linkID == 0)
			{
				//volatile static float radius = 0.475f;
				const float radius = 0.16f;
				const Sphere calfSphereL(playerWorldTM.TransformPoint(m_rPlayer.GetBoneTransform(BONE_CALF_L).t), radius);
				const Sphere calfSpehreR(playerWorldTM.TransformPoint(m_rPlayer.GetBoneTransform(BONE_CALF_R).t), radius);

				visible = camera.IsSphereVisible_F(calfSphereL) || camera.IsSphereVisible_F(calfSpehreR);
			}

			//const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
			//gEnv->pRenderer->Draw2dLabel(50.0f, 50.0f, 2.0f, white, false, visible ? "Rendering complete FP body" : "Rendering only arms");

			//Early out if no change
			if (m_fpCompleteBodyVisible == visible)
				return;

			//Hide/Unhide certain parts depending on visibility
			const int kNumParstToToggle = 2;
			const char *tooglePartsTable[kNumParstToToggle] = {"lower_body", "upper_body"};
			for (int i=0; i<kNumParstToToggle; i++)
			{
				IAttachment* pAttachment = pAttachmentManager->GetInterfaceByName(tooglePartsTable[i]);
				if (pAttachment)
				{
					pAttachment->HideAttachment(!visible);
					pAttachment->HideInShadow(1);
				}
			}

			m_fpCompleteBodyVisible = visible;
		}
	}
}
コード例 #16
0
ファイル: ScriptBind_Actor.cpp プロジェクト: kitnet/crynegine
int CScriptBind_Actor::GetClosestAttachment(IFunctionHandler *pH, int characterSlot, Vec3 testPos, float maxDistance, const char* suffix)
{
  CActor *pActor = GetActor(pH);
	if (!pActor)
		return pH->EndFunction();

  IEntity* pEntity = pActor->GetEntity();
  ICharacterInstance* pChar = pEntity->GetCharacter(characterSlot);

  if (!pChar)  
    return pH->EndFunction();

  //fallback: use nearest attachment
  float minDiff = maxDistance*maxDistance;  
  IAttachment* pClosestAtt = 0;
  
  IAttachmentManager* pMan = pChar->GetIAttachmentManager();
  int count = pMan->GetAttachmentCount();
  
  for (int i=0; i<count; ++i)
  {
    IAttachment* pAtt = pMan->GetInterfaceByIndex(i);		
		
    if (pAtt->IsAttachmentHidden() || !pAtt->GetIAttachmentObject())
			continue;
		
		AABB bbox(AABB::CreateTransformedAABB(Matrix34(pAtt->GetAttWorldAbsolute()),pAtt->GetIAttachmentObject()->GetAABB()));
		//gEnv->pRenderer->GetIRenderAuxGeom()->DrawAABB(bbox,false,ColorB(255,0,0,100),eBBD_Faceted);
		
    //float diff = (testPos - pAtt->GetWMatrix().GetTranslation()).len2();
		float diff((testPos - bbox.GetCenter()).len2());
		
    if (diff < minDiff)
    {
      //CryLogAlways("%s distance: %.1f", pAtt->GetName(), sqrt(diff));

      if (suffix[0] && !strstr(pAtt->GetName(), suffix))
        continue;

      minDiff = diff; 
      pClosestAtt = pAtt;      
    }
  }

  if (!pClosestAtt)
    return pH->EndFunction();
  
	//FIXME FIXME: E3 workaround
	char attachmentName[64];
	strncpy(attachmentName,pClosestAtt->GetName(),63);
	attachmentName[63] = 0;
	char *pDotChar = strstr(attachmentName,".");
	if (pDotChar)
		*pDotChar = 0;

	strlwr(attachmentName);
	//

  return pH->EndFunction(attachmentName);    
}
コード例 #17
0
void CKVoltEffect::Leave()
{
	if(m_particleEmitter)
	{
		gEnv->pParticleManager->DeleteEmitter(m_particleEmitter);
		m_particleEmitter->Release();
		m_particleEmitter = NULL;
	}

	IAttachment* screenAttachment = GetScreenAttachment();
	if(screenAttachment)
	{
		screenAttachment->ClearBinding();
	}
}
コード例 #18
0
void CLTag::HideGrenadeAttachment( ICharacterInstance* pWeaponCharacter, const char* attachmentName, bool hide )
{
	CRY_ASSERT(pWeaponCharacter);

	CCCPOINT_IF(string("newShell") == attachmentName && hide, ltag_hide_newShell);
	CCCPOINT_IF(string("newShell") == attachmentName && !hide, ltag_show_newShell);
	CCCPOINT_IF(string("currentShell") == attachmentName && hide, ltag_hide_currentShell);
	CCCPOINT_IF(string("currentShell") == attachmentName && !hide, ltag_show_currentShell);

	IAttachment* pAttachment = pWeaponCharacter->GetIAttachmentManager()->GetInterfaceByName(attachmentName);
	if (pAttachment)
	{
		pAttachment->HideAttachment(hide ? 1 : 0);
	}
}
コード例 #19
0
ファイル: GameEffect.cpp プロジェクト: amrhead/eaascode
//--------------------------------------------------------------------------------------------------
// Name: InitAttachmentIndexArray
// Desc: Initialises attachment index array
//--------------------------------------------------------------------------------------------------
void CGameEffect::InitAttachmentIndexArray(PodArray<int> *attachmentIndexArray,PodArray<ItemString>* pAttachmentNameArray,EntityId entityId) const 
{
	if(attachmentIndexArray && pAttachmentNameArray && (entityId!=0))
	{
		if(attachmentIndexArray->size() == 0)
		{
			// Store attachment index array
			const int attachmentNameCount = pAttachmentNameArray->size();

			SEntitySlotInfo slotInfo;
			IEntity* pEntity = gEnv->pEntitySystem->GetEntity(entityId);
			if(pEntity)
			{
				bool gotEntitySlotInfo = pEntity->GetSlotInfo(0, slotInfo);
				if(gotEntitySlotInfo)
				{
					attachmentIndexArray->reserve(attachmentNameCount);

					if(slotInfo.pCharacter)
					{
						IAttachmentManager* attachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
						if(attachmentManager)
						{
							const int attachmentCount = attachmentManager->GetAttachmentCount();

							for(int n=0; n<attachmentNameCount; n++)
							{
								for(int a=0; a<attachmentCount; a++)
								{
									IAttachment* attachment = attachmentManager->GetInterfaceByIndex(a);
									if(attachment)
									{
										const char* currentAttachmentName = attachment->GetName();
										if(strcmp(currentAttachmentName,(*pAttachmentNameArray)[n].c_str())==0)
										{
											attachmentIndexArray->push_back(a);
											break;
										}
									}
								}
							}
						}
					}
				}
			}	
		}
	}
}//-------------------------------------------------------------------------------------------------
コード例 #20
0
ファイル: ItemResource.cpp プロジェクト: Xydrel/Infected
//------------------------------------------------------------------------
Vec3 CItem::GetSlotHelperPos(int slot, const char *helper, bool worldSpace, bool relative) const
{
	Vec3 position(0,0,0);

	SEntitySlotInfo info;
	if (GetEntity()->GetSlotInfo(slot, info))
	{
		if (info.pStatObj)
		{
			IStatObj *pStatsObj = info.pStatObj;
			position = pStatsObj->GetHelperPos(helper);
			position = GetEntity()->GetSlotLocalTM(slot, false).TransformPoint(position);
		}
		else if (info.pCharacter)
		{
			ICharacterInstance *pCharacter = info.pCharacter;
			IAttachment* pAttachment = pCharacter->GetIAttachmentManager()->GetInterfaceByName(helper);
			if (pAttachment)
			{
				position = worldSpace ? pAttachment->GetAttWorldAbsolute().t : pAttachment->GetAttModelRelative().t;
				return position;
			}
			else
			{
				ICharacterModelSkeleton* pICharacterModelSkeleton = pCharacter->GetICharacterModel()->GetICharacterModelSkeleton();
				ISkeletonPose* pSkeletonPose = pCharacter->GetISkeletonPose();
				int16 id = pICharacterModelSkeleton->GetJointIDByName(helper);
				if (id > -1)
				{
					position = relative ? pSkeletonPose->GetRelJointByID(id).t : pSkeletonPose->GetAbsJointByID(id).t;
				}
			}

			if (!relative)
			{
				position = GetEntity()->GetSlotLocalTM(slot, false).TransformPoint(position);
			}
		}
	}

	if (worldSpace)
	{
		position = GetWorldTM().TransformPoint(position);
	}

	return position;
}
コード例 #21
0
ファイル: ItemResource.cpp プロジェクト: kitnet/project-o
//------------------------------------------------------------------------
void CItem::SetCharacterAttachmentLocalTM(int slot, const char *name, const Matrix34 &tm)
{
	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);
	if (!pCharacter)
		return;

	IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);

	if (!pAttachment)
	{
		GameWarning("Item '%s' trying to set local TM on attachment '%s' which does not exist!", GetEntity()->GetName(), name);
		return;
	}

	pAttachment->SetAttRelativeDefault( QuatT(tm));
}
コード例 #22
0
ファイル: ItemResource.cpp プロジェクト: kitnet/project-o
//------------------------------------------------------------------------
Matrix34 CItem::GetCharacterAttachmentWorldTM(int slot, const char *name)
{
	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);
	if (!pCharacter)
		return Matrix34::CreateIdentity();

	IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);

	if (!pAttachment)
	{
		GameWarning("Item '%s' trying to get local TM on attachment '%s' which does not exist!", GetEntity()->GetName(), name);
		return Matrix34::CreateIdentity();
	}

	return Matrix34(pAttachment->GetAttWorldAbsolute());
}
コード例 #23
0
ファイル: ItemResource.cpp プロジェクト: kitnet/project-o
//------------------------------------------------------------------------
void CItem::ResetCharacterAttachment(int slot, const char *name)
{
	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);
	if (!pCharacter)
		return;

	IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);

	if (!pAttachment)
	{
		GameWarning("Item '%s' trying to reset attachment '%s' which does not exist!", GetEntity()->GetName(), name);
		return;
	}

	pAttachment->ClearBinding();
}
コード例 #24
0
ファイル: ItemResource.cpp プロジェクト: kitnet/project-o
//------------------------------------------------------------------------
const char *CItem::GetCharacterAttachmentBone(int slot, const char *name)
{
	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);
	if (!pCharacter)
		return 0;

	IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);

	if (!pAttachment)
	{
		GameWarning("Item '%s' trying to get attachment bone on '%s' which does not exist!", GetEntity()->GetName(), name);
		return 0;
	}

	return pCharacter->GetISkeletonPose()->GetJointNameByID(pAttachment->GetBoneID());
}
コード例 #25
0
	void UnHideAttachment(SActivationInfo* pActInfo)
	{
		IAttachment* pAttachment = GetAttachment(pActInfo);
		if(pAttachment)
		{
			pAttachment->HideAttachment(0);

			IAttachmentObject* pAttachmentObject = pAttachment->GetIAttachmentObject();
			if((pAttachmentObject != NULL) && (pAttachmentObject->GetAttachmentType() == IAttachmentObject::eAttachment_Entity))
			{
				IEntity* pAttachedEntity = gEnv->pEntitySystem->GetEntity( static_cast<CEntityAttachment*>(pAttachmentObject)->GetEntityId() );
				if(pAttachedEntity)
				{
					pAttachedEntity->Hide(false);
				}
			}
		}
	}
コード例 #26
0
ファイル: EntityCVars.cpp プロジェクト: amrhead/eaascode
void CVar::EnableDebugAnimText(IConsoleCmdArgs *args)
{
	if (args && args->GetArgCount() > 1)
	{
		const char* szFilterName = args->GetArg(1);
		bool enable = true;
		if (args->GetArgCount() > 2)
		{
			enable = (strcmp(args->GetArg(2), "0") != 0);
		}

		CEntitySystem* pEntitySystem = GetIEntitySystem();
		IEntity *entity = pEntitySystem->FindEntityByName(szFilterName);

		if (entity)
		{
			uint32 numSlots = entity->GetSlotCount();
			for (uint32 i=0; i<numSlots; i++)
			{
				ICharacterInstance *charInst = entity->GetCharacter(i);
				if (charInst)
				{
					charInst->GetISkeletonAnim()->SetDebugging(enable);
					IAttachmentManager* pAttachmentManager = charInst->GetIAttachmentManager();
					for(int32 attachmentIndex=0; attachmentIndex<pAttachmentManager->GetAttachmentCount(); ++attachmentIndex)
					{
						IAttachment* pAttachment = pAttachmentManager->GetInterfaceByIndex(attachmentIndex);
						assert(pAttachment);

						IAttachmentObject* pObject = pAttachment->GetIAttachmentObject();
						if (pObject)
						{
							ICharacterInstance* pObjectCharInst = pObject->GetICharacterInstance();
							if (pObjectCharInst)
							{
								pObjectCharInst->GetISkeletonAnim()->SetDebugging(enable);
							}
						}
					}
				}
			}
		}
	}
}
コード例 #27
0
	void OnEntityEvent( IEntity* pEntity, SEntityEvent& event )
	{
		if (event.event==m_event)
		{
			if (m_pNewAttachment)
			{
				m_pNewAttachment->ClearBinding();
			}
		}
	}
コード例 #28
0
ファイル: HandGrenades.cpp プロジェクト: Xydrel/Infected
int PickStowSlot(IAttachmentManager *pAttachmentManager, const char *slot1, const char *slot2)
{
	int ret = -1;
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(slot1);
	if(pAttachment && !pAttachment->GetIAttachmentObject())
	{
		ret = 0;
	}
	else
	{
		pAttachment = pAttachmentManager->GetInterfaceByName(slot2);
		if(pAttachment && !pAttachment->GetIAttachmentObject())
		{
			ret = 1;
		}
	}

	return ret;
}
コード例 #29
0
ファイル: ItemResource.cpp プロジェクト: kitnet/project-o
//------------------------------------------------------------------------
void CItem::SetCharacterAttachment(int slot, const char *name, IStatObj *pObj, int flags)
{
	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);
	if (!pCharacter)
		return;

	IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);

	if (!pAttachment)
	{
		GameWarning("Item '%s' trying to attach static object on '%s' which does not exist!", GetEntity()->GetName(), name);
		return;
	}

	CCGFAttachment *pStatAttachment = new CCGFAttachment();
	pStatAttachment->pObj  = pObj;

	pAttachment->AddBinding(pStatAttachment);
}
コード例 #30
0
ファイル: ItemResource.cpp プロジェクト: kitnet/project-o
//------------------------------------------------------------------------
void CItem::SetCharacterAttachmentWorldTM(int slot, const char *name, const Matrix34 &tm)
{
	ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);
	if (!pCharacter)
		return;

	IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
	IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);

	if (!pAttachment)
	{
		GameWarning("Item '%s' trying to set world TM on attachment '%s' which does not exist!", GetEntity()->GetName(), name);
		return;
	}

//	Matrix34 boneWorldMatrix = GetEntity()->GetSlotWorldTM(slot) *	pCharacter->GetISkeleton()->GetAbsJMatrixByID(pAttachment->GetBoneID());
	Matrix34 boneWorldMatrix = GetEntity()->GetSlotWorldTM(slot) *	Matrix34(pCharacter->GetISkeletonPose()->GetAbsJointByID(pAttachment->GetBoneID()) );

	Matrix34 localAttachmentMatrix = (boneWorldMatrix.GetInverted()*tm);
	pAttachment->SetAttRelativeDefault(QuatT(localAttachmentMatrix));
}