本文整理汇总了C++中Mat4::MakeTranslate方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4::MakeTranslate方法的具体用法?C++ Mat4::MakeTranslate怎么用?C++ Mat4::MakeTranslate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4
的用法示例。
在下文中一共展示了Mat4::MakeTranslate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _upateState
void tPlayerController::_upateState(float timeStep)
{
Vec3 nextStep = Vec3::Zero;
if (mState == eOnLand)
{
nextStep += mForwordVelocity * mNode->GetDirection();
nextStep += mSideVelocity * mNode->GetRight();
}
else if (mState == eOnFall)
{
nextStep += Vec3::UnitY * mGravity;
}
else if (mState == eOnJump)
{
nextStep += mForwordVelocity * mNode->GetDirection();
nextStep += mSideVelocity * mNode->GetRight();
nextStep += mInternalJumpVel * Vec3::UnitY;
}
nextStep *= timeStep;
const Vec3 & worldPos = mNode->GetPosition();
NewtonWorld * ntWorld = tWorld::Instance()->_getNewtonWorld();
NewtonWorldConvexCastReturnInfo info[_NT_MAX_CONTACTS];
Mat4 worldTm;
worldTm.MakeTranslate(worldPos.x, worldPos.y, worldPos.z);
Vec3 dest = worldPos + nextStep;
float hitParam;
// check on land
if (mState == eOnJump)
{
int contacts = NewtonWorldConvexCast(ntWorld, worldTm[0], &dest.x, mShape->_getNewtonCollision(), &hitParam, this,
_convexCastBodyFilter, info, _NT_MAX_CONTACTS, 0);
if (contacts)
{
float bestValue = info[0].m_point[1];
float lowestValue = info[0].m_point[1];
for (int i = 1; i < contacts; i ++)
{
float value = info[i].m_point[1];
if (value > bestValue)
bestValue = value;
if (value < lowestValue)
lowestValue = value;
}
if (mInternalJumpVel >= 0 && bestValue > mPlayerHeight * mJumpHighLimit)
mInternalJumpVel = 0;
/*if (mInternalJumpVel <= 0 && lowestValue < mPlayerHeight * mLandLimit)
{
mState = eOnLand;
}
*/
Vec3 Normal, Position;
if (mInternalJumpVel <= 0 && _checkOnLand(dest, &Normal, &Position))
{
mNode->SetPosition(Position);
mState = eOnLand;
}
}
mNode->SetPosition(dest);
return ;
}
Vec3 Normal, Position;
if (_checkOnLand(dest, &Normal, &Position))
{
int contacts = NewtonWorldConvexCast(ntWorld, worldTm[0], &dest.x, mShape->_getNewtonCollision(), &hitParam, this,
_convexCastBodyFilter, info, _NT_MAX_CONTACTS, 0);
float bestValue = info[0].m_point[1];
float lowestValue = info[0].m_point[1];
for (int i = 1; i < contacts; i ++)
{
float value = info[i].m_point[1];
if (value > bestValue)
bestValue = value;
if (value < lowestValue)
lowestValue = value;
}
if (bestValue < dest.y + mPlayerHeight * mLandLimit)
mState = eOnLand;
//.........这里部分代码省略.........