예제 #1
0
void		Application::setViewport(std::string const &name)
{
  AScene	*ptr;

  _window->removeAllViewports();

  if (_currentScene) {
    _currentScene->setVisible(false);
    _currentScene->delViewport();
    _currentScene = NULL;
  }

  _mouse->setEventCallback(NULL);
  _keyboard->setEventCallback(NULL);

  ptr = _sceneMap[name];
  ptr->setVisible(true);
  if (!ptr)
    throw graphicException("Failed to load " + name + " scene");

  ptr->createViewport();

  _mouse->setEventCallback(ptr);
  _keyboard->setEventCallback(ptr);

  _currentScene = ptr;
}
예제 #2
0
	void PositionSystem::update(Entity& entity)
	{
		Position*		position;
		AScene*			scene;

		if ((position = dynamic_cast<Position*>(entity[ecs::AComponent::ComponentType::POSITION])) != nullptr && (scene = dynamic_cast<AScene*>(entity[ecs::AComponent::ComponentType::SCENE])) != nullptr)
		{
			// TODO: remove or update entity's position to others?
			Camera*	camera = GraphicUtil::getInstance().getFPSCamera();
			irr::core::vector3df posMe = position->getVectorPosition();
			irr::core::vector3df oriMe = position->getVectorRotation();
			irr::core::vector3df posCam = camera->getPosition().getVectorPosition();
			irr::core::vector3df oriCam = camera->getPosition().getVectorRotation();

			const float dist = 5.f;
			const float radCamY = utility::MathUtility::degreesToRadians(oriCam.Y);

			posCam.Y -= 27.f;
			posCam.X = posCam.X - dist * std::sin(radCamY);
			posCam.Z = posCam.Z - dist * std::cos(radCamY);
			oriMe.Y = oriCam.Y - 85.f;

			position->set(ecs::Position(posCam, oriMe));
			scene->setPosition(ecs::Position(posCam, oriMe));

			ClientCore::getInstance().getNetworkModule()->callRPC(NetworkRPC::PLAYER_MANAGER_SERVER_UPDATE_ENTITY, static_cast<RakNet::NetworkID>(NetworkRPC::ReservedNetworkIds::PlayerManager), entity.getOwner(), &entity);
		}
	}
예제 #3
0
	void PositionSystem::updateScenePosition(Entity& entity)
	{
		Position*	position;
		AScene*		scene;

		if ((position = dynamic_cast<ecs::Position*>(entity[ecs::AComponent::ComponentType::POSITION])) != nullptr && (scene = dynamic_cast<ecs::AScene*>(entity[ecs::AComponent::ComponentType::SCENE])) != nullptr)
		{
			scene->setPosition(*position);
		}
	}
예제 #4
0
void					SceneManager::handleMessage(e_message type, bool activate, std::string const & sceneName)
{
  AScene				*tmp;
  t_iter				it;

  tmp = this->get(sceneName);
  switch (type)
    {
    case MSG_ACTIVE:
      if (sceneName.empty())
	this->setActiveAll(activate);
      else
	{
	  if (tmp)
	    tmp->setActive(activate);
	  else
	    std::cout << "existe pas " << sceneName << std::endl;
	}
      break;
    case MSG_VISIBLE:
      if (sceneName.empty())
	this->setVisibleAll(activate);
      else
	{
	  if (tmp)
	    tmp->setVisible(activate);
	}
      break;
    default:
      if (tmp)
	tmp->receiveMessage(type, activate);
      else if (sceneName.empty())
	{
	  it = this->collection_.begin();
	  while (it != this->collection_.end())
	    {
	      (*it)->receiveMessage(type, activate);
	      ++it;
	    }
	}
    }
}
예제 #5
0
void		Application::initScene()
{
  std::cout << "*******   Initializating Scene    ********" << std::endl;
  AScene	*tmp;

  if (!(tmp = new GUI::Controller(_window)))
    throw graphicException("Failed to create MenuScene");
  _sceneMap[tmp->getName()] = tmp;

  if (!(tmp = new GUIG::Controller(_window)))
    throw graphicException("Failed to create ControllerGUIGScene");
  _sceneMap[tmp->getName()] = tmp;

  for (std::map<std::string, AScene *>::iterator it = _sceneMap.begin(); it != _sceneMap.end(); ++it)
    if ((*it).second != NULL)
    {
      ((*it).second)->init(_root);
      ((*it).second)->setVisible(false);
    }
}