void EC_WaterPlane::CreateWaterPlane() { if (!ViewEnabled()) return; if (entity_) RemoveWaterPlane(); OgreWorldPtr world = world_.lock(); // Create water plane if (world) { Ogre::SceneManager *sceneMgr = world->GetSceneManager(); assert(sceneMgr); if (node_ != 0) { int x = xSize.Get(); int y = ySize.Get(); float uTile = scaleUfactor.Get() * x; /// Default x-size 5000 --> uTile 1.0 float vTile = scaleVfactor.Get() * y; Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().createPlane(Name().toStdString().c_str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::Plane(Ogre::Vector3::UNIT_Y, 0), x, y, xSegments.Get(), ySegments.Get(), true, 1, uTile, vTile, Ogre::Vector3::UNIT_X); entity_ = sceneMgr->createEntity(world->GetUniqueObjectName("EC_WaterPlane_entity"), Name().toStdString().c_str()); entity_->setMaterialName(materialName.Get().toStdString().c_str()); entity_->setCastShadows(false); // Tries to attach entity, if there is not EC_Placeable availible, it will not attach object AttachEntity(); } } }
void EC_SkyBox::CreateSky() { if (!ViewEnabled()) return; if (renderer_.expired()) return; QString currentMaterial = materialRef.Get().ref; Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(currentMaterial.toStdString().c_str()); if (materialPtr.isNull()) { LogError("Could not get SkyBox material : " + currentMaterial.toStdString()); return; } materialPtr->setReceiveShadows(false); try { //RexTypes::Vector3 v = angleAxisAttr.Get(); //Ogre::Quaternion rotation(Ogre::Degree(90.0), Ogre::Vector3(1, 0, 0)); Quaternion o = orientation.Get(); renderer_.lock()->GetSceneManager()->setSkyBox(true, currentMaterial.toStdString().c_str(), distance.Get(), drawFirst.Get(), Ogre::Quaternion(o.w, o.x, o.y, o.z)); } catch(Ogre::Exception& e) { LogError("Could not set SkyBox: " + std::string(e.what())); } }
void EC_WaterPlane::SetParent() { if (!ViewEnabled()) return; CreateWaterPlane(); // Parent entity has set. // Has parent a placeable? EC_Placeable* placeable = dynamic_cast<EC_Placeable*>(FindPlaceable().get()); if (placeable != 0) { // Are we currently attached? if (attached_ ) { // Now there might be that we are attached to OgreRoot not to placeable node. DetachEntity(); AttachEntity(); } } connect(parentEntity,SIGNAL(ComponentAdded(IComponent*, AttributeChange::Type)), SLOT(ComponentAdded(IComponent*, AttributeChange::Type))); connect(parentEntity,SIGNAL(ComponentRemoved(IComponent*, AttributeChange::Type)), SLOT(ComponentRemoved(IComponent*, AttributeChange::Type))); }
void EC_Sky::CreateSky() { if (!ViewEnabled()) return; if (world_.expired()) return; QString currentMaterial = materialRef.Get().ref; Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(currentMaterial.toStdString().c_str()); //Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(framework->Asset()->LookupAssetRefToStorage(materialRef.Get().ref).toStdString().c_str()); if (materialPtr.isNull()) { LogError("Could not get SkyBox material : " + currentMaterial.toStdString()); return; } materialPtr->setReceiveShadows(false); try { world_.lock()->GetSceneManager()->setSkyBox(true, currentMaterial.toStdString().c_str(), distance.Get(), drawFirst.Get(), orientation.Get()); } catch(Ogre::Exception& e) { LogError("Could not set SkyBox: " + std::string(e.what())); } }
void EnvironmentLight::UpdateSignals() { if (!ViewEnabled()) return; Entity* parent = ParentEntity(); if (!parent) return; if (parent->ParentScene()) world_ = parent->ParentScene()->Subsystem<GraphicsWorld>(); if (world_) { Urho3D::Scene* urhoScene = world_->UrhoScene(); node_ = urhoScene->CreateChild("EnvironmentLight"); light_ = node_->CreateComponent<Urho3D::Light>(); light_->SetLightType(Urho3D::LIGHT_DIRECTIONAL); Urho3D::Zone* zone = world_->UrhoZone(); if (zone) zone->SetAmbientColor(ambientColor.Get()); node_->SetDirection(sunDirection.Get()); light_->SetColor(sunColor.Get()); light_->SetBrightness(brightness.Get()); light_->SetCastShadows(sunCastShadows.Get()); // Setup basic shadow cascade for desktops #ifndef ANDROID light_->SetShadowBias(Urho3D::BiasParameters(0.00025f, 0.5f)); // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance light_->SetShadowCascade(Urho3D::CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f)); #endif } }
void AnimationController::PlayReverseAnim(const String &name, const String &fadein, const String &exclusive) { if (!ViewEnabled()) return; if (!name.Length()) { LogWarning("Empty animation name for PlayReverseAnim"); return; } float fadein_ = 0.0f; if (fadein.Length()) fadein_ = ToFloat(fadein); bool exclusive_ = false; if (exclusive.Length()) exclusive_ = ToBool(exclusive); bool success; if (exclusive_) success = EnableAnimation(name, true, fadein_, false); else success = EnableExclusiveAnimation(name, true, fadein_, fadein_, false); if (!success) { StringVector anims = AvailableAnimations(); void (*log)(const String &) = LogDebug; if (anims.Size() > 0) log = LogWarning; log("Failed to play animation \"" + name + "\" in reverse on entity " + ParentEntity()->Name()); log("The entity has " + String(anims.Size()) + " animations available: " + Join(anims, ",")); SetAnimationToEnd(name); SetAnimationSpeed(name, -1.0f); } }
void Sky::UpdateSignals() { Entity* parent = ParentEntity(); if (!parent) return; // If scene is not view-enabled, no further action if (!ViewEnabled()) return; materialAsset_ = new AssetRefListener(); textureRefListListener_ = new AssetRefListListener(framework->Asset()); if (parent->ParentScene()) world_ = parent->ParentScene()->Subsystem<GraphicsWorld>(); if (world_) { materialAsset_->Loaded.Connect(this, &Sky::OnMaterialAssetLoaded); materialAsset_->TransferFailed.Connect(this, &Sky::OnMaterialAssetFailed); textureRefListListener_->Changed.Connect(this, &Sky::OnTextureAssetRefsChanged); textureRefListListener_->Failed.Connect(this, &Sky::OnTextureAssetFailed); textureRefListListener_->Loaded.Connect(this, &Sky::OnTextureAssetLoaded); CreateSkyboxNode(); } }
void EC_SkyBox::DisableSky() { if (!ViewEnabled()) return; if (!renderer_.expired()) renderer_.lock()->GetSceneManager()->setSkyBox(false, ""); }
void EC_HoveringText::Show() { if (!ViewEnabled()) return; if (billboardSet_) billboardSet_->setVisible(true); }
void EC_HoveringText::Hide() { if (!ViewEnabled()) return; if (billboardSet_) billboardSet_->setVisible(false); }
bool EC_HoveringText::IsVisible() const { if (!ViewEnabled()) return false; if (billboardSet_) return billboardSet_->isVisible(); else return false; }
void EC_MediaPlayer::Stop() { // Don't do anything if rendering is not enabled if (!ViewEnabled() || GetFramework()->IsHeadless()) return; if (!componentPrepared_) return; if (!mediaPlayer_ || mediaPlayer_->Media().isEmpty()) return; mediaPlayer_->Stop(); }
void EC_HoveringText::SetPosition(const float3& position) { if (!ViewEnabled()) return; if (billboard_) { billboard_->setPosition(position); billboardSet_->_updateBounds(); // Documentation of Ogre::BillboardSet says the update is never called automatically, so now do it manually. } }
void EC_RttTarget::PrepareRtt() { if (!ViewEnabled()) return; //\todo XXX reconfig via AttributeUpdated when these change int x = width.Get(); int y = height.Get(); // Get the camera ec EC_Camera *ec_camera = ParentEntity()->GetComponent<EC_Camera>().get(); if (!ec_camera) { LogInfo("No camera for rtt."); return; //XXX note: doesn't reschedule, so won't start working if cam added afterwards } ec_camera->GetCamera()->setAspectRatio(Ogre::Real(x) / Ogre::Real(y)); Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName(textureName.Get().toStdString()); if (tex.isNull()) { tex = Ogre::TextureManager::getSingleton().createManual(textureName.Get().toStdString(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, x, y, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET); } Ogre::RenderTexture *render_texture = tex->getBuffer()->getRenderTarget(); if (render_texture) { render_texture->removeAllViewports(); Ogre::Viewport *vp = 0; vp = render_texture->addViewport(ec_camera->GetCamera()); // Exclude ui overlays vp->setOverlaysEnabled(false); // Exclude highlight mesh from rendering vp->setVisibilityMask(0x2); render_texture->update(false); tex->getBuffer()->getRenderTarget()->setAutoUpdated(false); } else LogError("render target texture getting failed."); //create material to show the texture material_name_ = textureName.Get().toStdString() + "_mat"; //renderer_.lock()->GetUniqueObjectName("EC_BillboardWidget_mat"); OgreRenderer::CloneMaterial("HoveringText", material_name_); //would LitTextured be the right thing? XXX \todo Ogre::MaterialManager &material_manager = Ogre::MaterialManager::getSingleton(); Ogre::MaterialPtr material = material_manager.getByName(material_name_); OgreRenderer::SetTextureUnitOnMaterial(material, textureName.Get().toStdString()); }
void EC_MediaPlayer::Pause() { // Don't do anything if rendering is not enabled if (!ViewEnabled() || GetFramework()->IsHeadless()) return; if (!componentPrepared_) return; if (!mediaPlayer_ || mediaPlayer_->Media().isEmpty()) return; if (!mediaPlayer_->GetVideoWidget()) return; QAbstractAnimation::State state = GetMediaState(); if (state == QAbstractAnimation::Running) mediaPlayer_->GetVideoWidget()->Pause(); }
void EC_HoveringText::ShowMessage(const QString &text) { if (!ViewEnabled()) return; if (world_.expired()) return; OgreWorldPtr world = world_.lock(); Ogre::SceneManager *scene = world->OgreSceneManager(); assert(scene); if (!scene) return; Entity* entity = ParentEntity(); assert(entity); if (!entity) return; EC_Placeable *node = entity->GetComponent<EC_Placeable>().get(); if (!node) return; Ogre::SceneNode *sceneNode = node->GetSceneNode(); assert(sceneNode); if (!sceneNode) return; // Create billboard if it doesn't exist. if (!billboardSet_) { billboardSet_ = scene->createBillboardSet(world->GetUniqueObjectName("EC_HoveringText"), 1); assert(billboardSet_); billboardSet_->Ogre::MovableObject::setUserAny(Ogre::Any(static_cast<IComponent *>(this))); billboardSet_->Ogre::Renderable::setUserAny(Ogre::Any(static_cast<IComponent *>(this))); sceneNode->attachObject(billboardSet_); } if (billboardSet_ && !billboard_) { billboard_ = billboardSet_->createBillboard(Ogre::Vector3(0, 0, 0.7f)); SetBillboardSize(width.Get(), height.Get()); SetPosition(position.Get()); } Redraw(); }
void AnimationController::UpdateSignals() { // If scene is not view-enabled, no further action if (!ViewEnabled()) return; Entity* parent = ParentEntity(); if (!parent) return; framework->Frame()->Updated.Connect(this, &AnimationController::Update); parent->ComponentAdded.Connect(this, &AnimationController::OnComponentStructureChanged); parent->ComponentRemoved.Connect(this, &AnimationController::OnComponentStructureChanged); if (parent->ParentScene()) world_ = parent->ParentScene()->Subsystem<GraphicsWorld>(); }
void Sky::AttributesChanged() { if (!ViewEnabled() || !ParentScene()) return; if (materialRef.ValueChanged() && materialAsset_) materialAsset_->HandleAssetRefChange(&materialRef); if (textureRefs.ValueChanged() && textureRefListListener_) textureRefListListener_->HandleChange(textureRefs.Get()); if (distance.ValueChanged()) { if (urhoNode_) urhoNode_->SetScale(distance.Get()); } }
void EC_WaterPlane::SetOrientation() { if ((!node_) || (!ViewEnabled())) return; // Set orientation Quat rot = rotation.Get(); #if OGRE_VERSION_MINOR <= 6 && OGRE_VERSION_MAJOR <= 1 Ogre::Quaternion current_rot = node_->_getDerivedOrientation(); Ogre::Quaternion tmp(rot.w, rot.x, rot.y, rot.z); Ogre::Quaternion rota = current_rot * tmp; node_->setOrientation(rota); #else node_->_setDerivedOrientation(rot); #endif }
void EnvironmentLight::AttributesChanged() { if (!ViewEnabled() || !light_) return; if (sunColor.ValueChanged()) light_->SetColor(sunColor.Get()); if (ambientColor.ValueChanged() && world_) { Urho3D::Zone* zone = world_->UrhoZone(); if (zone) zone->SetAmbientColor(ambientColor.Get()); } if (sunDirection.ValueChanged()) node_->SetDirection(sunDirection.Get()); if (sunCastShadows.ValueChanged()) light_->SetCastShadows(sunCastShadows.Get()); if (brightness.ValueChanged()) light_->SetBrightness(brightness.Get()); }
bool EC_MediaPlayer::SeekMedia(float timeInSeconds) { // Don't do anything if rendering is not enabled if (!ViewEnabled() || GetFramework()->IsHeadless()) return false; if (!componentPrepared_ || !mediaPlayer_ || mediaPlayer_->Media().isEmpty()) return false; if (!mediaPlayer_->GetVideoWidget()) return false; QAbstractAnimation::State state = GetMediaState(); if (state == QAbstractAnimation::Running) { if (timeInSeconds < 0.0) timeInSeconds = 0.0; uint_least64_t seekTimeMsec = timeInSeconds * 1000.0; return mediaPlayer_->GetVideoWidget()->Seek(seekTimeMsec); } return false; }
void EC_RttTarget::SetAutoUpdated(bool val) { if (!ViewEnabled()) return; Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName(textureName.Get().toStdString()); if (tex.isNull()) { LogError("render target texture getting failed."); return; } Ogre::RenderTexture *render_texture = tex->getBuffer()->getRenderTarget(); if (!render_texture) { LogError("Render target texture getting failed."); return; } tex->getBuffer()->getRenderTarget()->setAutoUpdated(val); }
void EC_Sky::OnAttributeUpdated(IAttribute* attribute) { if (!ViewEnabled()) return; if ((attribute->Name() == materialRef.Name() && materialRef.Get().ref != lastMaterial_ ) || (attribute->Name() == distance.Name() && distance.Get() != lastDistance_ ) || (attribute->Name() == drawFirst.Name() && drawFirst.Get() != lastDrawFirst_ )) { DisableSky(); CreateSky(); lastMaterial_ = materialRef.Get().ref; lastDistance_ = distance.Get(); lastDrawFirst_ = drawFirst.Get(); } else if (attribute->Name() == textureRefs.Name()) { AssetReferenceList textures = textureRefs.Get(); // Make sure that the asset ref list type stays intact. textures.type = "Texture"; textureRefs.Set(textures, AttributeChange::Disconnected); // Reallocate the number of texture asset reflisteners. while(textureAssets.size() > (size_t)textures.Size()) textureAssets.pop_back(); while(textureAssets.size() < (size_t)textures.Size()) textureAssets.push_back(boost::shared_ptr<AssetRefListener>(new AssetRefListener)); for(int i = 0; i < textures.Size(); ++i) { connect(textureAssets[i].get(), SIGNAL(Loaded(AssetPtr)), this, SLOT(OnTextureAssetLoaded(AssetPtr)), Qt::UniqueConnection); textureAssets[i]->HandleAssetRefChange(framework->Asset(), textures[i].ref); } //SetTextures(); } }
void EC_SkyBox::OnAttributeUpdated(IAttribute* attribute) { if (!ViewEnabled()) return; std::string name = attribute->GetNameString(); if ((name == materialRef.GetNameString() && materialRef.Get().ref != lastMaterial_ ) || (name == distance.GetNameString() && distance.Get() != lastDistance_ ) || (name == drawFirst.GetNameString() && drawFirst.Get() != lastDrawFirst_ )) { DisableSky(); CreateSky(); lastMaterial_ = materialRef.Get().ref; lastDistance_ = distance.Get(); lastDrawFirst_ = drawFirst.Get(); } else if (name == textureRefs.GetNameString() ) { // What texture has changed? SetTextures(); } }
void EC_SkyBox::SetTextures() { if (!ViewEnabled()) return; AssetReferenceList lst = textureRefs.Get(); std::vector<std::string> texture_names; texture_names.reserve(6); for(int i = 0; i < lst.Size() && i <= 6; ++i) texture_names.push_back(lst[i].ref.toStdString()); Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(materialRef.Get().ref.toStdString().c_str()); if (!materialPtr.isNull() && texture_names.size() == 6) materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setCubicTextureName(&texture_names[0], false); //skyMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureScale(1, -1); else if(!materialPtr.isNull() ) for(int i = 0; i < texture_names.size(); ++i) materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setFrameTextureName(Ogre::String(texture_names[i].c_str()), i); DisableSky(); CreateSky(); }
void EC_HoveringText::Destroy() { if (!ViewEnabled()) return; if (!world_.expired()) { Ogre::SceneManager* sceneMgr = world_.lock()->OgreSceneManager(); try{ Ogre::MaterialManager::getSingleton().remove(materialName_); } catch(...) { } try{ if (billboardSet_ && billboard_) billboardSet_->removeBillboard(billboard_); } catch(...) { } try{ if (billboardSet_) { sceneMgr->destroyBillboardSet(billboardSet_); } } catch(...) { } } billboard_ = 0; billboardSet_ = 0; textureName_ = ""; materialName_ = ""; }
void EC_MediaPlayer::OnFrameUpdate(QImage frame) { // Don't do anything if rendering is not enabled if (!ViewEnabled() || GetFramework()->IsHeadless()) return; if (!componentPrepared_) return; if (!getenabled()) return; // Get needed components, something is fatally wrong if these are not present but componentPrepared_ is true. EC_Mesh *mesh = GetMeshComponent(); EC_WidgetCanvas *sceneCanvas = GetSceneCanvasComponent(); if (!mesh || !sceneCanvas) { // In the case someone destroyed EC_WidgetCanvas or EC_Mesh from our entity // lets stop our running timer (if its running), so we don't unnecessarily poll here. componentPrepared_ = false; return; } // Validate submesh index from EC_Mesh uint submeshIndex = (uint)getrenderSubmeshIndex(); if (submeshIndex >= mesh->GetNumSubMeshes()) { /// \note ResetSubmeshIndex() is called with a small delay here, or the ec editor UI wont react to it. Resetting the index back to 0 will call Render() again. LogWarning("Render submesh index " + QString::number(submeshIndex).toStdString() + " is illegal, restoring default value."); QTimer::singleShot(1, this, SLOT(ResetSubmeshIndex())); return; } // Set submesh to EC_WidgetCanvas if different from current if (!sceneCanvas->GetSubMeshes().contains(submeshIndex)) sceneCanvas->SetSubmesh(submeshIndex); sceneCanvas->Update(frame); }
void EC_WaterPlane::SetPosition() { if ((!node_) || (!ViewEnabled())) return; float3 vec = position.Get(); //node_->setPosition(vec.x, vec.y, vec.z); #if OGRE_VERSION_MINOR <= 6 && OGRE_VERSION_MAJOR <= 1 //Ogre::Vector3 current_pos = node_->_getDerivedPosition(); Ogre::Vector3 tmp(vec.x,vec.y,vec.z); if (!vec.IsFinite()) return; node_->setPosition(tmp); #else Ogre::Vector3 pos(vec.x, vec.y, vec.z); if (!vec.IsFinite()) return; //node_->_setDerivedPosition(pos); node_->setPosition(pos); #endif }
void EC_HoveringText::Redraw() { if (!ViewEnabled()) return; if (world_.expired() || !billboardSet_ || !billboard_ || materialName_.empty()) return; bool textEmpty = text.Get().isEmpty(); billboardSet_->setVisible(!textEmpty); if (textEmpty) return; try { if (texture_.get() == 0) { textureName_ = framework->Asset()->GenerateUniqueAssetName("tex", "EC_HoveringText_").toStdString(); QString name(textureName_.c_str()); texture_ = dynamic_pointer_cast<TextureAsset>(framework->Asset()->CreateNewAsset("Texture", name)); assert(texture_); if (texture_ == 0) { LogError("Failed to create texture " + textureName_); return; } } QBrush brush(backgroundColor.Get()); if (usingGrad.Get()) { QRect rect(0,0,texWidth.Get(), texHeight.Get()); bg_grad_.setStart(QPointF(0,rect.top())); bg_grad_.setFinalStop(QPointF(0,rect.bottom())); brush = QBrush(bg_grad_); } QColor borderCol; Color col = borderColor.Get(); borderCol.setRgbF(col.r, col.g, col.b, col.a); QPen borderPen; borderPen.setColor(borderCol); borderPen.setWidthF(borderThickness.Get()); float2 corners = cornerRadius.Get(); texture_->SetContentsDrawText(texWidth.Get(), texHeight.Get(), text.Get(), textColor_, font_, brush, borderPen, Qt::AlignCenter | Qt::TextWordWrap, enableMipmapping.Get(), false, corners.x, corners.y); } catch(Ogre::Exception &e) { LogError("Failed to create texture " + textureName_ + ": " + std::string(e.what())); return; } // Set new texture for the material assert(!materialName_.empty()); if (!materialName_.empty()) { Ogre::MaterialManager &mgr = Ogre::MaterialManager::getSingleton(); Ogre::MaterialPtr material = mgr.getByName(materialName_); assert(material.get()); OgreRenderer::SetTextureUnitOnMaterial(material, textureName_); } }
EC_MediaPlayer::EC_MediaPlayer(Scene* scene) : IComponent(scene), mediaPlayer_(0), componentPrepared_(false), pendingMediaDownload_(false), sourceRef(this, "Media Source", AssetReference("", "")), renderSubmeshIndex(this, "Render Submesh", 0), interactive(this, "Interactive", false), illuminating(this, "Illuminating", true), streamingAllowed(this, "Streaming Allowed", true), enabled(this, "Enabled", true) { if (!ViewEnabled() || GetFramework()->IsHeadless()) return; // Set metadata min/max/step static AttributeMetadata submeshMetaData; static bool metadataInitialized = false; if (!metadataInitialized) { submeshMetaData.minimum = "0"; submeshMetaData.step = "1"; metadataInitialized = true; } renderSubmeshIndex.SetMetadata(&submeshMetaData); // Init our internal media player mediaPlayer_ = new VlcMediaPlayer(); connect(mediaPlayer_, SIGNAL(FrameUpdate(QImage)), SLOT(OnFrameUpdate(QImage)), Qt::UniqueConnection); // Connect signals from IComponent connect(this, SIGNAL(ParentEntitySet()), SLOT(PrepareComponent()), Qt::UniqueConnection); // Connect window size changes to update rendering as the ogre textures go black. if (GetFramework()->Ui()->MainWindow()) connect(GetFramework()->Ui()->MainWindow(), SIGNAL(WindowResizeEvent(int,int)), SLOT(RenderWindowResized()), Qt::UniqueConnection); resizeRenderTimer_ = new QTimer(this); resizeRenderTimer_->setSingleShot(true); connect(resizeRenderTimer_, SIGNAL(timeout()), mediaPlayer_, SLOT(ForceUpdateImage()), Qt::UniqueConnection); // Prepare scene interactions SceneInteract *sceneInteract = GetFramework()->GetModule<SceneInteract>(); if (sceneInteract) { connect(sceneInteract, SIGNAL(EntityClicked(Entity*, Qt::MouseButton, RaycastResult*)), SLOT(EntityClicked(Entity*, Qt::MouseButton, RaycastResult*))); } // Prepare media downloader mediaDownloader_ = new AssetRefListener(); connect(mediaDownloader_, SIGNAL(Loaded(AssetPtr)), SLOT(OnMediaLoaded(AssetPtr))); connect(mediaDownloader_, SIGNAL(TransferFailed(IAssetTransfer*, QString)), SLOT(OnMediaFailed(IAssetTransfer*, QString))); // Construct loading image downloadingLogo_ = QImage(500, 300, QImage::Format_ARGB32); downloadingLogo_.fill(Qt::black); QPixmap bufferingIcon(":/images/buffering.png"); QPoint centerPos = downloadingLogo_.rect().center(); QRect target(centerPos.x() - (bufferingIcon.width()/2), centerPos.y() - (bufferingIcon.height()/2), bufferingIcon.width(), bufferingIcon.height()); QPainter p(&downloadingLogo_); p.setPen(Qt::white); p.drawPixmap(target, bufferingIcon, bufferingIcon.rect()); p.drawText(5, 12, "Downloading media..."); p.end(); }