本文整理汇总了C++中CVehicle::GetMoveSpeedVector方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetMoveSpeedVector方法的具体用法?C++ CVehicle::GetMoveSpeedVector怎么用?C++ CVehicle::GetMoveSpeedVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetMoveSpeedVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InvertSpeed
static void InvertSpeed(void)
{
CPlayerPed* pLocalPlayer = pGame->FindPlayerPed();
if (pLocalPlayer->IsInVehicle())
{
CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
CVehicle* pVehicle = pVehiclePool->GetAt(pVehiclePool->FindIDFromGtaPtr(pLocalPlayer->GetGtaVehicle()));
VECTOR vecMoveSpeed;
pVehicle->GetMoveSpeedVector(&vecMoveSpeed);
vecMoveSpeed.X *= -1;
vecMoveSpeed.Y *= -1;
vecMoveSpeed.Z *= -1;
pVehicle->SetMoveSpeedVector(vecMoveSpeed);
}
}
示例2: UpdateSurfing
void CRemotePlayer::UpdateSurfing()
{
if ( m_ofSync.wSurfInfo > MAX_VEHICLES ) { // its an object
m_ofSync.wSurfInfo -= MAX_VEHICLES; // derive proper object id
CObjectPool* pObjectPool = pNetGame->GetObjectPool();
CObject* pObject = pObjectPool->GetAt((BYTE)m_ofSync.wSurfInfo);
if (pObject) {
MATRIX4X4 objMat;
pObject->GetMatrix(&objMat);
objMat.pos.X += m_ofSync.vecSurfOffsets.X;
objMat.pos.Y += m_ofSync.vecSurfOffsets.Y;
objMat.pos.Z += m_ofSync.vecSurfOffsets.Z;
m_pPlayerPed->SetMatrix(objMat);
}
} else { // must be a vehicle
CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
CVehicle* pVehicle = pVehiclePool->GetAt(m_ofSync.wSurfInfo);
if (pVehicle) {
MATRIX4X4 matPlayer, matVehicle;
VECTOR vecMoveSpeed,vecTurnSpeed;
pVehicle->GetMatrix(&matVehicle);
pVehicle->GetMoveSpeedVector(&vecMoveSpeed);
pVehicle->GetTurnSpeedVector(&vecTurnSpeed);
m_pPlayerPed->GetMatrix(&matPlayer);
matPlayer.pos.X = matVehicle.pos.X + m_ofSync.vecSurfOffsets.X;
matPlayer.pos.Y = matVehicle.pos.Y + m_ofSync.vecSurfOffsets.Y;
matPlayer.pos.Z = matVehicle.pos.Z + m_ofSync.vecSurfOffsets.Z;
m_pPlayerPed->SetMatrix(matPlayer);
m_pPlayerPed->SetMoveSpeedVector(vecMoveSpeed);
//m_pPlayerPed->SetTurnSpeedVector(vecTurnSpeed);
}
}
}
示例3: StoreUnoccupiedSyncData
void CRemotePlayer::StoreUnoccupiedSyncData(UNOCCUPIED_SYNC_DATA * unocSync)
{
VEHICLEID UnocID = unocSync->VehicleID;
if (!UnocID || UnocID == INVALID_VEHICLE_ID) return;
CVehiclePool *pVehiclePool = pNetGame->GetVehiclePool();
CVehicle *pVehicle = NULL;
if (pVehiclePool) {
pVehicle = pVehiclePool->GetAt(UnocID);
pVehiclePool->SetLastUndrivenID(UnocID, m_PlayerID);
}
if(pVehicle && !pVehicle->HasADriver())
{
MATRIX4X4 matWorld;
pVehicle->GetMatrix(&matWorld);
DecompressNormalVector(&matWorld.up, &unocSync->cvecDirection);
DecompressNormalVector(&matWorld.right, &unocSync->cvecRoll);
// if we're pretty already there.. no translation.
if( (FloatOffset(unocSync->vecPos.X,matWorld.pos.X) <= 0.1f) &&
(FloatOffset(unocSync->vecPos.Y,matWorld.pos.Y) <= 0.1f) &&
(FloatOffset(unocSync->vecPos.Z,matWorld.pos.Z) <= 0.1f) )
{
return;
}
// if difference is over 8 units, direct translation
if( !pVehicle->IsAdded() ||
(FloatOffset(unocSync->vecPos.X,matWorld.pos.X) > 8.0f) ||
(FloatOffset(unocSync->vecPos.Y,matWorld.pos.Y) > 8.0f) ||
(FloatOffset(unocSync->vecPos.Z,matWorld.pos.Z) > 8.0f) ) {
matWorld.pos.X = unocSync->vecPos.X;
matWorld.pos.Y = unocSync->vecPos.Y;
matWorld.pos.Z = unocSync->vecPos.Z;
pVehicle->SetMatrix(matWorld);
pVehicle->SetMoveSpeedVector(unocSync->vecMoveSpeed);
pVehicle->SetTurnSpeedVector(unocSync->vecTurnSpeed);
return;
}
// gradually increase/decrease velocities towards the target
pVehicle->SetMatrix(matWorld); // rotation
pVehicle->SetMoveSpeedVector(unocSync->vecMoveSpeed); // move velocity
pVehicle->SetTurnSpeedVector(unocSync->vecTurnSpeed); // turn velocity
VECTOR vec = {0.0f, 0.0f, 0.0f};
pVehicle->GetMoveSpeedVector(&vec);
if( FloatOffset(unocSync->vecPos.X,matWorld.pos.X) > 0.05 ) {
vec.X += (unocSync->vecPos.X - matWorld.pos.X) * 0.05f;
}
if( FloatOffset(unocSync->vecPos.Y,matWorld.pos.Y) > 0.05 ) {
vec.Y += (unocSync->vecPos.Y - matWorld.pos.Y) * 0.05f;
}
if( FloatOffset(unocSync->vecPos.Z,matWorld.pos.Z) > 0.05 ) {
vec.Z += (unocSync->vecPos.Z - matWorld.pos.Z) * 0.05f;
}
pVehicle->SetMoveSpeedVector(vec);
pVehicle->m_bRemoteUnocSync = true;
}
}