本文整理汇总了C++中CVehicle::GetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetMatrix方法的具体用法?C++ CVehicle::GetMatrix怎么用?C++ CVehicle::GetMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetMatrix方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: SendInCarFullSyncData
void CLocalPlayer::SendInCarFullSyncData()
{
if(m_pPlayerPed)
{
RakNet::BitStream bsVehicleSync;
VEHICLE_SYNC_DATA vehicleSyncData;
MATRIX4X4 matVehicle;
CVehicleManager * pVehicleManager = pNetowkManager->GetVehicleManager();
CVehicle * pGameVehicle = NULL;
// write packet id
bsVehicleSync.Write((MessageID)ID_VEHICLE_SYNC);
vehicleSyncData.vehicleID = pVehicleManager->FindIDFromGtaPtr(m_pPlayerPed->GetGtaVehicle());
// make sure we have a valid vehicle
if(vehicleSyncData.vehicleID == INVALID_ENTITY_ID)
{
return;
}
// get the player keys
vehicleSyncData.wKeys = m_pPlayerPed->GetKeys();
// get the vehicle pointer
pGameVehicle = pVehicleManager->GetAt(vehicleSyncData.vehicleID);
// make sure the vehicle pointer is valid
if(!pGameVehicle)
{
return;
}
// get the vehicle matrix
pGameVehicle->GetMatrix(&matVehicle);
// copy the roll and direction vectors
memcpy(&vehicleSyncData.vecRoll, &matVehicle.vLookRight, sizeof(Vector3));
memcpy(&vehicleSyncData.vecDirection, &matVehicle.vLookUp, sizeof(Vector3));
// pack the roll and direction vectors
//CompressVector1(&matVehicle.vLookRight, &vehicleSyncData.cvecRoll);
//CompressVector1(&matVehicle.vLookUp, &vehicleSyncData.cvecDirection);
// copy the vehicle position
memcpy(&vehicleSyncData.vecPos, &matVehicle.vPos, sizeof(Vector3));
// get the vehicle move speed
pGameVehicle->GetMoveSpeed(&vehicleSyncData.vecMoveSpeed);
// get the vehicle turn speed
pGameVehicle->GetTurnSpeed(&vehicleSyncData.vecTurnSpeed);
// pack the vehicle health
vehicleSyncData.byteVehicleHealth = PACK_VEHICLE_HEALTH(pGameVehicle->GetHealth());
// get the player health (casted to a byte to save space)
vehicleSyncData.bytePlayerHealth = (BYTE)m_pPlayerPed->GetHealth();
// get the player armour (casted to a byte to save space)
vehicleSyncData.bytePlayerArmour = (BYTE)m_pPlayerPed->GetArmour();
// write vehicle sync struct to bit stream
bsVehicleSync.Write((char *)&vehicleSyncData, sizeof(VEHICLE_SYNC_DATA));
// send sync data
pNetowkManager->GetRakPeer()->Send(&bsVehicleSync,HIGH_PRIORITY,UNRELIABLE_SEQUENCED,0,UNASSIGNED_SYSTEM_ADDRESS,TRUE);
}
}
示例3: ProcessVehicleSirenPosition
//.........这里部分代码省略.........
}
}
else
{
// Set our Randomiser
ucRandomiser = rand () % ucVehicleSirenCount;
if ( bPointLights == false )
{
// Update our stored Randomiser
pVehicle->SetSirenRandomiser ( ucRandomiser );
}
}
}
else
{
ucRandomiser++;
if ( ucRandomiser >= ucVehicleSirenCount )
{
ucRandomiser = 0;
}
if ( bPointLights == false )
{
// Update our stored Randomiser
pVehicle->SetSirenRandomiser ( ucRandomiser );
}
}
ucSirenCount = ucRandomiser;
if ( bPointLights == false )
{
// Gete our siren position for this siren count
pVehicle->GetVehicleSirenPosition ( ucSirenCount, *vecRelativeSirenPosition );
}
if ( bPointLights == false )
{
// Are we skipping LOS Checks?
if ( pVehicle->IsSirenLOSCheckEnabled ( ) )
{
// Storage 'n stuff
CMatrix matCamera;
CMatrix matVehicle;
// Grab our vehicle matrix
pVehicle->GetMatrix( &matVehicle );
// Get our Camera
CCamera* pCamera = pGameInterface->GetCamera ();
// Get the Camera Matrix
pCamera->GetMatrix( &matCamera );
// Get our sirens ACTUAL position from the relative value
CVector vecSirenPosition = matVehicle.TransformVector ( *vecRelativeSirenPosition );
// Setup our LOS flags
SLineOfSightFlags flags;
flags.bCheckBuildings = false;
flags.bCheckDummies = false;
flags.bCheckObjects = false;
flags.bCheckPeds = false;
flags.bCheckVehicles = true;
flags.bIgnoreSomeObjectsForCamera = false;
flags.bSeeThroughStuff = false;
flags.bShootThroughStuff = false;
// Ignore nothing
pGameInterface->GetWorld()->IgnoreEntity ( NULL );
// Variables 'n tings
CColPoint* pColPoint = NULL;
CEntity* pGameEntity = NULL;
// Check if we can see it
if ( pGameInterface->GetWorld()->IsLineOfSightClear ( &matCamera.vPos, &vecSirenPosition, flags ) == false )
{
// Nope? Invisible
dwRed = 0;
dwGreen = 0;
dwBlue = 0;
}
else
{
// Yep?
SetupSirenColour ( pVehicle );
}
}
else
{
// Skip LOS Checks.
SetupSirenColour ( pVehicle );
}
// Set our current Siren ID after we increment it
pVehicle->SetVehicleCurrentSirenID ( ++ucSirenCount );
}
bPointLights = false;
// Return true
return true;
}
}
}
bPointLights = false;
// Return false
return false;
}
示例4: 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;
}
}
示例5: cheat_handle_quickwarp
void cheat_handle_quickwarp(struct vehicle_info *vehicle_info, struct actor_info *actor_info)
{
if (KEYCOMBO_PRESSED(set.key_quickwarp))
{
CCam *pCam = pGame->GetCamera()->GetCam(pGame->GetCamera()->GetActiveCam());
CVector camsrc(*pCam->GetSource()), src, target, tppos;
CColPoint *pCollision = nullptr;
CEntitySAInterface *pEntity = nullptr;
if (pCam->GetMode() == MODE_AIMWEAPON || pCam->GetMode() == MODE_AIMWEAPON_ATTACHED || pCam->GetMode() == MODE_AIMWEAPON_FROMCAR)
{
// calculate target position by aim vector
pGame->GetCamera()->Find3rdPersonCamTargetVector(700.0f, &camsrc, &src, &target);
}
else
{
// else by camera vector
target = camsrc + *pCam->GetFront() * 700.0f;
}
// ignore self vehicle
if (vehicle_info != nullptr)
{
*(::vehicle_info **)VAR_IgnoredEntity = vehicle_info;
}
if (GTAfunc_ProcessLineOfSight(&camsrc, &target, &pCollision, &pEntity, true, true, false, true, true, false, false, false))
{
tppos = *pCollision->GetPosition();
tppos -= (*pCollision->GetNormal()) * 0.5f;
if (pCollision->GetNormal()->fZ >= 0.5f || pPedSelf->GetAreaCode() != 0)
{
tppos.fZ += 1.0f;
tppos.fZ = pGameInterface->GetWorld()->FindGroundZFor3DPosition(&tppos);
}
else
{
tppos.fZ = pGameInterface->GetWorld()->FindGroundZForPosition(tppos.fX, tppos.fY);
}
if (vehicle_info != nullptr)
{
// check for collision
CVehicle *vehSelf = pPedSelf->GetVehicle();
if (vehSelf)
{
pCollision->Destroy();
// check for collision
CVector vecVehicleGravity;
vehSelf->GetGravity(&vecVehicleGravity);
CVector vecVehicleAbove = (-vecVehicleGravity * 5.0f) + tppos;
CVector vecVehicleBelow = (vecVehicleGravity * 5.0f) + tppos;
bool bCollision = GTAfunc_ProcessLineOfSight(&vecVehicleAbove, &vecVehicleBelow, &pCollision, &pEntity,
true, false, false, true, true, false, false, false); // not checking for vehicle collisions
if (bCollision && pCollision)
{
// set vehicle to same Up position has surface normal
CMatrix matVehicleSelf;
vehSelf->GetMatrix(&matVehicleSelf);
CVector vecCollisionNormal = *pCollision->GetNormal();
// get "down" from vehicle model
CVector rotationAxis = matVehicleSelf.vUp;
// normalize our vectors
vecCollisionNormal.Normalize();
rotationAxis.Normalize();
// axis and rotation for gravity
float theta = acos(rotationAxis.DotProduct(&vecCollisionNormal));
if (!near_zero(theta))
{
rotationAxis.CrossProduct(&vecCollisionNormal);
rotationAxis.Normalize();
rotationAxis.ZeroNearZero();
matVehicleSelf = matVehicleSelf.Rotate(&rotationAxis, -theta);
}
// set the new matrix
vehSelf->SetMatrix(&matVehicleSelf);
// set pos floats for actual teleporting
tppos.fX = pCollision->GetPosition()->fX;
tppos.fY = pCollision->GetPosition()->fY;
tppos.fZ = pCollision->GetPosition()->fZ + 1.0f; // should be enough to stay above the ground properly
}
else
{
tppos.fZ += 0.5f;
}
cheat_vehicle_teleport(vehicle_info, &tppos.fX, gta_interior_id_get(), true);
}
}
else if (actor_info != nullptr)
{
tppos.fZ += 1.0f;
cheat_actor_teleport(actor_info, &tppos.fX, gta_interior_id_get());
}
GTAfunc_TogglePlayerControllable(0);
//.........这里部分代码省略.........