本文整理汇总了C++中IAttachment::GetAttWorldAbsolute方法的典型用法代码示例。如果您正苦于以下问题:C++ IAttachment::GetAttWorldAbsolute方法的具体用法?C++ IAttachment::GetAttWorldAbsolute怎么用?C++ IAttachment::GetAttWorldAbsolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAttachment
的用法示例。
在下文中一共展示了IAttachment::GetAttWorldAbsolute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetClosestAttachment
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);
}
示例2: if
//------------------------------------------------------------------------
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;
}
示例3: GetSlotHelperPos
//------------------------------------------------------------------------
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;
}
示例4: GetCharacterAttachmentWorldTM
//------------------------------------------------------------------------
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());
}
示例5: AttachVulnerabilityEffect
//------------------------------------------------------------------------
int CScriptBind_Actor::AttachVulnerabilityEffect(IFunctionHandler *pH, int characterSlot, int partid, Vec3 hitPos, float radius, const char* effect, const char* attachmentIdentifier)
{
CActor *pActor = GetActor(pH);
if (!pActor)
return pH->EndFunction();
IEntity* pEntity = pActor->GetEntity();
ICharacterInstance* pChar = pEntity->GetCharacter(characterSlot);
if (!pChar || !effect)
return pH->EndFunction();
//fallback: use nearest attachment
float minDiff = radius*radius;
IAttachment* pClosestAtt = 0;
IAttachmentManager* pMan = pChar->GetIAttachmentManager();
for (int i=0; i<pMan->GetAttachmentCount(); ++i)
{
IAttachment* pAtt = pMan->GetInterfaceByIndex(i);
float diff = (hitPos - pAtt->GetAttWorldAbsolute().t).len2();
if (diff < minDiff)
{
// only use specified attachments
if (attachmentIdentifier[0] && !strstr(pAtt->GetName(), attachmentIdentifier))
continue;
minDiff = diff;
pClosestAtt = pAtt;
}
//CryLog("diff: %.2f, att: %s", diff, attName.c_str());
}
if (!pClosestAtt)
return pH->EndFunction();
//CryLog("AttachVulnerabilityEffect: closest att %s, attaching effect %s", pClosestAtt->GetName(), effect);
CEffectAttachment *pEffectAttachment = new CEffectAttachment(effect, Vec3(ZERO), Vec3(0,1,0), 1.f);
pClosestAtt->AddBinding(pEffectAttachment);
pClosestAtt->HideAttachment(0);
return pH->EndFunction(pClosestAtt->GetName());
}
示例6: SpawnEffect
//------------------------------------------------------------------------
void CItem::SpawnEffect(int slot, const char *effectName, const char *helper, const Vec3 &offset, const Vec3 &dir, float scale)
{
if (m_stats.mounted)
slot=eIGS_FirstPerson;
Vec3 position(0,0,0);
Vec3 finalOffset = offset;
SEntitySlotInfo slotInfo;
if (GetEntity()->GetSlotInfo(slot, slotInfo))
{
if (slotInfo.pStatObj) // entity slot
{
// get helper position
IStatObj *pStatsObj = slotInfo.pStatObj;
position = pStatsObj->GetHelperPos(helper);
position = GetEntity()->GetSlotWorldTM(slot).TransformPoint(position);
}
else if (slotInfo.pCharacter) // bone attachment
{
ICharacterInstance *pCharacter = slotInfo.pCharacter;
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(helper);
if (pAttachment)
{
const Matrix34 m = Matrix34(pAttachment->GetAttWorldAbsolute());
position = m.GetTranslation();
}
else
{
int16 id = pCharacter->GetISkeletonPose()->GetJointIDByName(helper);
if (id>=0)
position = pCharacter->GetISkeletonPose()->GetAbsJointByID(id).t;
position = GetEntity()->GetSlotWorldTM(slot).TransformPoint(position);
}
}
}
else if(m_stats.mounted && !m_stats.fp)
{
if(GetIWeapon())
{
// if no helper specified, try getting pos from firing locator
IWeaponFiringLocator *pLocator = GetIWeapon()->GetFiringLocator();
if (pLocator)
{
if(!pLocator->GetFiringPos(GetEntityId(), NULL, position))
position.Set(0.0f,0.0f,0.0f);
else
finalOffset = GetEntity()->GetWorldTM().TransformVector(finalOffset);
}
}
}
position += finalOffset;
IParticleEffect *pParticleEffect = gEnv->pParticleManager->FindEffect(effectName);
if (pParticleEffect)
pParticleEffect->Spawn(true, IParticleEffect::ParticleLoc(position, dir, scale));
}