当前位置: 首页>>代码示例>>C++>>正文


C++ CNetworkVehicle::IsOnScreen方法代码示例

本文整理汇总了C++中CNetworkVehicle::IsOnScreen方法的典型用法代码示例。如果您正苦于以下问题:C++ CNetworkVehicle::IsOnScreen方法的具体用法?C++ CNetworkVehicle::IsOnScreen怎么用?C++ CNetworkVehicle::IsOnScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CNetworkVehicle的用法示例。


在下文中一共展示了CNetworkVehicle::IsOnScreen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Direct3DRender


//.........这里部分代码省略.........
			// Draw the string
			g_pGUI->DrawText(strStats, CEGUI::Vector2(26, 30), (CEGUI::colour)D3DCOLOR_RGBA(255, 255, 255, 255), g_pGUI->GetFont("tahoma-bold", 10));
			g_pChatWindow->SetEnabled(false);
			g_bNetworkStatsDisplayed = true;
		}
		else
		{
			// If our network stats were displayed
			if(g_bNetworkStatsDisplayed) {
				if(g_pChatWindow && !g_pChatWindow->IsEnabled())
					g_pChatWindow->SetEnabled(true);
				
				g_bNetworkStatsDisplayed = false;
			}

			// If our input window exists draw it
			if(g_pInputWindow)
				g_pInputWindow->Draw();
		}

		// Update the time
		if(g_pTime)
		{
			// jenksta: Setting this every frame causes the weather to change
			// rapidly
			unsigned char ucHour = 0, ucMinute = 0;
			g_pTime->GetTime(&ucHour, &ucMinute);
			CGame::SetTime(ucHour, ucMinute);
			CGame::SetDayOfWeek(g_pTime->GetDayOfWeek());
		}
		/* Vehicle Headlights testcode
			IVVehicle * pGameVehicle = pVehicle->GetGameVehicle()->GetVehicle();
			//*(BYTE *)(pVehicle->GetGameVehicle()->GetVehicle() + 0xF71) |= 1;
			*((BYTE *)pGameVehicle + 3953) = *((BYTE *)pGameVehicle + 3953) & 0xFE | 2;
				
		}

		 CViewportManager + 0x00 = sysArray (CViewport *)
		 CViewport + 0x53C = Viewport ID
		 GET_VIEWPORT_POS_AND_SIZE(unsigned int uiViewportId, float * fPosX, float * fPosY, float * fSizeX, float * fSizeY)
		 (pViewport + 0x10) is always used
		 ((pViewport + 0x10) + 0x298) = float fPosX;
		 (((pViewport + 0x10) + 0x298) + 0x4) = float fPosY;
		 (((pViewport + 0x10) + 0x298) + 0x8) = float fSizeX;
		 (((pViewport + 0x10) + 0x298) + 0xC) = float fSizeY;
		 GET_VIEWPORT_POSITION_OF_COORD(float fCoordX, float fCoordY, float fCoordZ, unsigned int uiViewportId, float * fPosX, float * fPosY)
		 Viewport 1 = CViewportPrimaryOrtho
		 Viewport 2 = CViewportGame
		 Viewport 3 = CViewportRadar
		*/
		if(g_pLocalPlayer)
		{
			if(g_pLocalPlayer->GetVehicleInfos())
			{
				if(g_pVehicleManager)
				{
					CVector3 vecWorldPosition;
					Vector2 vecScreenPosition;

					for(EntityId i = 0; i < MAX_VEHICLES; i++)
					{
						if(g_pVehicleManager->Exists(i))
						{
							CNetworkVehicle * pVehicle = g_pVehicleManager->Get(i);

							if(!pVehicle->IsStreamedIn())
								continue;

							if(!pVehicle->IsOnScreen())
								continue;
					
							pVehicle->GetPosition(vecWorldPosition); 
							CGame::GetScreenPositionFromWorldPosition(vecWorldPosition, vecScreenPosition);

							//if(g_pGraphics)
							//{
							//	CVector3 vecScreen;
							//	g_pGraphics->GetScreenPositionFromWorldPosition(vecWorldPosition, &vecScreen);
						
							//	if( vecScreen.fZ < 0 )
							//		return;
							//}
							//else
							//	return;
							
							int health = pVehicle->GetHealth();
							int model = pVehicle->GetEngineState();
							float petrol = pVehicle->GetPetrolTankHealth();
							CVector3 vecPos; pVehicle->GetPosition(vecPos);
							CVector3 vecRot; pVehicle->GetRotation(vecRot);
							g_pGUI->DrawText(String("VehicleId %d, Enginestate: %d, Health: %d, PetrolTankHealth: %f\nPosition(%.3f,%.3f,%.3f), Rot(%.3f,%.3f,%.3f)", i, model, health, petrol, vecPos.fX,vecPos.fY,vecPos.fZ,vecRot.fX,vecRot.fY,vecRot.fZ), CEGUI::Vector2(vecScreenPosition.X, vecScreenPosition.Y));
						}
					}
				}
			}
		}
		if(g_pNameTags)
			g_pNameTags->Draw();
	}
}
开发者ID:TheFRiChicken,项目名称:ivmultiplayer,代码行数:101,代码来源:Main.cpp

示例2: 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();
	}
}
开发者ID:JamesConway69,项目名称:ivmultiplayer,代码行数:101,代码来源:CClient.cpp


注:本文中的CNetworkVehicle::IsOnScreen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。