本文整理汇总了C++中IAttachmentManager::GetInterfaceByName方法的典型用法代码示例。如果您正苦于以下问题:C++ IAttachmentManager::GetInterfaceByName方法的具体用法?C++ IAttachmentManager::GetInterfaceByName怎么用?C++ IAttachmentManager::GetInterfaceByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAttachmentManager
的用法示例。
在下文中一共展示了IAttachmentManager::GetInterfaceByName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FixAttachment
void CLaserBeam::FixAttachment(IEntity* pLaserEntity)
{
m_usingEntityAttachment = false;
IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
CItem* pOwnerItem = static_cast<CItem*>(pItemSystem->GetItem(m_ownerEntityId));
if (pOwnerItem)
{
IEntity* pOwnerEntity = pOwnerItem->GetEntity();
IEntity* pAttachedEntity = pOwnerEntity;
const char* attach_helper = "laser_term";
Vec3 offset = pOwnerItem->GetSlotHelperPos(m_geometrySlot, attach_helper, false);
if(m_geometrySlot == eIGS_FirstPerson)
{
if(pOwnerItem->IsAccessory())
{
EntityId parentId = pOwnerItem->GetParentId();
if(parentId)
{
if(CItem* pParentItem = static_cast<CItem*>(pItemSystem->GetItem(parentId)))
{
const SAccessoryParams* pParams = pParentItem->GetAccessoryParams(pAttachedEntity->GetClass());
attach_helper = pParams->attach_helper.c_str();
pAttachedEntity = pParentItem->GetEntity();
}
}
}
if(pAttachedEntity)
{
ICharacterInstance *pCharacter = pAttachedEntity->GetCharacter(eIGS_FirstPerson);
if (pCharacter)
{
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pLaserAttachment = pAttachmentManager->GetInterfaceByName(LASER_ATTACH_NAME);
if(!pLaserAttachment)
{
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(attach_helper);
if(pAttachment)
{
const char* pBone = pCharacter->GetIDefaultSkeleton().GetJointNameByID(pAttachment->GetJointID());
pLaserAttachment = pAttachmentManager->CreateAttachment(LASER_ATTACH_NAME, CA_BONE, pBone);
if(pLaserAttachment)
{
QuatT relative = pAttachment->GetAttRelativeDefault();
if(pOwnerItem->GetEntity() != pAttachedEntity)
{
Matrix34 mtx(relative);
relative.t = relative * offset;
}
pLaserAttachment->SetAttRelativeDefault(relative);
}
}
}
if(pLaserAttachment)
{
CEntityAttachment* pEntAttach = new CEntityAttachment;
pEntAttach->SetEntityId(m_laserEntityId);
pLaserAttachment->AddBinding(pEntAttach);
pLaserAttachment->HideAttachment(0);
m_usingEntityAttachment = true;
}
}
}
}
if(!m_usingEntityAttachment && pOwnerEntity)
{
pOwnerEntity->AttachChild(pLaserEntity);
pLaserEntity->SetLocalTM(Matrix34::CreateTranslationMat(offset));
}
}
}
示例2: AttachLight
//.........这里部分代码省略.........
const bool validSlot = m_pOwnerEntity->GetSlotInfo(targetSlot, slotInfo);
if (!validSlot || slotInfo.pStatObj)
{
//Get helper position on static object (if any)
Vec3 helperPos(ZERO);
Vec3 localHelperPosition = attachParams.offset;
if (validSlot)
{
helperPos = slotInfo.pStatObj->GetHelperPos(helperName);
if (helperPos.IsZero())
{
const int childCount = m_pOwnerEntity->GetChildCount();
for (int i=0;i<childCount;++i)
{
if (IEntity* pChild = m_pOwnerEntity->GetChild(i))
{
if (IStatObj* statObj = pChild->GetStatObj(targetSlot))
{
helperPos = statObj->GetHelperPos(helperName);
if (!helperPos.IsZero())
{
helperPos += pChild->GetPos();
break;
}
}
}
}
}
localHelperPosition = helperPos + attachParams.offset;
localHelperPosition = m_pOwnerEntity->GetSlotLocalTM(targetSlot, false).TransformPoint(localHelperPosition);
}
int attachSlot = FindSafeSlot(attachParams.firstSafeSlot);
++m_effectGeneratorId;
effectInfo.id = m_effectGeneratorId;
effectInfo.entityEffectSlot = m_pOwnerEntity->LoadLight(attachSlot, &light);
if ((effectInfo.entityEffectSlot >= 0) && pMaterial)
{
m_pOwnerEntity->SetSlotMaterial(effectInfo.entityEffectSlot, pMaterial);
}
Matrix34 localEffectMtx = Matrix34(Matrix33::CreateRotationVDir(attachParams.direction));
localEffectMtx.SetTranslation(localHelperPosition);
m_pOwnerEntity->SetSlotLocalTM(effectInfo.entityEffectSlot, localEffectMtx);
m_attachedEffects.push_back(effectInfo);
return m_effectGeneratorId;
}
else if (slotInfo.pCharacter)
{
IAttachmentManager *pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(helperName);
if (pAttachment)
{
CLightAttachment *pLightAttachment = new CLightAttachment();
pLightAttachment->LoadLight(light);
ILightSource* pLightSource = pLightAttachment->GetLightSource();
if (pLightSource)
{
pLightSource->SetMaterial(pMaterial);
pLightSource->SetCastingException(attachParams.pCasterException);
}
pAttachment->AddBinding(pLightAttachment);
const bool customOffset = (attachParams.offset != Vec3Constants<float>::fVec3_Zero) || (attachParams.direction != Vec3Constants<float>::fVec3_OneY);
if (customOffset)
{
pAttachment->SetAttRelativeDefault(QuatT(Quat::CreateRotationVDir(attachParams.direction), attachParams.offset));
}
}
else
{
GameWarning("[EntityEffects] Entity '%s' trying to attach light to attachment '%s' which does not exist!", m_pOwnerEntity->GetName(), helperName);
return 0;
}
++m_effectGeneratorId;
effectInfo.id = m_effectGeneratorId;
effectInfo.helperName = helperName;
effectInfo.characterEffectSlot = targetSlot;
m_attachedEffects.push_back(effectInfo);
return m_effectGeneratorId;
}
return 0;
}
示例3: AttachParticleEffect
TAttachedEffectId CEffectsController::AttachParticleEffect(IParticleEffect* pParticleEffect, const int targetSlot, const char *helperName, const SEffectAttachParams &attachParams)
{
CRY_ASSERT(m_pOwnerEntity);
if (pParticleEffect)
{
SEntitySlotInfo slotInfo;
SEffectInfo effectInfo;
const bool validSlot = m_pOwnerEntity->GetSlotInfo(targetSlot, slotInfo);
if (!validSlot || slotInfo.pStatObj)
{
//Get helper position on static object (if any)
Vec3 localHelperPosition = attachParams.offset;
if (validSlot)
{
const Matrix34& localSlotMtx = m_pOwnerEntity->GetSlotLocalTM(targetSlot, false);
localHelperPosition = slotInfo.pStatObj->GetHelperPos(helperName) + attachParams.offset;
localHelperPosition = localSlotMtx.TransformPoint(localHelperPosition);
}
int attachSlot = FindSafeSlot(attachParams.firstSafeSlot);
//Offset particle to desired location
effectInfo.entityEffectSlot = m_pOwnerEntity->LoadParticleEmitter(attachSlot, pParticleEffect, 0, attachParams.prime, false);
Matrix34 localEffectMtx(IParticleEffect::ParticleLoc(localHelperPosition, attachParams.direction, attachParams.scale));
m_pOwnerEntity->SetSlotLocalTM(effectInfo.entityEffectSlot, localEffectMtx);
++m_effectGeneratorId;
effectInfo.id = m_effectGeneratorId;
m_attachedEffects.push_back(effectInfo);
return m_effectGeneratorId;
}
else if (slotInfo.pCharacter)
{
IAttachmentManager *pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(helperName);
if (pAttachment)
{
CEffectAttachment *pEffectAttachment = new CEffectAttachment(pParticleEffect, attachParams.offset, attachParams.direction, attachParams.scale);
if (attachParams.prime)
{
if (IParticleEmitter* pEmitter = pEffectAttachment->GetEmitter())
{
pEmitter->Prime();
}
}
pAttachment->AddBinding(pEffectAttachment);
pEffectAttachment->ProcessAttachment(pAttachment);
}
else
{
GameWarning("[EntityEffects] Can not attach '%s' to entity '%s', attachment point helper '%s' does not exist", pParticleEffect->GetName(), m_pOwnerEntity->GetName(), helperName);
return 0;
}
++m_effectGeneratorId;
effectInfo.id = m_effectGeneratorId;
effectInfo.characterEffectSlot = targetSlot;
effectInfo.helperName = helperName;
m_attachedEffects.push_back(effectInfo);
return m_effectGeneratorId;
}
}
return 0;
}
示例4: AttachEffect
//------------------------------------------------------------------------
EntityEffects::TAttachedEffectId CItem::AttachEffect(int slot, bool attachToAccessory, const char *effectName, const char *helper, const Vec3 &offset, const Vec3 &dir, float scale, bool prime)
{
if(!g_pGameCVars->i_particleeffects)
{
return 0;
}
Vec3 finalOffset(offset);
string helperName(helper);
if(attachToAccessory)
{
SEntitySlotInfo slotInfo;
QuatT accessoryOffset;
accessoryOffset.SetIdentity();
const char* accessoryHelper = "";
const char* accessoryName = NULL;
const int numAccessories = m_accessories.size();
for (int curIndex = 0; curIndex < numAccessories; curIndex++)
{
IEntity* pAccessory = gEnv->pEntitySystem->GetEntity(m_accessories[curIndex].accessoryId);
if(pAccessory && pAccessory->GetSlotInfo(slot, slotInfo))
{
if(slotInfo.pStatObj)
{
accessoryOffset.t = slotInfo.pStatObj->GetHelperPos(helper);
if(!accessoryOffset.t.IsZero())
{
accessoryOffset.q = pAccessory->GetRotation();
accessoryOffset.t += pAccessory->GetPos();
accessoryName = m_accessories[curIndex].pClass->GetName();
break;
}
}
if(slotInfo.pCharacter)
{
IAttachmentManager *pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(helper);
if(pAttachment)
{
accessoryHelper = GetAccessoryParams(m_accessories[curIndex].pClass)->attach_helper.c_str();
accessoryName = m_accessories[curIndex].pClass->GetName();
accessoryOffset = pAttachment->GetAttAbsoluteDefault();
break;
}
}
}
}
if(accessoryName)
{
bool validSlot = GetEntity()->GetSlotInfo(slot, slotInfo) && (slotInfo.pCharacter || slotInfo.pStatObj);
if (!validSlot || slotInfo.pStatObj)
{
if (validSlot)
{
Matrix34 mtx = GetEntity()->GetSlotLocalTM(slot, false) * Matrix34(accessoryOffset);
finalOffset += mtx.GetTranslation();
}
EntityEffects::SEffectAttachParams attachParams(finalOffset, dir, scale, prime, eIGS_Last);
return m_effectsController.AttachParticleEffect(effectName, attachParams);
}
else if (slotInfo.pCharacter) // bone attachment
{
ICharacterInstance *pCharacter = slotInfo.pCharacter;
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = NULL;
helperName = string().Format("%s_%s", helper, accessoryName);
pAttachment = pAttachmentManager->GetInterfaceByName(helperName.c_str());
if(!pAttachment)
{
IAttachment* pAccessoryAttachment = pAttachmentManager->GetInterfaceByName(accessoryHelper);
if(pAccessoryAttachment)
{
const char* bone = pCharacter->GetIDefaultSkeleton().GetJointNameByID(pAccessoryAttachment->GetJointID());
pAttachment = pAttachmentManager->CreateAttachment(helperName.c_str(), CA_BONE, bone);
if (pAttachment)
{
QuatT relative = pAccessoryAttachment->GetAttRelativeDefault();
relative = relative * accessoryOffset;
relative.t = relative * finalOffset;
finalOffset.zero();
//.........这里部分代码省略.........
示例5: EnableFogVolume
void CFlashLight::EnableFogVolume(CWeapon* pWeapon, int slot, bool enable)
{
if (!g_pGameCVars->i_flashlight_has_fog_volume)
{
return;
}
if (!m_sharedparams->pFlashLightParams)
{
return;
}
IEntity* pFogVolume = 0;
if (m_fogVolume == 0)
{
const Vec3 size = Vec3(
m_sharedparams->pFlashLightParams->fogVolumeRadius,
m_sharedparams->pFlashLightParams->fogVolumeSize,
m_sharedparams->pFlashLightParams->fogVolumeRadius);
SEntitySpawnParams fogVolumeParams;
fogVolumeParams.pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("FogVolume");
fogVolumeParams.nFlags = ENTITY_FLAG_NO_SAVE;
fogVolumeParams.vPosition = Vec3(ZERO);
pFogVolume = gEnv->pEntitySystem->SpawnEntity(fogVolumeParams);
if (!pFogVolume)
{
return;
}
m_fogVolume = pFogVolume->GetId();
SmartScriptTable pProperties;
pFogVolume->GetScriptTable()->GetValue("Properties", pProperties);
if (pProperties)
{
pProperties->SetValue("color_Color", m_sharedparams->pFlashLightParams->fogVolumeColor);
pProperties->SetValue("GlobalDensity", m_sharedparams->pFlashLightParams->fogVolumeDensity);
pProperties->SetValue("Size", size);
pProperties->SetValue("FallOffScale", 0.0f);
}
EntityScripts::CallScriptFunction(pFogVolume, pFogVolume->GetScriptTable(), "OnPropertyChange");
pFogVolume->Activate(true);
}
else
{
pFogVolume = gEnv->pEntitySystem->GetEntity(m_fogVolume);
}
if (!pFogVolume)
{
return;
}
const char* attachHelper = "lightFog_term";
const float distance = m_sharedparams->pFlashLightParams->fogVolumeSize * 0.5f;
ICharacterInstance* pCharacter = pWeapon->GetEntity()->GetCharacter(slot);
if (enable && pCharacter)
{
IAttachmentManager* pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment* pAttachment = pAttachmentManager->GetInterfaceByName(attachHelper);
if (pAttachment)
{
CEntityAttachment* pEntityAttachment = new CEntityAttachment();
pEntityAttachment->SetEntityId(m_fogVolume);
pAttachment->AddBinding(pEntityAttachment);
QuatT relative(IDENTITY);
relative.t.y = distance;
pAttachment->SetAttRelativeDefault(relative);
}
}
pFogVolume->Hide(!enable);
}
示例6: GetEntity
//------------------------------------------------------------------------
bool CC4Projectile::StickToCharacter(bool stick,IEntity *pActor)
{
if(!pActor)
return false;
//Check for friendly AI
if(pActor->GetAI())
{
if(CWeapon *pWeapon = GetWeapon())
{
if(CActor *pPlayer = pWeapon->GetOwnerActor())
{
if(IAIObject *pPlayerAI = pPlayer->GetEntity()->GetAI())
{
if(pActor->GetAI()->IsFriendly(pPlayerAI, false))
{
return false;
}
}
}
}
}
ICharacterInstance *pCharacter = pActor->GetCharacter(0);
if(!pCharacter)
return false;
//Actors doesn't support constraints, try to stick as character attachment
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = NULL;
//Select one of the attachment points
Vec3 charOrientation = pActor->GetRotation().GetColumn1();
Vec3 c4ToChar = pActor->GetWorldPos() - GetEntity()->GetWorldPos();
c4ToChar.Normalize();
//if(c4ToChar.Dot(charOrientation)>0.0f)
//pAttachment = pAttachmentManager->GetInterfaceByName("c4_back");
//else
pAttachment = pAttachmentManager->GetInterfaceByName("c4_front");
if(!pAttachment)
{
GameWarning("No c4 face attachment found in actor");
if(!pAttachment)
return false;
}
if(stick)
{
//Check if there's already one
if(IAttachmentObject *pAO = pAttachment->GetIAttachmentObject())
return false;
CEntityAttachment *pEntityAttachment = new CEntityAttachment();
pEntityAttachment->SetEntityId(GetEntityId());
pAttachment->AddBinding(pEntityAttachment);
pAttachment->HideAttachment(0);
m_stuck = true;
}
else
{
pAttachment->ClearBinding();
m_stuck = false;
}
return true;
}