Lales.Charles Posted November 7, 2019 Share Posted November 7, 2019 Hi, Trying to get the possibility to switch from CIGI player to spectator one to move freely the camera. // ===================== in CIGIWorldLogic.h ======================= class CIGIWorldLogic : public WorldLogic { public: int init(); int update(); private: void init_cigi(); IG::CIGI::ConnectorInterface* _cigi = nullptr; PlayerSpectatorPtr _spectator; ///< the Player controlled by keyboard/mouse PlayerPtr _cigi_player; ///< the Player controlled by the CIGI Connector bool _is_cigi_player = true; }; // ===================== in CIGIWorldLogic.cpp ======================= void CIGIWorldLogic::init_cigi() { // get CIGI interface _cigi = (IG::CIGI::ConnectorInterface*)Engine::get()->getPluginData(cigi_connector_index); //deal with players _cigi_player = Game::get()->getPlayer(); // save current CIGI player _spectator = PlayerSpectator::create(); _spectator->setZFar(200000.0f); _spectator->setMinVelocity(50.0f); _spectator->setMaxVelocity(500.0f); } int CIGIWorldLogic::update() { // switch the camera by pressing the SPACE key if (App::get()->clearKeyState(' ') && !Console::get()->getActivity()) { _is_cigi_player = !_is_cigi_player; if (!_is_cigi_player) { Log::message("Spectator player\n"); // switch to manual camera _spectator->setWorldTransform(_cigi_player->getWorldTransform()); // make position and rotation of our camera the same as the CIGI camera _spectator->setPostMaterials(_cigi_player->getPostMaterials()); Game::get()->setPlayer(_spectator->getPlayer()); // set to our camera } else { Log::message("CIGI player\n"); // switch to automatic CIGI camera _cigi_player->setPostMaterials(_spectator->getPostMaterials()); Game::get()->setPlayer(_cigi_player); } } return 1; } The fact is with this code, at initialization camera is right attached to CIGI and moving an entity through CIGI emulator move camera as well. But, once we start to switch with player, CIGI player seems to be detached from entity.. you can move it with HE, camera doesn't follow. What am I missing? Kind regards, Charles Link to comment
cash-metall Posted November 8, 2019 Share Posted November 8, 2019 perhaps, at the time of initialization, the Game::player is not yet installed in cigi player... Have you tried using this ig_manager->setPlayer(0); ? this should set the player back to the CIGI player. Link to comment
Lales.Charles Posted November 8, 2019 Author Share Posted November 8, 2019 Hi, Yes but now _cigi is IG::CIGI::ConnectorInterface* instead of Cigi::CigiClientInterface*.. So, what would be the equiv of CigiClientInterface::setPlayer(int view_id)? Kind regards, Charles Link to comment
cash-metall Posted November 11, 2019 Share Posted November 11, 2019 //================ in init int ig_plugin_index = Engine::get()->findPlugin("IG"); if (ig_plugin_index != -1) ig_manager = (IG::ManagerInterface*)Engine::get()->getPluginData(ig_plugin_index); else Log::error("cant find IG Plugin"); //================ ig_manager->setPlayer(0); CIGIConnector has no method setPlayer. All common methods have been moved to IG plugin Link to comment
Lales.Charles Posted November 12, 2019 Author Share Posted November 12, 2019 Hi, So stupid I am.. yes, working fine thanks! Kind regards, Charles Link to comment
Recommended Posts