void EC_Hydrax::Create() { PROFILE(EC_Hydrax_Create); SAFE_DELETE(impl); if (!framework || framework->IsHeadless()) return; try { if (!ParentScene()) { LogError("EC_Hydrax: no parent scene. Cannot be created."); return; } OgreWorldPtr w = ParentScene()->Subsystem<OgreWorld>(); assert(w); connect(w->Renderer(), SIGNAL(MainCameraChanged(Entity *)), SLOT(OnActiveCameraChanged(Entity *)), Qt::UniqueConnection); Entity *mainCamera = w->Renderer()->MainCamera(); if (!mainCamera) { // Can't create Hydrax just yet, no main camera set (Hydrax needs a valid camera to initialize). // This error is benign, and Hydrax will now postpone its initialization to until a camera is set. // (see OnActiveCameraChanged()). LogDebug("Cannot create EC_Hydrax: No main camera set!"); return; } Ogre::Camera *cam = mainCamera->GetComponent<EC_Camera>()->GetCamera(); impl = new EC_HydraxImpl(); impl->hydrax = new Hydrax::Hydrax(w->OgreSceneManager(), cam, w->Renderer()->MainViewport()); // Using projected grid module by default Hydrax::Module::ProjectedGrid *module = new Hydrax::Module::ProjectedGrid(impl->hydrax, new Hydrax::Noise::Perlin(), Ogre::Plane(Ogre::Vector3::UNIT_Y, Ogre::Vector3::ZERO), Hydrax::MaterialManager::NM_VERTEX); impl->hydrax->setModule(module); impl->module = module; // Load all parameters from config file, but position attribute is always authoritative for the position. RequestConfigAsset(); connect(framework->Frame(), SIGNAL(PostFrameUpdate(float)), SLOT(Update(float)), Qt::UniqueConnection); } catch(const Ogre::Exception &e) { // Currently if we try to create more than one Hydrax component we end up here due to Ogre internal name collision. LogError("Could not create EC_Hydrax: " + std::string(e.what())); } }
void EC_SkyX::Create() { if (framework->IsHeadless()) return; if (!ParentScene()) { LogError("EC_SkyX: Aborting creation, parent scene is null!"); return; } // Return if main camera is not set OgreWorldPtr w = ParentScene()->GetWorld<OgreWorld>(); if (!w || !w->Renderer()) return; if (!w->Renderer()->MainCamera()) { connect(w->Renderer(), SIGNAL(MainCameraChanged(Entity*)), this, SLOT(Create()), Qt::UniqueConnection); return; }