本文整理汇总了C++中EntityManager::getFirstEntityByComponentType方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::getFirstEntityByComponentType方法的具体用法?C++ EntityManager::getFirstEntityByComponentType怎么用?C++ EntityManager::getFirstEntityByComponentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::getFirstEntityByComponentType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calcCameraPlanes
void ParticleRenderSystem::calcCameraPlanes()
{
EntityManager* entitymanager = m_world->getEntityManager();
Entity* cam = entitymanager->getFirstEntityByComponentType(ComponentType::TAG_MainCamera);
CameraInfo* info = static_cast<CameraInfo*>(cam->getComponent(ComponentType::CameraInfo));
Transform* transform = static_cast<Transform*>(
cam->getComponent( ComponentType::ComponentTypeIdx::Transform ) );
AglVector3 position = transform->getTranslation();
AglQuaternion rotation = transform->getRotation();
AglVector3 lookTarget = position+transform->getMatrix().GetForward();
AglVector3 up = transform->getMatrix().GetUp();
AglMatrix view = AglMatrix::createViewMatrix(position,
lookTarget,
up);
AglMatrix viewProj = view * info->m_projMat;
m_cameraPlanes[0] = viewProj.getColumn(3)+viewProj.getColumn(0); //LEFT
m_cameraPlanes[1] = viewProj.getColumn(3)-viewProj.getColumn(0); //RIGHT
m_cameraPlanes[2] = viewProj.getColumn(3)-viewProj.getColumn(1); //TOP
m_cameraPlanes[3] = viewProj.getColumn(3)+viewProj.getColumn(1); //BOTTOM
m_cameraPlanes[4] = viewProj.getColumn(2); //NEAR
m_cameraPlanes[5] = viewProj.getColumn(3)-viewProj.getColumn(2); //FAR
for (unsigned int i = 0; i < 6; i++)
{
float l = sqrt(m_cameraPlanes[i].x * m_cameraPlanes[i].x +
m_cameraPlanes[i].y * m_cameraPlanes[i].y +
m_cameraPlanes[i].z * m_cameraPlanes[i].z);
m_cameraPlanes[i].x /= l;
m_cameraPlanes[i].y /= l;
m_cameraPlanes[i].z /= l;
m_cameraPlanes[i].w /= l;
}
}
示例2: process
void HudSystem::process()
{
ClientStateSystem* stateSystem = static_cast<ClientStateSystem*>(m_world->
getSystem(SystemType::ClientStateSystem));
if(stateSystem->getStateDelta(GameStates::INGAME) == EnumGameDelta::ENTEREDTHISFRAME)
{
m_backend->showDocument(m_hudIndex);
m_hudVisible = true;
setHUDData(SCORE,"-1");
setHUDData(TIME,"00:00");
setHUDData(SERVERNAME, m_client->getServerName().c_str());
GraphicsBackendSystem* gfx = static_cast<GraphicsBackendSystem*>(m_world->getSystem(SystemType::GraphicsBackendSystem));
m_screenSize = gfx->getWindowSize();
float screenRatio = gfx->getAspectRatio();
/*float wingRatio = 228.0f / 527.0f;
AglVector2 wingsize = AglVector2(1.0f, 1.0f*gfx->getAspectRatio() * wingRatio) * screenRatio;
float timerRatio = 109.0f / 953.0f;
AglVector2 timerSize = AglVector2(0.4f, 0.4f*gfx->getAspectRatio() * timerRatio) * screenRatio;
*/
float constRatio = 65.0f / 1025.0f;
AglVector2 constSize = AglVector2(0.6f, 0.6f*gfx->getAspectRatio() * constRatio) * screenRatio;
/*m_leftWing = createSprite(AglVector3(-1.0f+wingsize.x*0.5f, 1.0f-wingsize.y*0.5f, 0.0f), "leftwing_HUD.png", wingsize);
m_rightWing = createSprite(AglVector3(1.0f-wingsize.x*0.5f, 1.0f-wingsize.y*0.5f, 0.0f), "rightwing_HUD.png", wingsize);
m_timerMonitor = createSprite(AglVector3(0.0f, 1.0f-timerSize.y, 0.0f), "timer_HUD.png", timerSize);*/
m_constructionMode = createConstructionSprite(
AglVector3(0.0f, -1.0f-constSize.y + 0.5f, 0.0f),
"construction_mode_label.png", constSize);
}
else if (stateSystem->getCurrentState() == GameStates::INGAME)
{
GraphicsBackendSystem* gfx = static_cast<GraphicsBackendSystem*>
(m_world->getSystem(SystemType::GraphicsBackendSystem));
AglVector2 newSize = gfx->getWindowSize();
if (newSize.x != m_screenSize.x || newSize.y != m_screenSize.y)
{
m_screenSize = newSize;
float screenRatio = 1280 / m_screenSize.x;
/*float wingRatio = 228.0f / 527.0f;
AglVector2 wingsize = AglVector2(0.3f, 0.3f*gfx->getAspectRatio() * wingRatio) * screenRatio;
float timerRatio = 109.0f / 953.0f;
AglVector2 timerSize = AglVector2(0.4f, 0.4f*gfx->getAspectRatio() * timerRatio) * screenRatio;
*/
float constRatio = 65.0f / 1025.0f;
AglVector2 constSize = AglVector2(0.6f, 0.6f*gfx->getAspectRatio() * constRatio) * screenRatio;
/*
reinitSprite(m_leftWing, AglVector3(-1.0f+wingsize.x*0.5f, 1.0f-wingsize.y*0.5f, 0.0f), wingsize);
reinitSprite(m_rightWing, AglVector3(1.0f-wingsize.x*0.5f, 1.0f-wingsize.y*0.5f, 0.0f), wingsize);
reinitSprite(m_timerMonitor, AglVector3(0.0f, 1.0f-timerSize.y, 0.0f), timerSize);*/
reinitSprite(m_constructionMode, AglVector3(0.0f, -1.0f-constSize.y + 0.5f, 0.0f), constSize);
}
EntityManager* entitymanager = m_world->getEntityManager();
Entity* ship = entitymanager->getFirstEntityByComponentType(ComponentType::TAG_MyShip);
ShipEditMode_TAG* editMode = static_cast<ShipEditMode_TAG*>(ship->getComponent(ComponentType::TAG_ShipEditMode));
if (editMode)
{
ParticleSystemsComponent* ps = static_cast<ParticleSystemsComponent*>(
m_constructionMode->getComponent(ComponentType::ParticleSystemsComponent));
if(ps)
{
AglParticleSystem* particleSystem = ps->getParticleSystemPtr(0);
if(particleSystem)
{
AglParticleSystemHeader* particleHeader = particleSystem->getHeaderPtr();
if(particleHeader)
{
particleHeader->color = AglVector4(1, 1, 1, 1);
}
}
}
}
else
{
ParticleSystemsComponent* ps = static_cast<ParticleSystemsComponent*>(
m_constructionMode->getComponent(ComponentType::ParticleSystemsComponent));
AglParticleSystem* partSystem = ps->getParticleSystemPtr(0);
if(partSystem)
{
AglParticleSystemHeader* header = partSystem->getHeaderPtr();
if(header)
{
header->color = AglVector4(0, 0, 0, 0);
}
}
//.........这里部分代码省略.........