Пример #1
0
void EC_ChatBubble::Refresh()
{
    if (renderer_.expired() || !billboardSet_ || !billboard_)
        return;

    // If no messages in the log, hide the chat bubble.
    if (messages_.isEmpty())
    {
        billboardSet_->setVisible(false);
        return;
    }
    else
        billboardSet_->setVisible(true);

    // Get image buffer and texture
    QImage buffer = GetChatBubblePixmap().toImage();
    Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(texture_name_);
    if (buffer.isNull() || texture.isNull())
        return;

    // Check texture size
    if ((int)texture->getWidth() != buffer.width() || (int)texture->getHeight() != buffer.height())
    {
        texture->freeInternalResources();
        texture->setWidth(buffer.width());
        texture->setHeight(buffer.height());
        texture->createInternalResources();
    }

    // Update texture buffer
    Ogre::Box update_box(0,0, buffer.width(), buffer.height());
    Ogre::PixelBox pixel_box(update_box, Ogre::PF_A8R8G8B8, (void*)buffer.bits());
    if (!texture->getBuffer().isNull())
        texture->getBuffer()->blitFromMemory(pixel_box, update_box);
}
Пример #2
0
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());
}
Пример #3
0
 void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height)
 {
     Ogre::HardwarePixelBufferSharedPtr texBuf = m_renderTexture->getBuffer();
     texBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD);
     memcpy(texBuf->getCurrentLock().data, buffer, width*height*4);
     texBuf->unlock();
 }
Пример #4
0
bool ShadowUpdateTask::executeTaskInMainThread()
{
	if (!mPageGeometries.empty()) {
		auto pageGeometry = mPageGeometries.back();
		mPageGeometries.pop_back();
		auto& page = pageGeometry->getPage();
		if (page.getSurface()) {
			auto shadow = page.getSurface()->getShadow();
			if (shadow) {
				auto& shadowTextureName = shadow->getShadowTextureName();
				if (!shadowTextureName.empty()) {
					Ogre::TexturePtr texture = Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(shadowTextureName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
					if (texture) {
						Ogre::Image ogreImage;
						shadow->loadIntoImage(ogreImage);

						texture->loadImage(ogreImage);

						//blit the whole image to the hardware buffer
						Ogre::PixelBox sourceBox(ogreImage.getPixelBox());
						//blit for each mipmap
						for (unsigned int i = 0; i <= texture->getNumMipmaps(); ++i) {
							Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(texture->getBuffer(0, i));
							hardwareBuffer->blitFromMemory(sourceBox);
						}
					}
				}
			}
		}
	}
	return mPageGeometries.empty();
}
Пример #5
0
void OgreWidget::createRttCamera(Ogre::Camera** camera, Ogre::RenderTarget** renderTarget, Ogre::SceneNode ** sceneNode, const QString name, const QSize size)
{
    Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual(
                QString(name+"_texture").toStdString(),
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME/*"general"*/,
                Ogre::TEX_TYPE_2D,
                size.width(),
                size.height(),
                32,
                0,
                Ogre::PF_R8G8B8A8,
                Ogre::TU_RENDERTARGET);

    *renderTarget = tex->getBuffer()->getRenderTarget();
    tex.setNull();

    *camera = mSceneManager->createCamera(QString(name+"_camera").toStdString());
    Ogre::Viewport* viewPort = (*renderTarget)->addViewport(*camera);
    viewPort->setBackgroundColour(Ogre::ColourValue::Red);

    // From: http://www.ogre3d.org/docs/api/html/classOgre_1_1Camera.html:
    // Note that a Camera can be attached to a SceneNode, using the method SceneNode::attachObject.
    // If this is done the Camera will combine it's own position/orientation settings with it's parent
    // SceneNode. This is useful for implementing more complex Camera / object relationships i.e.
    // having a camera attached to a world object.
    //
    // Cameras are attached to the camera-scenenode, which is attached to the vehicle-scenenode
    Ogre::Entity *cameraEntity = mSceneManager->createEntity(QString(name + "_entity").toStdString(), "camera.mesh");
    *sceneNode = mSceneManager->getSceneNode("vehicleNode")->createChildSceneNode(QString(name + "_node").toStdString());
    (*sceneNode)->attachObject(cameraEntity);
    (*sceneNode)->attachObject(*camera);
}
Пример #6
0
    void MiniMapMaker::init(void)
    {
        // 创建纹理
        Ogre::TexturePtr pTexture = Ogre::TextureManager::getSingleton().createManual(
            "RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
            Ogre::TEX_TYPE_2D,
            mTexWidth, mTexHeight, 1, 0, mOutPutFormat,
            Ogre::TU_RENDERTARGET, 0);

        Ogre::HardwarePixelBufferSharedPtr pBuffer = pTexture->getBuffer(0, 0);

        mRenderTexture = pBuffer->getRenderTarget(0);
        {
            mCamera = mManipulator->getSceneManager()->createCamera("RttCam");

            // 设置摄像机的基本属性
            mCamera->setAspectRatio(1);
            mCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
            mCamera->setFOVy(Ogre::Degree(90));            

            _setCameraAttribute();

            Ogre::Viewport *v = mRenderTexture->addViewport( mCamera );
            v->setClearEveryFrame( true );
            v->setBackgroundColour( Ogre::ColourValue::Black );   
            v->setOverlaysEnabled(false);
            v->setSkiesEnabled(false);
            v->setShadowsEnabled(true);
        }
    }
Пример #7
0
Ogre::TexturePtr Simple::updateShadowTexture(Ogre::MaterialPtr material, const TerrainPageShadow* terrainPageShadow)
{
	//we need an unique name for our alpha texture
	std::stringstream shadowTextureNameSS;
	shadowTextureNameSS << material->getName() << "_shadow";
	const Ogre::String shadowTextureName(shadowTextureNameSS.str());

	Ogre::TexturePtr texture = static_cast<Ogre::TexturePtr> (Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(shadowTextureName));
	if (texture.isNull()) {
		texture = Ogre::Root::getSingletonPtr()->getTextureManager()->createManual(shadowTextureName, "General", Ogre::TEX_TYPE_2D, mPage.getAlphaTextureSize(), mPage.getAlphaTextureSize(), 1, Ogre::PF_L8, Ogre::TU_DYNAMIC_WRITE_ONLY);
	}

	Ogre::Image ogreImage;
	terrainPageShadow->loadIntoImage(ogreImage);

	texture->loadImage(ogreImage);

	//blit the whole image to the hardware buffer
	Ogre::PixelBox sourceBox(ogreImage.getPixelBox());
	//blit for each mipmap
	for (unsigned int i = 0; i <= texture->getNumMipmaps(); ++i) {
		Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(texture->getBuffer(0, i));
		hardwareBuffer->blitFromMemory(sourceBox);
	}

	return texture;
}
Пример #8
0
void SimpleRenderContext::setTexture(Ogre::TexturePtr texture)
{
    if (texture != mTexture) {
        if (mRenderTexture) {
            mRenderTexture->removeAllViewports();
        }
        mTexture = texture;
        mRenderTexture = texture->getBuffer()->getRenderTarget();
        mRenderTexture->removeAllViewports();

        mRenderTexture->setAutoUpdated(false);
        //initially deactivate it until setActive(true) is called
        mRenderTexture->setActive(false);

        S_LOG_VERBOSE("Adding camera.");
        mViewPort = mRenderTexture->addViewport(mCamera);
        mViewPort->setOverlaysEnabled(false);
        mViewPort->setShadowsEnabled(false);
        //make sure the camera renders into this new texture
        //this should preferrably be a transparent background, so that CEGUI could itself decide what to show behind it, but alas I couldn't get it to work, thus black
        mViewPort->setBackgroundColour(mBackgroundColour);
        //	mViewPort->setBackgroundColour(Ogre::ColourValue::ZERO);
        //don't show the CEGUI
        mViewPort->setOverlaysEnabled(false);
        //the cegui renderer wants a TexturePtr (not a RenderTexturePtr), so we just ask the texturemanager for texture we just created (rttex)
    }
}
Пример #9
0
Ogre::TexturePtr Simple::updateShadowTexture(Ogre::MaterialPtr material, const TerrainPageShadow* terrainPageShadow, std::set<std::string>& managedTextures) const
{
	auto shadowTextureName = getShadowTextureName(material);

	Ogre::TexturePtr texture = static_cast<Ogre::TexturePtr>(Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(shadowTextureName));
	if (texture.isNull()) {
		texture = Ogre::Root::getSingletonPtr()->getTextureManager()->createManual(shadowTextureName, "General", Ogre::TEX_TYPE_2D, mPage.getBlendMapSize(), mPage.getBlendMapSize(), 1, Ogre::PF_L8, Ogre::TU_DYNAMIC_WRITE_ONLY);
		managedTextures.insert(texture->getName());
	}

	Ogre::Image ogreImage;
	terrainPageShadow->loadIntoImage(ogreImage);

	texture->loadImage(ogreImage);

	//blit the whole image to the hardware buffer
	Ogre::PixelBox sourceBox(ogreImage.getPixelBox());
	//blit for each mipmap
	for (unsigned int i = 0; i <= texture->getNumMipmaps(); ++i) {
		Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(texture->getBuffer(0, i));
		hardwareBuffer->blitFromMemory(sourceBox);
	}

	return texture;
}
Пример #10
0
  void OgreNode::updateFBO()
  {
    Ogre::TexturePtr rttTexture = mRenderSystem->getRtt("RttTex", mSize.width(), mSize.height());
    mRenderTarget = rttTexture->getBuffer()->getRenderTarget();

    Ogre::Camera* cam = mRenderSystem->getOgreCamera();

    mRenderTarget->addViewport(cam);

    Ogre::Real aspectRatio = Ogre::Real(mSize.width()) / Ogre::Real(mSize.height());
    cam->setAspectRatio(aspectRatio);

    QSGGeometry::updateTexturedRectGeometry(&mGeometry,
        QRectF(0, 0, mSize.width(), mSize.height()),
        QRectF(0, 0, 1, 1));

    Ogre::GLTexture *nativeTexture = static_cast<Ogre::GLTexture *>(rttTexture.get());

    delete mTexture;
    mTexture = mQuickWindow->createTextureFromId(nativeTexture->getGLID(), mSize);

    mMaterial.setTexture(mTexture);
    mMaterialO.setTexture(mTexture);

    LOG(INFO) << "Updated FBO, new size: " << mSize.width() << "x" << mSize.height() << ", texture id: " << nativeTexture->getGLID();
  }
Пример #11
0
//----------------------------------------------------------------------------//
void OgreTextureTarget::declareRenderSize(const Sizef& sz)
{
    // exit if current size is enough
    if ((d_area.getWidth() >= sz.d_width) && (d_area.getHeight() >=sz.d_height))
        return;

    Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(
        OgreTexture::getUniqueName(),
        Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        Ogre::TEX_TYPE_2D, sz.d_width, sz.d_height, 1, 0, Ogre::PF_A8R8G8B8,
        Ogre::TU_RENDERTARGET);

    d_renderTarget = rttTex->getBuffer()->getRenderTarget();

    Rectf init_area(
        Vector2f(0, 0),
        Sizef(d_renderTarget->getWidth(), d_renderTarget->getHeight())
    );

    setArea(init_area);

    // delete viewport and reset ptr so a new one is generated.  This is
    // required because we have changed d_renderTarget so need a new VP also.
    delete d_viewport;
    d_viewport = 0;

    // because Texture takes ownership, the act of setting the new ogre texture
    // also ensures any previous ogre texture is released.
    d_CEGUITexture->setOgreTexture(rttTex, true);

    clear();
}
Пример #12
0
void video_display(VideoState *is)
{
  VideoPicture *vp;

  vp = &is->pictq[is->pictq_rindex];

  if (is->video_st->codec->width != 0 && is->video_st->codec->height != 0)
  {
    Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton ().getByName("VideoTexture");
    if (texture.isNull () || texture->getWidth() != is->video_st->codec->width || texture->getHeight() != is->video_st->codec->height)
    {
      Ogre::TextureManager::getSingleton ().remove ("VideoTexture");
      texture = Ogre::TextureManager::getSingleton().createManual(
                  "VideoTexture",
                  Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                  Ogre::TEX_TYPE_2D,
                  is->video_st->codec->width, is->video_st->codec->height,
                  0,
                  Ogre::PF_BYTE_RGBA,
                  Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
    }
    Ogre::PixelBox pb(is->video_st->codec->width, is->video_st->codec->height, 1, Ogre::PF_BYTE_RGBA, vp->data);
    Ogre::HardwarePixelBufferSharedPtr buffer = texture->getBuffer();
    buffer->blitFromMemory(pb);
  }

  free(vp->data);
}
Пример #13
0
void HTML::PaintScrollImage(Ogre::HardwarePixelBufferSharedPtr pixelBuffer, const Berkelium::Rect& scrollOrigRect, int scroll_dx, int scroll_dy)
{

  Berkelium::Rect scrolledRect = scrollOrigRect.translate(scroll_dx, scroll_dy);

  Berkelium::Rect scrolled_shared_rect = scrollOrigRect.intersect(scrolledRect);
  // Only do scrolling if they have non-zero intersection
  if(scrolled_shared_rect.width() == 0 || scrolled_shared_rect.height() == 0)
    return;
  Berkelium::Rect shared_rect = scrolled_shared_rect.translate(-scroll_dx, -scroll_dy);

  size_t width = shared_rect.width();
  size_t height = shared_rect.height();

  Ogre::TexturePtr shadow = Ogre::TextureManager::getSingleton().createManual("scrollbuf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, Ogre::Bitwise::firstPO2From(width), Ogre::Bitwise::firstPO2From(height), 1, 1, Ogre::PF_BYTE_BGRA);
  {
    Ogre::HardwarePixelBufferSharedPtr shadowBuffer = shadow->getBuffer();

    Berkelium::Rect borderedScrollRect = GetBorderedRect(shared_rect);
    Berkelium::Rect borderedScrolledRect = GetBorderedRect(scrolled_shared_rect);

    shadowBuffer->blit(pixelBuffer, Ogre::Box(borderedScrollRect.left(), borderedScrollRect.top(), borderedScrollRect.right(), borderedScrollRect.bottom()), Ogre::Box(0, 0, width, height));

    pixelBuffer->blit(shadowBuffer, Ogre::Box(0, 0, width, height), Ogre::Box(borderedScrolledRect.left(), borderedScrolledRect.top(), borderedScrolledRect.right(), borderedScrolledRect.bottom()));
  }

  Ogre::ResourcePtr shadowResource(shadow);
  Ogre::TextureManager::getSingleton().remove(shadowResource);

}
Пример #14
0
void initShadows()
{
    const unsigned int numShadowTex = 1;

    GlbVar.ogreSmgr->setShadowTextureSelfShadow(true);
    GlbVar.ogreSmgr->setShadowTextureCasterMaterial("shadow_caster");

    GlbVar.ogreSmgr->setShadowTextureCount(numShadowTex);
    GlbVar.ogreSmgr->setShadowTextureSize(256);
    GlbVar.ogreSmgr->setShadowTexturePixelFormat(Ogre::PF_FLOAT16_RGB);
    GlbVar.ogreSmgr->setShadowTextureCountPerLightType(Ogre::Light::LT_SPOTLIGHT, numShadowTex);
    GlbVar.ogreSmgr->setShadowCasterRenderBackFaces(false);

    for (unsigned int i = 0; i < numShadowTex; ++i) 
    {
        Ogre::TexturePtr tex = GlbVar.ogreSmgr->getShadowTexture(i);
        Ogre::Viewport *vp = tex->getBuffer()->getRenderTarget()->getViewport(0);
        vp->setBackgroundColour(Ogre::ColourValue(1,1,1,1));
        vp->setClearEveryFrame(true);
    }
    GlbVar.ogreSmgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);

    //Debug overlays.
    /*
    unsigned int w = GlbVar.ogreWindow->getWidth();
    for (unsigned int i = 0; i < numShadowTex; ++i)
    {
        MyGUI::StaticImagePtr img = GlbVar.gui->createWidget<MyGUI::StaticImage>("StaticImage", w - 250 , 50 + 210*i, 200, 200, MyGUI::Align::Default, "Main");
        img->setImageTexture(GlbVar.ogreSmgr->getShadowTexture(i)->getName());
        img->setVisible(true);
    }
    */
}
Пример #15
0
//------------------------------------------------------------------------------
void OgreVideoTexture::_initTexture(Ogre::TexturePtr _texture)
{
    // Get the pixel buffer
    Ogre::HardwarePixelBufferSharedPtr pixelBuffer = _texture->getBuffer();

    // Lock the pixel buffer and get a pixel box
    pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
    const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();

    Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);

    for (size_t j = 0; j < _texture->getHeight(); j++)
        for(size_t i = 0; i < _texture->getWidth() ; i++)
        {

            if (j<480-5 && i<640-5)
            {
                *pDest++ = 255; // B
                *pDest++ = 0; // G
                *pDest++ = 255; // R
            }
            else
            {
                *pDest++ = 255; // B
                *pDest++ = 0;   // G
                *pDest++ = 0; // R
            }
        }
 
        pixelBuffer->unlock();
}
Пример #16
0
//-------------------------------------------------------------------------------------------
void MagickWidget::loadMesh(Ogre::MeshPtr pMesh)
{
    QString directory(OgitorsRoot::getSingletonPtr()->GetProjectOptions()->ProjectDir.c_str());
    if(directory.isEmpty())
        directory = "./";

    QDir(directory).mkpath("entitycache");

    Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "MeshMagickTex", 
                   Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 
                   512, 512, 0, Ogre::PF_R8G8B8A8 , Ogre::TU_RENDERTARGET );

    Ogre::RenderTexture *rttTex = texture->getBuffer()->getRenderTarget();
    Ogre::SceneManager *mSceneMgr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "MeshMagickTexMgr");

    Ogre::Light *dirl = mSceneMgr->createLight("DisplayLight");
    dirl->setDirection(-1,-1,-1);
    dirl->setDiffuseColour(1,1,1);
    dirl->setType(Ogre::Light::LT_DIRECTIONAL);

    Ogre::Camera* RTTCam = mSceneMgr->createCamera("MeshMagickCam");
    RTTCam->setNearClipDistance(0.01F);
    RTTCam->setFarClipDistance(0);
    RTTCam->setAspectRatio(1);
    RTTCam->setFOVy(Ogre::Degree(90));
    RTTCam->setPosition(0,0,1);
    RTTCam->lookAt(0,0,0);

    Ogre::Viewport *v = rttTex->addViewport( RTTCam );
    v->setClearEveryFrame( true );
    v->setBackgroundColour(Ogre::ColourValue(0,0,0));

    Ogre::Entity *mEntity;

    mEntity = mSceneMgr->createEntity("scbDisplay", pMesh->getName());
    mSceneMgr->getRootSceneNode()->attachObject(mEntity);

    Ogre::Vector3 vSize = mEntity->getBoundingBox().getHalfSize();
    Ogre::Vector3 vCenter = mEntity->getBoundingBox().getCenter(); 
    
    vSize += Ogre::Vector3(vSize.z, vSize.z, vSize.z);

    float maxsize = std::max(std::max(vSize.x,vSize.y),vSize.z);
    
    vSize = Ogre::Vector3(0, 0, maxsize * 1.15f) + vCenter;
    
    RTTCam->setPosition(vSize.x,vSize.y,vSize.z);
    RTTCam->lookAt(vCenter.x,vCenter.y,vCenter.z);

    rttTex->update();
    Ogre::String imagefile = OgitorsUtils::QualifyPath(directory.toStdString() + "/entitycache/meshmagick.png");
    rttTex->writeContentsToFile(imagefile);

    mEntity->detachFromParent();
    mSceneMgr->destroyEntity(mEntity);
    rttTex->removeAllViewports();
    Ogre::Root::getSingletonPtr()->destroySceneManager(mSceneMgr);
    mDisplayWidget->setImage(QString(imagefile.c_str()));
}
Пример #17
0
 void QOgreWorldView::OverlayUI(Ogre::PixelBox &ui)
 {
     PROFILE(QOgreWorldView_OverlayUI);
     Ogre::TextureManager &mgr = Ogre::TextureManager::getSingleton();
     Ogre::TexturePtr texture = mgr.getByName(texture_name_);
     assert(texture.get());
     texture->getBuffer()->blitFromMemory(ui);
 }
Пример #18
0
bool EC_WidgetCanvas::Blit(const QImage &source, Ogre::TexturePtr destination)
{
#if defined(DIRECTX_ENABLED) && defined(WIN32)
    Ogre::HardwarePixelBufferSharedPtr pb = destination->getBuffer();
    Ogre::D3D9HardwarePixelBuffer *pixelBuffer = dynamic_cast<Ogre::D3D9HardwarePixelBuffer*>(pb.get());
    if (!pixelBuffer)
        return false;

    LPDIRECT3DSURFACE9 surface = pixelBuffer->getSurface(Ogre::D3D9RenderSystem::getActiveD3D9Device());
    if (surface)
    {
        D3DSURFACE_DESC desc;
        HRESULT hr = surface->GetDesc(&desc);
        if (SUCCEEDED(hr))
        {
            D3DLOCKED_RECT lock;
            HRESULT hr = surface->LockRect(&lock, 0, 0);
            if (SUCCEEDED(hr))
            {
                const int bytesPerPixel = 4; ///\todo Count from Ogre::PixelFormat!
                const int sourceStride = bytesPerPixel * source.width();
                if (lock.Pitch == sourceStride)
                    memcpy(lock.pBits, source.bits(), sourceStride * source.height());
                else
                    for(int y = 0; y < source.height(); ++y)
                        memcpy((u8*)lock.pBits + lock.Pitch * y, source.bits() + sourceStride * y, sourceStride);
                surface->UnlockRect();
            }
        }
    }
#else
    if (!destination->getBuffer().isNull())
    {
        Ogre::Box update_box(0, 0, source.width(), source.height());
        Ogre::PixelBox pixel_box(update_box, Ogre::PF_A8R8G8B8, (void*)source.bits());
        destination->getBuffer()->blitFromMemory(pixel_box, update_box);
    }
#endif

    return true;
}
Пример #19
0
void RenderWindow::UpdateOverlayImage(const QImage &src)
{
    PROFILE(RenderWindow_UpdateOverlayImage);

    Ogre::Box bounds(0, 0, src.width(), src.height());
    Ogre::PixelBox bufbox(bounds, Ogre::PF_A8R8G8B8, (void *)src.bits());

    Ogre::TextureManager &mgr = Ogre::TextureManager::getSingleton();
    Ogre::TexturePtr texture = mgr.getByName(rttTextureName);
    assert(texture.get());
    texture->getBuffer()->blitFromMemory(bufbox);
}
Пример #20
0
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);
}
Пример #21
0
    void GlobalMap::exploreCell(int cellX, int cellY)
    {
        float originX = static_cast<float>((cellX - mMinX) * mCellSize);
        // NB y + 1, because we want the top left corner, not bottom left where the origin of the cell is
        float originY = static_cast<float>(mHeight - (cellY + 1 - mMinY) * mCellSize);

        if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY)
            return;

        Ogre::TexturePtr localMapTexture = Ogre::TextureManager::getSingleton().getByName("Cell_"
            + boost::lexical_cast<std::string>(cellX) + "_" + boost::lexical_cast<std::string>(cellY));

        if (!localMapTexture.isNull())
        {
            int mapWidth = localMapTexture->getWidth();
            int mapHeight = localMapTexture->getHeight();
            mOverlayTexture->load();
            mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,mapWidth,mapHeight),
                         Ogre::Image::Box(static_cast<Ogre::uint32>(originX), static_cast<Ogre::uint32>(originY),
                         static_cast<Ogre::uint32>(originX + mCellSize), static_cast<Ogre::uint32>(originY + mCellSize)));

            Ogre::Image backup;
            std::vector<Ogre::uchar> data;
            data.resize(mCellSize*mCellSize*4, 0);
            backup.loadDynamicImage(&data[0], mCellSize, mCellSize, Ogre::PF_A8B8G8R8);

            localMapTexture->getBuffer()->blitToMemory(Ogre::Image::Box(0,0,mapWidth,mapHeight), backup.getPixelBox());

            for (int x=0; x<mCellSize; ++x)
                for (int y=0; y<mCellSize; ++y)
                {
                    assert (originX+x < mOverlayImage.getWidth());
                    assert (originY+y < mOverlayImage.getHeight());
                    assert (x < int(backup.getWidth()));
                    assert (y < int(backup.getHeight()));
                    mOverlayImage.setColourAt(backup.getColourAt(x, y, 0), static_cast<size_t>(originX + x), static_cast<size_t>(originY + y), 0);
                }
        }
    }
Пример #22
0
 void ReliefApp::GenerateRelief()
 {
     //Get depth data
     Ogre::TexturePtr depthTex = Ogre::TextureManager::getSingleton().createManual(  
         "DepthTexture",      // name   
         Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  
         Ogre::TEX_TYPE_2D,   // type   
         512,  // width   
         512,  // height   
         0,                   // number of mipmaps   
         //Ogre::PF_B8G8R8A8,   // pixel format
         Ogre::PF_FLOAT32_R,
         Ogre::TU_RENDERTARGET
         ); 
     Ogre::RenderTarget* pTarget = depthTex->getBuffer()->getRenderTarget();
     Ogre::Camera* pOrthCam = MagicCore::RenderSystem::GetSingleton()->GetMainCamera();
     pOrthCam->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
     pOrthCam->setOrthoWindow(3, 3);
     pOrthCam->setPosition(0, 0, 3);
     pOrthCam->lookAt(0, 0, 0);
     pOrthCam->setAspectRatio(1.0);
     pOrthCam->setNearClipDistance(0.5);
     pOrthCam->setFarClipDistance(5);
     Ogre::Viewport* pViewport = pTarget->addViewport(pOrthCam);
     pViewport->setDimensions(0, 0, 1, 1);
     MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "Depth", mpLightMesh);
     MagicCore::RenderSystem::GetSingleton()->Update();
     Ogre::Image img;
     depthTex->convertToImage(img);
     std::vector<double> heightField(512 * 512);
     for(int x = 0; x < 512; x++)  
     {  
         for(int y = 0; y < 512; y++)  
         {
             heightField.at(x * 512 + y) = (img.getColourAt(x, 511 - y, 0))[1];
         }
     }
     Ogre::TextureManager::getSingleton().remove("DepthTexture");
     //
     MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::PlaneReliefFromHeightField(heightField, 511, 511);
     //MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::CylinderReliefFromHeightField(heightField, 511, 511);
     if (pReliefMesh != NULL)
     {
         delete mpLightMesh;
         mpLightMesh = pReliefMesh;
         mpLightMesh->UnifyPosition(2);
         mpLightMesh->UpdateNormal();
     }
     MagicCore::RenderSystem::GetSingleton()->SetupCameraDefaultParameter();
     MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "MyCookTorrance", mpLightMesh);
 }
Пример #23
0
/*!
  Get the result of the rendering loop.

  \param I : The image on which to copy the result of the rendering loop.
  \param cMo : The desired camera pose.
*/
void vpAROgre::getRenderingOutput(vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo)
{
    updateCameraParameters(cMo);
    Ogre::TexturePtr dynTexPtr = Ogre::TextureManager::getSingleton().getByName("rtf");
//#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) )
//        .dynamicCast<Ogre::Texture>();
//#else
//        ;
//#endif
    Ogre::RenderTexture* RTarget = dynTexPtr->getBuffer()->getRenderTarget();
    mWindow->update();
    RTarget->update();
    if(I.getHeight() != mWindow->getHeight() || I.getWidth() != mWindow->getWidth()){
       I.resize(mWindow->getHeight(), mWindow->getWidth());
    }
    Ogre::HardwarePixelBufferSharedPtr mPixelBuffer = dynTexPtr->getBuffer();
    mPixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
    const Ogre::PixelBox& pixelBox = mPixelBuffer->getCurrentLock();
    dynTexPtr->getBuffer()->blitToMemory(pixelBox);
    Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
#if 1 // if texture in BGRa format
    for(unsigned int i=0; i<I.getHeight(); i++){
      for(unsigned int j=0; j<I.getWidth(); j++){
	// Color Image
	I[i][j].B = *pDest++; // Blue component
	I[i][j].G = *pDest++; // Green component
	I[i][j].R = *pDest++; // Red component
	I[i][j].A = *pDest++; // Alpha component
      }
    }
#else // if texture in RGBa format which is the format of the input image
    memcpy(I.bitmap, pDest, I.getHeight()*I.getWidth()*sizeof(vpRGBa));
#endif

    // Unlock the pixel buffer
    mPixelBuffer->unlock();

}
Пример #24
0
void PlayState::enter()
{
    mLuaState = lua_open();
    luaL_openlibs(mLuaState);
    luabind::open(mLuaState);
    LuaBinding binder(mLuaState);
    binder.bindLua();

    mKeyboard = InputManager::getSingletonPtr()->getKeyboard();
    mMouse = InputManager::getSingletonPtr()->getMouse();
    mRoot = Root::getSingletonPtr();
    mSoundMgr = SoundManager::getSingletonPtr();
    mGUI = 0;
    mViewport = 0;
    //mCurrentLevel = 0;
    createSounds();
    mContinue = true;
    mRotate = 0.13;
    mFriendScore = 0;
    mFocusActor = 0;
    mRivalScore = 0;
    mFriendLastScore = 0;
    mRivalLastScore = 0;
    firstConsoleInit = true;

    Ogre::ShadowTextureManager::getSingletonPtr()->clear();
    mSceneMgr = mRoot->createSceneManager(Ogre::ST_EXTERIOR_CLOSE, "Default SceneManager");
    mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);

    DotLevelLoader loader(mLuaState);
    loader.parseLevels("game.levels", mLevels);
    createScene();

    mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera);
    initPlayerCam();
    mViewport->setBackgroundColour(ColourValue(0.0, 0.0, 0.0));

    initGUI();

    mWindow = mRoot->getAutoCreatedWindow();

    Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual("RttTex",
                               ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, PF_R8G8B8,
                               TU_RENDERTARGET);

    mRenderTexture = texture->getBuffer()->getRenderTarget();
    mRenderTexture->addViewport(mCamera);
    mRenderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
    mRenderTexture->getViewport(0)->setOverlaysEnabled(true);
}
Пример #25
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is part of the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

#include "constants.h"
#include "texturelayer.h"
#include "OgreHlmsPbs.h"
#include "OgreHlmsManager.h"
#include "OgreLogManager.h"
#include "OgreStringConverter.h"
#include <fstream>
#include <ctime>

//****************************************************************************/
TextureLayer::TextureLayer(void) :
    mTextureOnWhichIsPaintedWidth(0),
    mTextureOnWhichIsPaintedHeight(0),
    mTextureOnWhichIsPaintedHasAlpha(false),
    mNumMipMaps(0),
    mTextureTypeDefined(false),
    mMaxSequence(0)
{
    mTextureType = Ogre::PBSM_DIFFUSE;
    mDatablockId = "";
    mTextureFileName = "";
}

//****************************************************************************/
TextureLayer::~TextureLayer(void)
{
}

//****************************************************************************/
void TextureLayer::setDatablockIdAndTexture (const Ogre::IdString& datablockId,
                                             Ogre::PbsTextureTypes textureType,
                                             const Ogre::String& textureFileName)
{
    mDatablockId = datablockId;
    mTextureType = textureType;
    mTextureFileName = textureFileName;
    mTextureTypeDefined = true;

    // Load the texture as image; assume it can be loaded, because it was already loaded as part of the material
    setFirstTextureGeneration();

    // Create the pixelbox of the original texture; this MUST be a separate image
    mOriginalTexture.load(textureFileName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    mPixelboxOriginalTexture = mOriginalTexture.getPixelBox(0, 0);

    // Debug texture
    //Ogre::LogManager::getSingleton().logMessage("Debug texture: " + textureFileName);
    //Ogre::LogManager::getSingleton().logMessage("Depth: " + Ogre::StringConverter::toString(mOriginalTexture.getDepth()));
    //Ogre::LogManager::getSingleton().logMessage("Pixel format: " + Ogre::StringConverter::toString(mOriginalTexture.getFormat()));
    //Ogre::LogManager::getSingleton().logMessage("Alpha: " + Ogre::StringConverter::toString(mOriginalTexture.getHasAlpha()));
    //Ogre::LogManager::getSingleton().logMessage("Height: " + Ogre::StringConverter::toString(mOriginalTexture.getHeight()));
    //Ogre::LogManager::getSingleton().logMessage("Number of faces: " + Ogre::StringConverter::toString(mOriginalTexture.getNumFaces()));
    //Ogre::LogManager::getSingleton().logMessage("Number of mipmaps: " + Ogre::StringConverter::toString(mOriginalTexture.getNumMipmaps()));
    //Ogre::LogManager::getSingleton().logMessage("Width: " + Ogre::StringConverter::toString(mOriginalTexture.getWidth()));
}

//****************************************************************************/
void TextureLayer::blitTexture (void)
{
    /* Always get the actual pointers, because they may change. That is the reason why the datablock pointer cannot be cached.
     * The same seems to apply to the texture pointer.
     */
    Ogre::HlmsDatablock* datablock;
    Ogre::HlmsPbsDatablock* datablockPbs;
    Ogre::TexturePtr texture;
    Ogre::HlmsManager* hlmsManager = Ogre::Root::getSingletonPtr()->getHlmsManager();
    Ogre::HlmsPbs* hlmsPbs = static_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS));
    datablock = hlmsPbs->getDatablock(mDatablockId);
    if (!datablock)
        return;

    datablockPbs = static_cast<Ogre::HlmsPbsDatablock*>(datablock);
    try
    {
        // Get texture on GPU
        if (!datablockPbs->getTexture(mTextureType).isNull())
        {
            texture = datablockPbs->getTexture(mTextureType); // TextureType MUST exist, otherwise the application crashes
            mNumMipMaps = texture->getNumMipmaps();
        }
    }
    catch (Ogre::Exception e){}

    if (texture.isNull())
        return;

    Ogre::uint8 maxMipMaps = mNumMipMaps + 1; // Increase with one, because there is always one image to blit
    maxMipMaps = maxMipMaps > PAINT_MAX_MIP_MAPS ? PAINT_MAX_MIP_MAPS : maxMipMaps; // Just paint a few mipmaps (not all)
    Ogre::Image textureOnWhichIsPaintedScaled = mTextureOnWhichIsPainted; // Temporary image must be used, otherwise painting doesn't work
    size_t w = mTextureOnWhichIsPaintedWidth;
    size_t h = mTextureOnWhichIsPaintedHeight;
    Ogre::v1::HardwarePixelBuffer* buffer;
    for (Ogre::uint8 i = 0; i < maxMipMaps; ++i)
    {
        buffer = texture->getBuffer(0, i).getPointer();
        buffer->blitFromMemory(textureOnWhichIsPaintedScaled.getPixelBox(0, 0), Ogre::Box(0, 0, 0, w, h, 1));
        w*=0.5f; // Mipmaps always are half of the previous one
        h*=0.5f;
        if (w < 1.0f || h < 1.0f)
            break; // Stop when the mipmaps are too small

        textureOnWhichIsPaintedScaled.resize(w, h);

    }
    textureOnWhichIsPaintedScaled.freeMemory();
}
Пример #26
0
void GPGPUDemo::launch()
{
	// create rendertarget
	Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual("Ogre/GPGPU/RT", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET);

	// load material
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName("GPGPUDemo");
	mat->load();

	Ogre::GPGPU::Root* gpgpu = new Ogre::GPGPU::Root;
	Ogre::GPGPU::Result* result = gpgpu->createResult(tex->getBuffer(0, 0));
	Ogre::GPGPU::Operation* op  = gpgpu->createOperation(mat->getTechnique(0)->getPass(0));

	Chrono chrono(true);
	for (unsigned int i=0; i<5000; ++i)
		gpgpu->compute(result, op);
	result->save("gpgpu_computing.png");
	std::cout << chrono.getTimeElapsed() << "ms [rendering+saving]" << std::endl;
}
Пример #27
0
	void UiManager::renderIntoTexture(const Ogre::TexturePtr &aTexture)
	{
		assert(!aTexture.isNull());
		assert(isViewSizeMatching(aTexture));
		
		Ogre::HardwarePixelBufferSharedPtr hwBuffer = aTexture->getBuffer(0, 0);
		hwBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
		
		const Ogre::PixelBox &pb = hwBuffer->getCurrentLock();
		
		// render into texture buffer
		QImage textureImg((uchar *)pb.data, pb.getWidth(), pb.getHeight(), QImage::Format_ARGB32);
		textureImg.fill(0);
		
		QPainter painter(&textureImg);
		mWidgetView->render(&painter, QRect(QPoint(0, 0), mWidgetView->size()), QRect(QPoint(0, 0), mWidgetView->size()));
		
		hwBuffer->unlock();
	}
Пример #28
0
    void TerrainWeightEditor::ApplyWeightTexture()
    {
        if(!GetSceneManager())
            return;

        QImage map  = CreateImageFromCanvases();
        if(map.isNull())
            return;
        
        if(map.format() != QImage::Format_ARGB32)
        {
            map = map.convertToFormat(QImage::Format_ARGB32/*,Qt::NoOpaqueDetection*/);
        }
        Ogre::Box bounds(0, 0, map.width(), map.height());
        Ogre::PixelBox bufbox(bounds, Ogre::PF_A8R8G8B8, (void *)map.bits());
        Scene::EntityList list = scene_manager_->GetEntitiesWithComponent("EC_Terrain");
        Scene::EntityList::const_iterator it = list.begin();
        while(it!= list.end())
        {
            boost::shared_ptr<EC_Terrain> ptr = (*it)->GetComponent<EC_Terrain>();
            QString texname;
            texname += (*it)->GetName();
            texname += ptr->TypeName();
            texname += ptr->Name();
            texname += ".png";
            Ogre::String str(texname.toStdString());
            Ogre::TextureManager::getSingleton().remove(str);
            Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual(str, "General", Ogre::TEX_TYPE_2D, bufbox.getWidth(), bufbox.getHeight(),bufbox.getDepth(),0,bufbox.format,Ogre::TU_DYNAMIC_WRITE_ONLY);
            if(tex.get())
            {
                tex->getBuffer()->blitFromMemory(bufbox);
            }
            ptr->texture0.Set(AssetReference(texname/*, "OgreTexture"*/), AttributeChange::Disconnected);
            it++;

            ///For now we just save this to assets folder. Later on, this should be replicated to server/clients etc.
            QImageWriter writer("data/assets/" + texname);
            writer.setCompression(0);
            writer.write(map);
            
        }
    }
Пример #29
0
void McsHudGui::addFrameGraph(CEGUI::Window* sheet)
{
    Ogre::TexturePtr tex = mOgreRoot->getTextureManager()->createManual(
                               "FrameGraph", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
                               TimeGraphMaxFrames, TimeGraphMaxResolution, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);

    Ogre::SceneManager* debugSceneMgr = mOgreRoot->createSceneManager(Ogre::ST_GENERIC);
    debugSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));

    Ogre::MaterialPtr frameLinesMaterial = Ogre::MaterialManager::getSingleton().create("frameLinesMaterial","Game");
    frameLinesMaterial->setReceiveShadows(false);
    frameLinesMaterial->getTechnique(0)->setLightingEnabled(false);
    frameLinesMaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
    frameLinesMaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);

    mFrameLines = new FrameGraphRenderable(TimeGraphMaxFrames, TimeGraphMaxResolution);
    mFrameLines->setMaterial("frameLinesMaterial");

    Ogre::SceneNode* frameLinesNode = debugSceneMgr->getRootSceneNode()->createChildSceneNode("frameGraph_node");
    frameLinesNode->attachObject(mFrameLines);
    Ogre::Camera* dbg_camera = debugSceneMgr->createCamera("item_camera");
    dbg_camera->setAspectRatio(static_cast<Ogre::Real>(TimeGraphMaxFrames) / static_cast<Ogre::Real>(TimeGraphMaxResolution));
    Ogre::Viewport *v = tex->getBuffer()->getRenderTarget()->addViewport(dbg_camera);
    v->setClearEveryFrame( true );
    v->setBackgroundColour( Ogre::ColourValue::Black );



    CEGUI::Texture& guiTex = mCeRenderer->createTexture(tex);
    CEGUI::Imageset& imageSet = CEGUI::ImagesetManager::getSingleton().create("FrameGraphImageset", guiTex);
    imageSet.defineImage("FrameGraphImage", CEGUI::Point(0.0f, 0.0f), CEGUI::Size(guiTex.getSize()), CEGUI::Point(0.0f, 0.0f));
    CEGUI::Window* si = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "FrameGraphWindow");
    si->setSize(CEGUI::UVector2(CEGUI::UDim(0.0f, TimeGraphMaxFrames), CEGUI::UDim(0.0f, TimeGraphMaxResolution)));
    si->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0), CEGUI::UDim(1.0f, -TimeGraphMaxResolution)));
    si->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imageSet.getImage("FrameGraphImage")));
    si->setAlpha(0.6f);
    si->setProperty("BackgroundEnabled", "False");
    si->setProperty("FrameEnabled", "False");

    sheet->addChildWindow(si);
}
Пример #30
0
//----------------------------------------------------------------------------------------
ImageConverter::ImageConverter(const size_t& width/*=128*/, const size_t& height/*=128*/)
{
    mWidth = width;
    mHeight = height;

    mResourceManager = Ogre::ResourceGroupManager::getSingletonPtr();
    mResourceManager->createResourceGroup("QTImageConverter");
    mResourceManager->initialiseResourceGroup("QTImageConverter");
    
    mSceneMgrPtr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "QTImageConverterSceneManager");
    mSceneMgrPtr->setAmbientLight(Ogre::ColourValue(1, 1, 1));

    Ogre::TexturePtr rendertexture = Ogre::TextureManager::getSingleton().createManual("RenderTex", 
                   "QTImageConverter", Ogre::TEX_TYPE_2D, 
                   mWidth, mHeight, 1, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);

    mRttTex = rendertexture->getBuffer()->getRenderTarget();

    // create our plane to set a texture to
    Ogre::Plane plane(Ogre::Vector3::UNIT_Z, 0);
    Ogre::MeshManager::getSingleton().createPlane("terrain", "QTImageConverter",
        plane, 100, 100, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Y);

    // attach the plane to the scene manager and rotate it so the camera can see it
    mEntityTerrain = mSceneMgrPtr->createEntity("terrainEntity", "terrain");
    Ogre::SceneNode* node = mSceneMgrPtr->getRootSceneNode()->createChildSceneNode();
    node->attachObject(mEntityTerrain);
    mEntityTerrain->setCastShadows(false);    
    
    Ogre::Camera* RTTCam = mSceneMgrPtr->createCamera("QTImageConverterCam");
    RTTCam->setNearClipDistance(0.01F);
    RTTCam->setFarClipDistance(0);
    RTTCam->setAspectRatio(1);
    RTTCam->setFOVy(Ogre::Degree(90));
    RTTCam->setPosition(0, 0, 50);
    RTTCam->lookAt(0, 0, 0);
    
    Ogre::Viewport *v = mRttTex->addViewport(RTTCam);
    v->setBackgroundColour(Ogre::ColourValue(1, 1, 1));
    v->setClearEveryFrame(true);
}