本文整理汇总了C++中TMatrix::SetTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ TMatrix::SetTranslation方法的具体用法?C++ TMatrix::SetTranslation怎么用?C++ TMatrix::SetTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMatrix
的用法示例。
在下文中一共展示了TMatrix::SetTranslation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MoveThink
void CCharacter::MoveThink()
{
if (!GetGroundEntity())
return;
if (m_vecGoalVelocity.LengthSqr())
m_vecGoalVelocity.Normalize();
m_vecMoveVelocity.x = Approach(m_vecGoalVelocity.x, m_vecMoveVelocity.x, GameServer()->GetFrameTime()*4);
m_vecMoveVelocity.y = 0;
m_vecMoveVelocity.z = Approach(m_vecGoalVelocity.z, m_vecMoveVelocity.z, GameServer()->GetFrameTime()*4);
if (m_vecMoveVelocity.LengthSqr() > 0)
{
TMatrix m = GetLocalTransform();
Vector vecUp = GetUpVector();
if (HasMoveParent())
{
TMatrix mGlobalToLocal = GetMoveParent()->GetGlobalToLocalTransform();
vecUp = mGlobalToLocal.TransformNoTranslate(vecUp);
}
Vector vecRight = m.GetForwardVector().Cross(vecUp).Normalized();
Vector vecForward = vecUp.Cross(vecRight).Normalized();
m.SetColumn(0, vecForward);
m.SetColumn(1, vecUp);
m.SetColumn(2, vecRight);
TVector vecMove = m_vecMoveVelocity * CharacterSpeed();
TVector vecLocalVelocity = m.TransformNoTranslate(vecMove);
SetLocalVelocity(vecLocalVelocity);
}
else
SetLocalVelocity(TVector());
eastl::vector<CEntityHandle<CBaseEntity> > apCollisionList;
size_t iMaxEntities = GameServer()->GetMaxEntities();
for (size_t j = 0; j < iMaxEntities; j++)
{
CBaseEntity* pEntity2 = CBaseEntity::GetEntity(j);
if (!pEntity2)
continue;
if (pEntity2->IsDeleted())
continue;
if (pEntity2 == this)
continue;
if (!pEntity2->ShouldCollide())
continue;
apCollisionList.push_back(pEntity2);
}
TMatrix mGlobalToLocalRotation;
if (HasMoveParent())
{
mGlobalToLocalRotation = GetMoveParent()->GetGlobalToLocalTransform();
mGlobalToLocalRotation.SetTranslation(TVector());
}
float flSimulationFrameTime = 0.01f;
// Break simulations up into consistent small steps to preserve accuracy.
for (; m_flMoveSimulationTime < GameServer()->GetGameTime(); m_flMoveSimulationTime += flSimulationFrameTime)
{
TVector vecVelocity = GetLocalVelocity();
TVector vecLocalOrigin = GetLocalOrigin();
TVector vecGlobalOrigin = GetGlobalOrigin();
vecVelocity = vecVelocity * flSimulationFrameTime;
TVector vecLocalDestination = vecLocalOrigin + vecVelocity;
TVector vecGlobalDestination = vecLocalDestination;
if (GetMoveParent())
vecGlobalDestination = GetMoveParent()->GetGlobalTransform() * vecLocalDestination;
TVector vecNewLocalOrigin = vecLocalDestination;
size_t iTries = 0;
while (true)
{
iTries++;
TVector vecPoint, vecNormal;
TVector vecLocalCollisionPoint, vecGlobalCollisionPoint;
bool bContact = false;
for (size_t i = 0; i < apCollisionList.size(); i++)
{
CBaseEntity* pEntity2 = apCollisionList[i];
//.........这里部分代码省略.........