本文整理汇总了C++中Matrix34::Invert方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix34::Invert方法的具体用法?C++ Matrix34::Invert怎么用?C++ Matrix34::Invert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix34
的用法示例。
在下文中一共展示了Matrix34::Invert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttachToCharacter
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;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:55,代码来源:MFXParticleEffect.cpp
示例2: if
//-----------------------------------------------
//This function is only executed on the server
void CC4Projectile::Stick(EventPhysCollision *pCollision)
{
assert(pCollision);
int trgId = 1;
IPhysicalEntity *pTarget = pCollision->pEntity[trgId];
if(pTarget == GetEntity()->GetPhysics())
{
trgId = 0;
pTarget = pCollision->pEntity[trgId];
}
//Do not stick to breakable glass
if(ISurfaceType *pSurfaceType = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceType(pCollision->idmat[trgId]))
{
if(pSurfaceType->GetBreakability()==1)
{
m_notStick = true;
return;
}
}
IEntity *pTargetEntity = pTarget ? gEnv->pEntitySystem->GetEntityFromPhysics(pTarget) : 0;
if(pTarget && (!pTargetEntity || (pTargetEntity->GetId() != m_ownerId)))
{
//Special cases
if(pTargetEntity)
{
//Stick to actors using a character attachment
CActor *pActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pTargetEntity->GetId()));
//Not in MP
if(pActor && gEnv->bMultiplayer)
{
m_notStick = true;
return;
}
if(pActor && pActor->GetHealth()>0)
{
if(pActor->GetActorSpecies()!=eGCT_HUMAN)
{
m_notStick = true;
return;
}
if(StickToCharacter(true,pTargetEntity))
{
GetGameObject()->SetAspectProfile(eEA_Physics, ePT_None);
m_stuck = true;
}
m_notStick = true;
return;
}
//Do not stick to small objects...
if(!pActor)
{
pe_params_part pPart;
pPart.ipart = 0;
if(pTarget->GetParams(&pPart) && pPart.pPhysGeom && pPart.pPhysGeom->V<0.15f)
{
m_notStick = true;
return;
}
}
}
else if(pTarget->GetType()==PE_LIVING)
{
m_notStick = true;
return;
}
if(!pTargetEntity)
StickToStaticObject(pCollision,pTarget);
else
{
//Do not attach to items
if(g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pTargetEntity->GetId()))
{
m_notStick = true;
return;
}
Matrix34 mat = pTargetEntity->GetWorldTM();
mat.Invert();
Vec3 pos = mat.TransformPoint(pCollision->pt);
mat.SetIdentity();
mat.SetRotation33(Matrix33::CreateOrientation(-pCollision->n,GetEntity()->GetWorldTM().TransformVector(Vec3(0,0,1)),gf_PI));
mat.SetTranslation(pos);
//Dephysicalize and stick
GetGameObject()->SetAspectProfile(eEA_Physics, ePT_None);
//.........这里部分代码省略.........