本文整理汇总了C++中CNetworkVehicle::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CNetworkVehicle::GetPosition方法的具体用法?C++ CNetworkVehicle::GetPosition怎么用?C++ CNetworkVehicle::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNetworkVehicle
的用法示例。
在下文中一共展示了CNetworkVehicle::GetPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCoordinates
// getVehicleCoordinates(vehicleid)
SQInteger CVehicleNatives::GetCoordinates(SQVM * pVM)
{
EntityId vehicleId;
sq_getentity(pVM, -1, &vehicleId);
CNetworkVehicle * pVehicle = g_pClient->GetVehicleManager()->Get(vehicleId);
if(pVehicle)
{
CVector3 vecPosition;
pVehicle->GetPosition(vecPosition);
CSquirrelArguments args;
args.push(vecPosition.fX);
args.push(vecPosition.fY);
args.push(vecPosition.fZ);
sq_pusharg(pVM, CSquirrelArgument(args, true));
return 1;
}
sq_pushbool(pVM, false);
return 1;
}
示例2: SavePosCommand
void SavePosCommand(char * szParams)
{
FILE * file = fopen(SharedUtility::GetAbsolutePath("SavedData.txt"), "a");
if(!file)
{
g_pClient->GetChatWindow()->AddInfoMessage("Failed to open 'SavedData.txt'");
return;
}
CVector3 vecPosition;
// Get our local player
CLocalPlayer * pLocalPlayer = g_pClient->GetLocalPlayer();
if(pLocalPlayer->IsInVehicle())
{
CNetworkVehicle * pVehicle = pLocalPlayer->GetVehicle();
if(pVehicle)
{
pVehicle->GetPosition(vecPosition);
CVector3 vecRotation;
pVehicle->GetRotation(vecRotation);
BYTE byteColors[4];
pVehicle->GetColors(byteColors[0], byteColors[1], byteColors[2], byteColors[3]);
fprintf(file, "createVehicle(%d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d);%s%s\n", g_pClient->GetModelManager()->ModelHashToVehicleId(pVehicle->GetModelInfo()->GetHash()), vecPosition.fX, vecPosition.fY, vecPosition.fZ, vecRotation.fX, vecRotation.fY, vecRotation.fZ, byteColors[0], byteColors[1], byteColors[2], byteColors[3], szParams ? " // " : "", szParams ? szParams : "");
}
}
else
{
pLocalPlayer->GetPosition(vecPosition);
int iModelId = ModelHashToSkinId(pLocalPlayer->GetModelInfo()->GetHash());
fprintf(file, "PlayerData(%d, %f, %f, %f, %f(%f));%s%s\n", iModelId, vecPosition.fX, vecPosition.fY, vecPosition.fZ, pLocalPlayer->GetCurrentHeading(), pLocalPlayer->GetDesiredHeading(),szParams ? " // " : "", szParams ? szParams : "");
}
fclose(file);
g_pClient->GetChatWindow()->AddInfoMessage("Position data saved to 'SavedData.txt'");
}
示例3: Direct3DRender
//.........这里部分代码省略.........
{
if(g_iCameraTime > 500)
{
if(g_iCameraState == 1)
g_iCameraState = 2;
else if(g_iCameraState == 2)
g_iCameraState = 3;
else if(g_iCameraState == 3)
g_iCameraState = 1;
g_iCameraTime = 0;
if(g_iCameraState == 1)
{
g_pCamera->SetPosition(CVector3(HAPPINESS_CAMERA_POS));
//g_pCamera->SetLookAt(CVector3(HAPPINESS_CAMERA_LOOK_AT));
}
if(g_iCameraState == 2)
{
g_pCamera->SetPosition(CVector3(TRIANGLE_CAMERA_POS));
//g_pCamera->SetLookAt(CVector3(TRIANGLE_CAMERA_LOOK_AT));
}
if(g_iCameraState == 3)
{
g_pCamera->SetPosition(CVector3(TRIANGLE_CAMERA_POS_OLD));
//g_pCamera->SetLookAt(CVector3(TRIANGLE_CAMERA_LOOK_AT_OLD));
}
}
else
{
g_iCameraTime++;
CVector3 vecPosition;
g_pCamera->GetPosition(vecPosition);
vecPosition.fX += 0.1f;
vecPosition.fY += 0.1f;
g_pCamera->SetPosition(vecPosition);
}
}
}
if(g_pNetworkManager)
{
if(!g_pNetworkManager->IsConnected() && CGame::IsGameLoaded())
{
if(CGame::GetState() == (eState)3)
CGame::SetState(GAME_STATE_IVMP_PAUSE_MENU);
if(!g_pMainMenu->IsVisible() && !CGame::IsMenuActive())
CGame::SetState(GAME_STATE_IVMP_PAUSE_MENU);
}
}*/
// Are we in game?
if(CGame::GetState() == GAME_STATE_INGAME)
{
// Is F4 held down and do we have a network manager?
if(GetAsyncKeyState(VK_F4) && g_pNetworkManager)
{
// Get the network statistics
CNetStats * pNetStats = g_pNetworkManager->GetNetClient()->GetNetStats();
// Convert the network statistics to a string
char szNetworkStats[10000];
pNetStats->ToString(szNetworkStats, 2);
示例4: if
//.........这里部分代码省略.........
}
}
// Are we in game?
if(CGame::GetState() == GAME_STATE_INGAME)
{
// Is F4 held down and do we have a network manager?
if(GetAsyncKeyState(VK_F4) && m_pNetworkManager && m_pActorManager)
{
// Get the network statistics
CNetStats * pNetStats = m_pNetworkManager->GetNetClient()->GetNetStats();
// Convert the network statistics to a string
char szNetworkStats[10000];
pNetStats->ToString(szNetworkStats, 2);
// Create the statistics string
String strStats(szNetworkStats);
// Append loaded and unloaded model counts to the stats
// jenksta: too performance heavy to be done every frame
//strStats.AppendF("Models (Loaded/Unload): %d/%d\n", CGame::GetLoadedModelCount(), CGame::GetUnloadedModelCount());
// Append streamed in/out entity counts and streamed in limits to the stats
strStats.AppendF("Players (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_PLAYER)+1, m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_PLAYER));
strStats.AppendF("Vehicles (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_VEHICLE), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_VEHICLE));
strStats.AppendF("Actors (Actor-Count/Max-Actors): %d/%d\n", m_pActorManager->GetActorCount(), MAX_ACTORS);
strStats.AppendF("Pickups (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_PICKUP), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_PICKUP));
strStats.AppendF("Objects (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_OBJECT), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_OBJECT));
strStats.AppendF("Checkpoints (StreamedIn/StreamedInLimit): %d/%d\n", m_pStreamer->GetStreamedInEntityCountOfType(STREAM_ENTITY_CHECKPOINT), m_pStreamer->GetStreamedInLimitOfType(STREAM_ENTITY_CHECKPOINT));
// Draw the string
m_pGUI->DrawText(strStats, CEGUI::Vector2(26, 30), (CEGUI::colour)D3DCOLOR_RGBA(255, 255, 255, 255), m_pGUI->GetFont("tahoma-bold", 10));
m_pChatWindow->SetEnabled(false);
m_bNetworkStatsDisplayed = true;
}
else
{
// If our network stats were displayed
if(m_bNetworkStatsDisplayed)
{
if(m_pChatWindow && !m_pChatWindow->IsEnabled())
m_pChatWindow->SetEnabled(true);
m_bNetworkStatsDisplayed = false;
}
// If our input window exists draw it
if(m_pInputWindow)
m_pInputWindow->Draw();
}
// Update the time
if(m_pTime)
{
// jenksta: Setting this every frame causes the weather to change
// rapidly
unsigned char ucHour = 0, ucMinute = 0;
m_pTime->GetTime(&ucHour, &ucMinute);
CGame::SetTime(ucHour, ucMinute);
CGame::SetDayOfWeek(m_pTime->GetDayOfWeek());
}
#ifdef IVMP_DEBUG
if(m_pVehicleManager)
{
CVector3 vecWorldPosition;
Vector2 vecScreenPosition;
for(EntityId i = 0; i < MAX_VEHICLES; i++)
{
CNetworkVehicle * pVehicle = m_pVehicleManager->Get(i);
if(pVehicle)
{
if(!pVehicle->IsStreamedIn())
continue;
if(!pVehicle->IsOnScreen())
continue;
pVehicle->GetPosition(vecWorldPosition);
if(!CGame::GetScreenPositionFromWorldPosition(vecWorldPosition, vecScreenPosition))
continue;
int iHealth = pVehicle->GetHealth();
int iModel = pVehicle->GetEngineState();
float fPetrol = pVehicle->GetPetrolTankHealth();
CVector3 vecPos; pVehicle->GetPosition(vecPos);
CVector3 vecRot; pVehicle->GetRotation(vecRot);
m_pGUI->DrawText(String("VehicleId %d, Enginestate: %d, Health: %d, PetrolTankHealth: %f\nPosition(%.3f,%.3f,%.3f), Rot(%.3f,%.3f,%.3f)", i, iModel, iHealth, fPetrol, vecPos.fX,vecPos.fY,vecPos.fZ,vecRot.fX,vecRot.fY,vecRot.fZ), CEGUI::Vector2(vecScreenPosition.fX, vecScreenPosition.fY));
}
}
}
#endif
if(m_pNameTags)
m_pNameTags->Draw();
}
}
示例5: GetClosestVehicle
void CLocalPlayer::GetClosestVehicle( CNetworkVehicle ** pNetworkVehicle, EntityId * seatId )
{
// Are we spawned and not dead and not already in a vehicle?
if( IsSpawned() && !IsDead() && !m_pPlayerPed->GetCurrentVehicle() )
{
//
float fCurrentDistance = 2.68f;
CVector3 vecVehiclePos;
CNetworkVehicle * pClosestVehicle = NULL;
// Get our position
CVector3 vecCurrentPosition;
GetPosition( &vecCurrentPosition );
// Loop through all network vehicles
for( int i = 0; i < MAX_VEHICLES; i++ )
{
// Is the current vehicle active?
if( pCore->GetVehicleManager()->IsActive( i ) )
{
// Get a pointer to the current vehicle
CNetworkVehicle * pCurrentVehicle = pCore->GetVehicleManager()->Get( i );
// Get the vehicle position
pCurrentVehicle->GetPosition( &vecVehiclePos );
// Get the distance between the current vehicle and us
float fDistance = Math::GetDistanceBetweenPoints( vecCurrentPosition, vecVehiclePos );
// Is this distance less than the current distance?
if( fDistance < fCurrentDistance )
{
// Set the current distance
fCurrentDistance = fDistance;
// Set the closest vehicle
pClosestVehicle = pCurrentVehicle;
}
}
}
// Isn't there a vehicle in range?
if( !pClosestVehicle )
return;
// Loop through all the passenger seats
BYTE byteCurrentSeat = 0;
for( BYTE i = 2; i < 5; i++ )
{
// Is there no one in this seat?
if( !pClosestVehicle->GetVehicle()->GetSeatOccupant( i ) )
{
byteCurrentSeat = i;
break;
}
}
// Didn't we find a seat?
if( !byteCurrentSeat )
return;
// Set the seat
*seatId = byteCurrentSeat;
// Set the vehicle
*pNetworkVehicle = pClosestVehicle;
}
}
示例6: SendInVehicleSync
void CLocalPlayer::SendInVehicleSync( void )
{
// Are we not connected to the network?
if( !pCore->GetNetworkModule()->IsConnected() )
return;
// Are we dead?
if( IsDead() )
return;
// Get the vehicle instance
CNetworkVehicle * pVehicle = pCore->GetVehicleManager()->GetFromGameGUID( GetPlayerPed()->GetCurrentVehicle()->m_dwGUID );
// Did we fail to find the vehicle?
if( !pVehicle )
return;
// Construct a new bitstream
RakNet::BitStream pBitStream;
// Write the vehicle id
pBitStream.WriteCompressed( pVehicle->GetId() );
// Construct a new in vehicle sync data structure
InVehicleSync inVehicleSync;
// Get the vehicle position
pVehicle->GetPosition( &inVehicleSync.m_vecPosition );
// Get the vehicle rotation
pVehicle->GetRotation( &inVehicleSync.m_vecRotation );
// Get the vehicle dirt level
inVehicleSync.m_fDirtLevel = pVehicle->GetVehicle()->GetDirtLevel();
// Get the vehicle tuning table
inVehicleSync.m_iTuningTable = pVehicle->GetVehicle()->GetTuningTable();
// Get the vehicle horn state
inVehicleSync.m_bHornState = pVehicle->GetVehicle()->IsHornOn();
// Get the vehicle siren state
inVehicleSync.m_bSirenState = pVehicle->GetVehicle()->IsSirenOn();
// Get the vehicle fuel
inVehicleSync.m_fFuel = pVehicle->GetVehicle()->GetFuel();
// Get the vehicle speed
pVehicle->GetSpeedVec( &inVehicleSync.m_vecVelocity );
// Get the turn speed
inVehicleSync.m_fTurnSpeed = pVehicle->GetSteer();
// Get the engine damage
inVehicleSync.m_fEngineDamage = pVehicle->GetVehicle()->GetEngineDamage();
// Get the vehicle plate text
strcpy( inVehicleSync.m_szPlateText, pVehicle->GetPlateText() );
inVehicleSync.m_szPlateText[ 6 ] = '\0';
// Get the vehicle colour
pVehicle->GetColour( &inVehicleSync.m_primaryColour, &inVehicleSync.m_secondaryColour );
// Get the power state
inVehicleSync.m_bPower = pVehicle->GetVehicle()->GetPower();
// Get the brake state
inVehicleSync.m_bBrake = pVehicle->GetVehicle()->GetBrake();
// Get the vehicle wheel models (DISABLED FOR TESTING)
for ( int i = 0; i < 3; i++ )
inVehicleSync.m_bWheelModels[ i ] = 0xFF; //Game::GetIdFromVehicleWheelModel ( pVehicle->GetVehicle()->GetWheelTexture ( i ) );
// Get the handbrake state
inVehicleSync.m_bHandbrake = pVehicle->GetVehicle()->IsHandbrakeOn ();
// Get the light state
inVehicleSync.m_bLightState = pVehicle->GetVehicle()->GetLightState ();
// Write the sync structure into the bitstream
pBitStream.Write( (char *)&inVehicleSync, sizeof(InVehicleSync) );
// Send the bitstream to the server
pCore->GetNetworkModule()->Call( RPC_VEHICLE_SYNC, &pBitStream, LOW_PRIORITY, UNRELIABLE_SEQUENCED, true );
}