예제 #1
0
		/// udata_vp	CreateRTTViewport	(udata_rtt,udata_cam)  ... RTT = render to texture
		static int		CreateRTTViewport	(lua_State *L) { PROFILE
			Ogre::RenderTarget*	pRenderTarget 	= cLuaBind<cRenderTexture>::checkudata_alive(L,1)->mpRenderTarget;
			Ogre::Camera*			pCamera 		= cLuaBind<cCamera>::checkudata_alive(L,2)->mpCam;
			assert(pRenderTarget);
			assert(pCamera);
			Ogre::Viewport*			pViewPort = pRenderTarget->addViewport(pCamera);
			cViewport* target = pViewPort ? new cViewport(pViewPort) : 0;
			return CreateUData(L,target);
		}
예제 #2
0
	void GodRaysManager::remove()
	{
		if (!mCreated)
		{
			return;
		}

		delete mPerlin;
		mPerlin = static_cast<Noise::Perlin*>(NULL);

		mHydrax->getSceneManager()->destroyManualObject(mManualGodRays);
		mManualGodRays = static_cast<Ogre::ManualObject*>(NULL);

		if (Ogre::MaterialManager::getSingleton().resourceExists(_def_GodRays_Material_Name))
		{
			Ogre::MaterialManager::getSingleton().remove(_def_GodRays_Material_Name);

			Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_GodRays_Shader_VP_Name);
		    Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_GodRays_Shader_FP_Name);
			Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_GodRays_Shader_VP_Name);
		    Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_GodRays_Shader_FP_Name);
		}

		if (Ogre::MaterialManager::getSingleton().resourceExists(_def_GodRaysDepth_Material_Name))
		{
			Ogre::MaterialManager::getSingleton().remove(_def_GodRaysDepth_Material_Name);

			Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_GodRaysDepth_Shader_VP_Name);
		    Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_GodRaysDepth_Shader_FP_Name);
			Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_GodRaysDepth_Shader_VP_Name);
		    Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_GodRaysDepth_Shader_FP_Name);
		}

		for (int k = 0; k < 2; k++)
		{
			mMaterials[k].setNull();
		}

		if (!mProjectorRTT.isNull())
		{
			Ogre::RenderTarget* RT = mProjectorRTT->getBuffer()->getRenderTarget();
            RT->removeAllListeners();
            RT->removeAllViewports();

			Ogre::TextureManager::getSingleton().remove(mProjectorRTT->getName());
			mProjectorRTT.setNull();
		}

		mHydrax->getSceneManager()->destroyCamera(mProjectorCamera);
		mProjectorCamera = static_cast<Ogre::Camera*>(NULL);

		mProjectorSN->detachAllObjects();
		mProjectorSN->getParentSceneNode()->removeAndDestroyChild(mProjectorSN->getName());
		mProjectorSN = static_cast<Ogre::SceneNode*>(NULL);

		mCreated = false;
	}
예제 #3
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);
 }
예제 #4
0
//----------------------------------------------------------------------------//
void OgreRenderer::constructor_impl(Ogre::RenderTarget& target)
{
    d_pimpl->d_renderSystem = d_pimpl->d_ogreRoot->getRenderSystem();

    d_pimpl->d_displaySize.d_width  = target.getWidth();
    d_pimpl->d_displaySize.d_height = target.getHeight();

    // create default target & rendering root (surface) that uses it
    d_pimpl->d_defaultTarget =
        new OgreWindowTarget(*this, *d_pimpl->d_renderSystem, target);

    // hook into the rendering process
    d_pimpl->d_ogreRoot->addFrameListener(&S_frameListener);
}
예제 #5
0
//-----------------------------------------------------------------------
void CompositorManager::_relocateChain( Viewport* sourceVP, Viewport* destVP )
{
    if (sourceVP != destVP)
    {
        CompositorChain *chain = getCompositorChain(sourceVP);
        Ogre::RenderTarget *srcTarget = sourceVP->getTarget();
        Ogre::RenderTarget *dstTarget = destVP->getTarget();
        if (srcTarget != dstTarget)
        {
            srcTarget->removeListener(chain);
            dstTarget->addListener(chain);
        }
        chain->_notifyViewport(destVP);
        mChains.erase(sourceVP);
        mChains[destVP] = chain;
    }
}
예제 #6
0
//----------------------------------------------------------------------------//
void OgreRenderer::constructor_impl(Ogre::RenderTarget& target)
{
    d_pimpl->d_renderSystem = d_pimpl->d_ogreRoot->getRenderSystem();

    d_pimpl->d_displaySize.d_width  = target.getWidth();
    d_pimpl->d_displaySize.d_height = target.getHeight();

    // create default target & rendering root (surface) that uses it
    d_pimpl->d_defaultTarget =
        CEGUI_NEW_AO OgreWindowTarget(*this, *d_pimpl->d_renderSystem, target);

#if defined RTSHADER_SYSTEM_BUILD_CORE_SHADERS && OGRE_VERSION >= 0x10800
    // default to using shaders when that is the sane thing to do.
    if (!d_pimpl->d_renderSystem->getFixedPipelineEnabled())
        setUsingShaders(true);
#endif

    // hook into the rendering process
    d_pimpl->d_ogreRoot->addFrameListener(&S_frameListener);
}
Ogre::TexturePtr OgrePlanarReflectionMaterial::createRenderTargetTexture(Ogre::Camera& camera)
{
    using namespace Ogre;
    std::ostringstream s;
    s << "Rtt[" << numInstances << "]";
    TexturePtr texture = TextureManager::getSingleton().createManual(
            s.str(),
            "General",
            Ogre::TEX_TYPE_2D,
            resolutionTexture.getValue().elems[0],
            resolutionTexture.getValue().elems[1],
            0,
            PF_R8G8B8,
            Ogre::TU_RENDERTARGET);
    Ogre::RenderTarget* rtt = texture->getBuffer()->getRenderTarget();
    Ogre::Viewport* v = rtt->addViewport( &camera );
    v->setClearEveryFrame(true);
    v->setBackgroundColour( Ogre::ColourValue::Black );
    return texture;
}
예제 #8
0
파일: StereoManager.cpp 프로젝트: A-K/naali
    void StereoManager::updateAllDependentRenderTargets(bool isLeftEye)
    {
        Ogre::uint32 mask;
        if(isLeftEye)
        {
            mask = left_mask_;
        }
        else
        {
            mask = right_mask_;
        }

        RenderTargetList::iterator itarg, itargend;
        itargend = rendertarget_list_.end();
        for( itarg = rendertarget_list_.begin(); itarg != itargend; ++itarg )
        {
            Ogre::RenderTarget *rt = itarg->first;

            int n = rt->getNumViewports();
            std::vector<int> maskVector(n); // VS2005 gives a warning if I declare the vector as uint32 but not with int

            for(int i = 0; i<n ; ++i)
            {
                maskVector[i] = rt->getViewport(i)->getVisibilityMask();
                rt->getViewport(i)->setVisibilityMask(maskVector[i] & mask);
            }

            rt->update();

            for(int i = 0; i<n ; ++i)
            {
                rt->getViewport(i)->setVisibilityMask(maskVector[i]);
            }
        }
    }
예제 #9
0
void RttManager::remove(const RttType& Rtt)
{
  Ogre::TexturePtr &Tex = mTextures[Rtt];

  if (!Tex.isNull()) {
    Ogre::RenderTarget* RT = Tex->getBuffer()->getRenderTarget();
    RT->removeAllListeners();
    RT->removeAllViewports();

    Ogre::TextureManager::getSingleton().remove(mRttOptions[Rtt].Name);
    Ogre::MeshManager::getSingleton().remove(mRttOptions[Rtt].Name + "ClipPlane");

    Tex.setNull();
    delete mPlanes[Rtt];
    mPlanes[Rtt] = static_cast<Ogre::MovablePlane*>(NULL);
  }

  // Check it to avoid any possible problem(texture initializated by createTextureUnit(Name..))
  if (Ogre::TextureManager::getSingleton().resourceExists(mRttOptions[Rtt].Name)) {
    Ogre::TextureManager::getSingleton().remove(mRttOptions[Rtt].Name);
  }
}
예제 #10
0
파일: Screen.cpp 프로젝트: Chimangoo/ember
void Screen::toggleRenderMode()
{

	if (mPolygonMode == Ogre::PM_SOLID) {
		mPolygonMode = Ogre::PM_WIREFRAME;
	} else {
		mPolygonMode = Ogre::PM_SOLID;
	}

	Ogre::RenderSystem::RenderTargetIterator renderTargetI = Ogre::Root::getSingleton().getRenderSystem()->getRenderTargetIterator();

	for (Ogre::RenderSystem::RenderTargetIterator::iterator I = renderTargetI.begin(); I != renderTargetI.end(); ++I) {
		Ogre::RenderTarget* renderTarget = I->second;
		for (unsigned short i = 0; i < renderTarget->getNumViewports(); ++i) {
			Ogre::Camera* camera = renderTarget->getViewport(i)->getCamera();
			if (camera) {
				camera->setPolygonMode(mPolygonMode);
			}
		}

	}

}
예제 #11
0
파일: GUIManager.cpp 프로젝트: ChWick/Zelda
CGUIManager::CGUIManager(Ogre::SceneManager *pSceneManager, Ogre::RenderTarget &target)
: CEntity("GUIManager", nullptr),
  m_pSceneManager(pSceneManager),
  m_nRenderQueue(Ogre::RENDER_QUEUE_OVERLAY),
  m_bPostQueue(false),
  m_bRenderPause(false),
  m_vNativeRes(target.getWidth(), target.getHeight()),
  m_MouseMoving(MD_COUNT, false),
  m_fMouseSpeedX(0),
  m_fMouseSpeedY(0),
  m_fMouseAcceleration(2),
  m_fMouseInitialSpeed(50) {
  CInputListenerManager::getSingleton().addInputListener(this);

  OgreBites::SdkTrayManager *pTrayMgr = CGame::getSingleton().showLoadingBar(1, 1);
  pTrayMgr->loadBarSetCaption("GUI ...");
  Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing CEGUI ***");

  Ogre::LogManager::getSingletonPtr()->logMessage("    creating bootstrapSystem");
  pTrayMgr->userUpdateLoadBar("Creating bootstrap system", 0.1);
  m_pCEGuiOgreRenderer = &CEGUI::OgreRenderer::bootstrapSystem(target);
  m_pCEGuiOgreRenderer->setFrameControlExecutionEnabled(false);

  Ogre::LogManager::getSingletonPtr()->logMessage("    setting up resource paths");
  pTrayMgr->userUpdateLoadBar("Setting up resource paths", 0.1);
  CEGUI::ImageManager::setImagesetDefaultResourceGroup("Imagesets");
  CEGUI::Font::setDefaultResourceGroup("Fonts");
  CEGUI::Scheme::setDefaultResourceGroup("Schemes");
  CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
  CEGUI::WindowManager::setDefaultResourceGroup("Layouts");

  Ogre::LogManager::getSingletonPtr()->logMessage("    creating scheme");
  pTrayMgr->userUpdateLoadBar("Creating scheme", 0.1);
  createResources();

  pSceneManager->addRenderQueueListener(this);

  Ogre::LogManager::getSingletonPtr()->logMessage("    creating root window");
  pTrayMgr->userUpdateLoadBar("Initializing the root window", 0.1);
  CEGUI::Window *guiRoot = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MasterRoot");
  m_pRoot = guiRoot;
  //guiRoot->setAlpha(0);
  guiRoot->setSize(USize(UDim(1, 0), UDim(1, 0)));
  //guiRoot->setProperty("BackgroundEnabled", "false");
  CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(guiRoot);
  CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("OgreTrayImages/MouseArrow");
  //CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("OgreTrayImages/MouseInvisible");
  CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setPosition(CEGUI::Vector2f(0,0));
  CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setConstraintArea(NULL);


  pTrayMgr->userUpdateLoadBar("Creating fonts", 0.2);
  createFreeTypeFont("dejavusans12", 12, "DejaVuSans.ttf");
  createFreeTypeFont("dejavusans8", 8, "DejaVuSans.ttf");
  createFreeTypeFont("dejavusans20", 20, "DejaVuSans.ttf");
  CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( "dejavusans12" );
  guiRoot->setFont("dejavusans12");


  pTrayMgr->userUpdateLoadBar("Creating gui components", 0.2);
  new CGUIDebugPullMenu(this, guiRoot, CGUIPullMenu::PMD_RIGHT);

  pTrayMgr->userUpdateLoadBar("done...", 0.2);

  Sizef vSize = CGUIManager::getSingleton().getNativeRes();

  Ogre::LogManager::getSingleton().logMessage("GUIManager initialized...");
  CGame::getSingleton().hideLoadingBar();
}
bool
CGUIDriverOgre::Init( GUI::TWindowContextPtr windowContext )
{
    if ( !m_ceGuiInitialized )
    {
        try
        {
            Ogre::RenderTarget* renderTarget = nullptr;
            CORE::CString renderTargetPtrStr = windowContext->GetProperty( "Ogre::RenderTarget" );
            if ( !renderTargetPtrStr.IsNULLOrEmpty() )
            {
                renderTarget = static_cast< Ogre::RenderTarget* >( CORE::StringToPointer( renderTargetPtrStr ) );
                if ( NULL == renderTarget )
                    return false;
            }
            Ogre::SceneManager* sceneManager = nullptr;
            CORE::CString sceneManagerPtrStr = windowContext->GetProperty( "Ogre::SceneManager" );
            if ( !sceneManagerPtrStr.IsNULLOrEmpty() )
            {
                sceneManager = static_cast< Ogre::SceneManager* >( CORE::StringToPointer( sceneManagerPtrStr ) );
                if ( NULL == sceneManager )
                    return false;
            }
            
            // Auto-create a viewport here if none exists yet
            unsigned short viewportCount = renderTarget->getNumViewports();
            if ( 0 == viewportCount )
            {
                Ogre::Camera* camera = sceneManager->createCamera( "CEGUI" );
                camera->setPosition( Ogre::Vector3( 0, 0, 500 ) );
                camera->lookAt( Ogre::Vector3( 0, 0, -300 ) );
                camera->setNearClipDistance( 5 );

                // Create a viewport covering whole window
                Ogre::Viewport* viewport = renderTarget->addViewport( camera );
                viewport->setBackgroundColour( Ogre::ColourValue( 0.0f, 0.0f, 0.0f, 0.0f ) );
                viewport->setOverlaysEnabled( true );
                                                  
                // Update the camera aspect ratio to that of the viewport
                camera->setAspectRatio( Ogre::Real( viewport->getActualWidth() ) / Ogre::Real( viewport->getActualHeight() ) );                
            }

            CEGUI::Sizef displaySize( (float) windowContext->GetWidth(), (float) windowContext->GetHeight() );
            m_guiRenderer = &CEGUI::OgreRenderer::create( *renderTarget );// displaySize );//, CEGUI::OpenGLRenderer::TTT_AUTO );
            m_guiRenderer->setDefaultRootRenderTarget( *renderTarget );
            m_guiSystem = &CEGUI::System::create( *m_guiRenderer, &m_vfsResourceProvider, &m_xmlParserAdapter, m_imageCodecAdapter );

            // setup default group for validation schemas
            CEGUI::XMLParser* parser = m_guiSystem->getXMLParser();
            if ( nullptr != parser && parser->isPropertyPresent( "SchemaDefaultResourceGroup" )  )
                parser->setProperty( "SchemaDefaultResourceGroup", m_schemasResourceGroup );

            // Load the fonts
            CEGUI::FontManager::getSingleton().createAll( m_defaultFont, CEGUI::Font::getDefaultResourceGroup() );
        
            // Load the scheme
            try
            {
                CEGUI::SchemeManager::getSingleton().createFromFile( "Generic.scheme" );
            }
            catch ( CEGUI::Exception& e )
            {
                CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String();
                GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info );
            }
            CEGUI::SchemeManager::getSingleton().createFromFile( m_schemeToUse );
        
            // Set the defaults
            CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( m_defaultFont );
            CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage( m_defaultCursorImage );
            CEGUI::Window* rootWindow = CEGUI::WindowManager::getSingleton().createWindow( "DefaultWindow", "root" );
            CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow( rootWindow );
            
            // clearing this queue actually makes sure it's created(!)
            CEGUI::System::getSingleton().getDefaultGUIContext().clearGeometry( CEGUI::RQ_OVERLAY );                                             
        
            m_ceGuiInitialized = true;
        }
        catch ( CEGUI::Exception& e )
        {
            CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String();
            GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info );

            m_ceGuiInitialized = false;
        }
    }
    return m_ceGuiInitialized;
}