本文整理汇总了C++中TransformComponent::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformComponent::getPosition方法的具体用法?C++ TransformComponent::getPosition怎么用?C++ TransformComponent::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransformComponent
的用法示例。
在下文中一共展示了TransformComponent::getPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//Busca enemigos
void CameraController3rd::lookForEnemies()
{
std::map<Entity*,Component*>* entitiesWithED = EntityManager::get().getAllEntitiesPosessingComponent<EnemyDataComponent>();
if(!entitiesWithED) return;
float distance = FLT_MAX;
float min_distance = distance;
std::map<Entity*,Component*>::iterator iter;
for (iter = entitiesWithED->begin(); iter != entitiesWithED->end(); ++iter)
{
if( iter->second->enabled )
{
Entity* entity = iter->first;
TransformComponent* transformEnemy = EntityManager::get().getComponent<TransformComponent>(entity);
float angle = _front.angle(transformEnemy->getPosition() - _camera->getPosition());
//dbg("angle: %f\n", angle);
if( angle < 1.0f )
{
distance = transformEnemy->getPosition().distance2(_camera->getTarget());
//dbg("distance: %f\n", distance);
if(distance < 30.0f && distance < min_distance)
{
_lockedEntity = entity;
min_distance = distance;
}
}
}
}
}
示例2: draw
void RenderSystem::draw(GameObject* gameObject)
{
RenderComponent* render = gameObject->getComponent<RenderComponent>();
if (render != nullptr)
{
RectangleShape shape = *render->getDrawable();
TransformComponent* transform = gameObject->getComponent<TransformComponent>();
if (transform != nullptr)
{
shape.setPosition(transform->getPosition());
}
else
{
BoardComponent* boardComp = gameObject->getComponent<BoardComponent>();
if (boardComp != nullptr && mBoard != nullptr)
{
Vector2i boardPos = boardComp->getPosition();
shape.setPosition(mBoard->getTilePosition(boardPos.x, boardPos.y));
}
}
mWindow->draw(shape);
}
}
示例3:
math::Vec3 TransformComponent::getPosition()
{
// Go trough parents and add transform from those to this.
// Current entity
Entity *ent = (Entity*)getParent();
if (ent == NULL)
return position;
// Get current entities parent
Entity *parent = ent->getParentEntity();
if (parent == NULL)
return position;
TransformComponent *parentTransform = parent->findComponent<TransformComponent>();
if (parentTransform == NULL)
return position;
//TODO: Add parenting to the rotation
return parentTransform->getPosition() + position;
}
示例4:
//ACCIONES
int CineSeq01::cineCam1()
{
//Poner el alpha del logo al maximo directamente
if(!CameraSystem::get().getBSAlpha() && !_logoFirstEnabled)
{
CameraSystem::get().enableLogo();
_logoFirstEnabled = true;
}
//Esperar a que se pulse enter o espacio
if((CIOStatus::instance()->becomesPressed(CIOStatus::instance()->TELEPORT) || CIOStatus::instance()->becomesPressed_key(13)) && !_started)
{
SoundSystem::get().playStream("intro", "data/music/intro.mp3", "intro", 0, 0.5f, false);
CameraSystem::get().setCinePaused(false);
TransformComponent *playerT = EntityManager::get().getComponent<TransformComponent>(World::instance()->getPlayer());
//Se crea una sombra magica donde nace el player
Entity * e = EntityFactory::get().createMagicShadow(D3DXVECTOR3(playerT->getPosition()),D3DXVECTOR3(0,1,0),0);
ShadowComponent * tShadowComp = EntityManager::get().getComponent<ShadowComponent>(e);
tShadowComp->radius = 2.5f;
tShadowComp->stopGrowing();
_started = true;
CameraSystem::get().disableLogo();
}
if(!_started) return STAY;
//Nos mantenemos aqui mientras dure la cine 1
if(CameraSystem::get().getActiveCamId() == 1) return STAY;
//Cuando llegue al final mandamos nacer al player
World::instance()->getPlayer()->enabled = true; //player activado
((AUTPlayer*)(EntityManager::get().getComponent<AutomatComponent>(World::instance()->getPlayer())->getAutomat()))->prepareForRebirth();
//Efecto de particulas donde nace el player, cuando acaba el 1er travelling
TransformComponent *playerT = EntityManager::get().getComponent<TransformComponent>(World::instance()->getPlayer());
_shadowEffectBirth = EntityFactory::get().createParticleEffect(D3DXVECTOR3(playerT->getPosition()) - D3DXVECTOR3(0,0.6f,0),ParticleEffectComponent::PARTICLE_EFFECT::SHADOW_STATIC);
return LEAVE;
}
示例5: updateView
void Camera::updateView(void){
if(isFollowing_){
TransformComponent* transformation = followee_->getComponent<TransformComponent>();
glm::fquat rotation = transformation->getRotation() * rotation_;
// glm::vec3 pos = pos_ + transformation->getPosition();
view_matrix_ = glm::translate(glm::mat4(1.0), transformation->getPosition()) * glm::mat4_cast(rotation) * glm::translate(glm::mat4(1.0), pos_);
}
else if(isMimicking_){
glm::vec3 pos = pos_ + followee_->getComponent<TransformComponent>()->getPosition();
view_matrix_ = glm::translate(glm::mat4(1.0), pos) * glm::mat4_cast(rotation_);
}
else{
view_matrix_ = glm::translate(glm::mat4(1.0), pos_) * glm::mat4_cast(rotation_);
}
view_matrix_ = glm::inverse(view_matrix_);
}
示例6: fall
//ACTIONS--------------------------------------------------------------------------------------------------------------------------------------------
int BTCommon::fall()
{
//Rotar hacia el player el doble de rapido de lo normal (susto)
const btVector3& playerPos = EntityManager::get().getComponent<TransformComponent>(World::instance()->getPlayer())->getPosition();
float angle;
_eD->_transformC->approximateFront_p(playerPos, _eD->_rotateVel*_eD->_delta*2.0f, angle);
if(angle < 0.01f)
{
_animation_component->clearCycles(1.5f);
_animation_component->executeAction("fall", 0.5f, 0.5f);
_animation_component->blendCycle("panic", 1.0f, 1.5f);
TransformComponent * tran = EntityManager::get().getComponent<TransformComponent>(_entity);
SoundSystem::get().playSFX3D( "panic", "data/sfx/panico.wav", "panic", tran->getPosition(), btVector3(0,0,0), false, 1.0f, 1.0f );
_panicClock.setTarget(10.0f);
_eD->setAttentionDegree(attentionDegrees::PANIC);
return LEAVE; //Cuando haya animacion anyadir restriccion de que la accion de caer hay acabado
}
else return STAY;
}
示例7: processEntity
void MovementSystem::processEntity( Entity& e )
{
TurnFactorComponent* turnFactorComponent = turnFactorComponentMapper.get(e);
TransformComponent* transformComponent = transformComponentMapper.get(e);
float dt = world->getDelta();
if (turnFactorComponent != NULL)
{
float previousAngle = turnFactorComponent->getAngleInDegrees();
turnFactorComponent->setAngleInDegrees(previousAngle + dt * 100.0f);
}
Vector2 previousPosition = transformComponent->getPosition();
Vector2 position = previousPosition.add(Vector2(dt*60.0f, dt*20.0f));
if (position.getX() > 1024) position.setX(512);
if (position.getX() < 0) position.setX(512);
if (position.getY() < 0) position.setY(384);
if (position.getY() > 768) position.setY(384);
transformComponent->setPosition(position);
SpatialComponent* spatialComponent = spatialComponentMapper.get(e);
if ((spatialComponent->needToRemoveTurnFactor) == true)
{
e.removeComponent<TurnFactorComponent>();
spatialComponent->needToRemoveTurnFactor = false;
spatialComponent->isTurnFactorRemoved = true;
spatialComponent->needToSetToAddTurnFactor = true;
}
if ((spatialComponent->needToAddTurnFactor) == true)
{
e.addComponent(new TurnFactorComponent());
spatialComponent->needToAddTurnFactor = false;
spatialComponent->isTurnFactorSetToRemove = false;
}
}
示例8: EventListener
void FieldSystem::EventListener(IEvent* eventData)
{
if(MousePositionEvent* event = dynamic_cast<MousePositionEvent*>(eventData))
{
glm::ivec2 mousePos = event->getMousePosition();
m_pickedField = nullptr;
//Simple mouse picking for field
for(std::map<unsigned int, BaseComponent*>::iterator it = m_fieldComponents->begin(); it != m_fieldComponents->end(); ++it)
{
FieldComponent* fieldComp = static_cast<FieldComponent*>(it->second);
unsigned int entityId = fieldComp->getEntityId();
TransformComponent* transformComp = static_cast<TransformComponent*>((*m_transformComponents)[entityId]);
SpriteComponent* spriteComp = static_cast<SpriteComponent*>((*m_spriteComponents)[entityId]);
glm::vec4 bounds = glm::vec4(transformComp->getPosition().x * transformComp->getScale().x, transformComp->getPosition().y * transformComp->getScale().y, spriteComp->getTextureBounds().z * transformComp->getScale().x, spriteComp->getTextureBounds().w * transformComp->getScale().y);
bool isPickedField = m_pickedField == nullptr && fieldComp->getIsPassable() && mousePos.x > bounds.x && mousePos.x < bounds.x + bounds.z && mousePos.y > bounds.y && mousePos.y < bounds.y + bounds.w;
//Either showing start or goal to set
switch(m_gameMode)
{
case MODE_CHOOSE_START:
if(isPickedField)
{
fieldComp->setIsStart(true);
m_pickedField = fieldComp;
}
else
{
fieldComp->setIsStart(false);
}
break;
case MODE_CHOOSE_GOAL:
if(isPickedField)
{
fieldComp->setIsGoal(true);
m_pickedField = fieldComp;
}
else
{
fieldComp->setIsGoal(false);
}
break;
case MODE_DONE:
if (isPickedField)
{
m_pickedField = fieldComp;
}
break;
default:
break;
}
}
RecalculateColors();
}
else if(MouseClickEvent* event = dynamic_cast<MouseClickEvent*>(eventData))
{
if (event->getButton() == sf::Mouse::Button::Left)
{
//Take enemy step/reculculate path or set start/goal
if (m_gameMode == MODE_DONE)
{
m_eventManager->FireEvent<StepEvent>(new StepEvent());
UpdatePheromones();
RecalculateColors();
}
else
{
if (m_pickedField != nullptr)
{
switch (m_gameMode)
{
case MODE_CHOOSE_START:
m_eventManager->FireEvent<StartSetEvent>(new StartSetEvent(m_pickedField));
std::cout << "Start set" << std::endl;
m_eventManager->FireEvent<ShowMessageEvent>(new ShowMessageEvent("Please choose a goal point."));
m_gameMode = MODE_CHOOSE_GOAL;
break;
case MODE_CHOOSE_GOAL:
m_eventManager->FireEvent<GoalSetEvent>(new GoalSetEvent(m_pickedField));
std::cout << "Goal set" << std::endl;
m_eventManager->FireEvent<ShowMessageEvent>(new ShowMessageEvent("Press mouse button for simulation step or 'A' for automatic mode."));
m_gameMode = MODE_DONE;
break;
default:
break;
}
}
}
}
else if (event->getButton() == sf::Mouse::Button::Right)
{
if (m_pickedField != nullptr)
{
m_pickedField->setIsPassable(!m_pickedField->getIsPassable());
m_pickedField->setCurrentPheromoneStrength(0);
m_pickedField->setNewPheromoneStrength(0);
RecalculateColors();
//.........这里部分代码省略.........