예제 #1
0
		virtual Ogre::CompositorWorkspace* setupCompositor()
		{
			//We reuse the ShadowMapDebugging sample's workspace. Pretty handful.
			Ogre::CompositorManager2 *compositorManager = mpRoot->getCompositorManager2();
			return compositorManager->addWorkspace(mpSceneManager, mpRenderWindow, mpCamera,
				"Test2Workspace",
				//				"ShadowMapDebuggingWorkspace", // KYLE :: ORIG 
				true);
		}
예제 #2
0
	void OgreModule::initEnd()
	{
		Ogre::CompositorManager2* compositorManager = mOgreRoot.getCompositorManager2();
		compositorManager->createBasicWorkspaceDef("Basic Workspace", Ogre::ColourValue(0.15f, 0.15f, 0.15f));
		compositorManager->createBasicWorkspaceDef("Black Workspace", Ogre::ColourValue::Black);

		Ogre::MaterialManager* materialManager = Ogre::MaterialManager::getSingletonPtr();
		Ogre::MaterialPtr material = materialManager->create("debug_invisible", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		material->setReceiveShadows(false);
		Ogre::Pass* pass = material->getTechnique(0)->getPass(0);
#if OGRE_VERSION_MAJOR == 2 && OGRE_VERSION_MINOR > 0
#else
		pass->setCullingMode(Ogre::CULL_NONE);
		pass->setColourWriteEnabled(false);
		pass->setDepthWriteEnabled(false);
#endif

		this->loadResources();
	}
예제 #3
0
	void OgreModule::multiViewportWorkspace(const std::vector<OgViewport*>& viewports, Ogre::RenderTarget* target)
	{
		Ogre::CompositorManager2* compositorManager = mOgreRoot.getCompositorManager2();
		Ogre::CompositorNodeDef* nodeDef = compositorManager->addNodeDefinition("AutoGen " + (Ogre::IdString("MultiViewportWorkspace") + Ogre::IdString("/Node")).getReleaseText());

		//Input texture
		nodeDef->addTextureSourceName("WindowRT", 0, Ogre::TextureDefinitionBase::TEXTURE_INPUT);
		nodeDef->setNumTargetPass(1);
		{
			Ogre::CompositorTargetDef* targetDef = nodeDef->addTargetPass("WindowRT");
			targetDef->setNumPasses(2 * viewports.size());
			{
				for(OgViewport* viewport : viewports)
				{
					{
						Ogre::CompositorPassClearDef* passClear = static_cast<Ogre::CompositorPassClearDef*>(targetDef->addPass(Ogre::PASS_CLEAR));
						passClear->mColourValue = Ogre::ColourValue(0.3f, 0.3f, 0.3f);
						passClear->mVpWidth = viewport->width() / target->getWidth();
						passClear->mVpHeight = viewport->height() / target->getHeight();
						passClear->mVpLeft = viewport->left() / target->getWidth();
						passClear->mVpTop = viewport->top() / target->getHeight();
					}
					{
						Ogre::CompositorPassSceneDef* passScene = static_cast<Ogre::CompositorPassSceneDef*>(targetDef->addPass(Ogre::PASS_SCENE));
						//passScene->mShadowNode = Ogre::IdString();
						passScene->mVpWidth = viewport->width() / target->getWidth();
						passScene->mVpHeight = viewport->height() / target->getHeight();
						passScene->mVpLeft = viewport->left() / target->getWidth();
						passScene->mVpTop = viewport->top() / target->getHeight();
						passScene->mCameraName = viewport->ogreCamera()->getName();
					}
				}
			}
		}

		Ogre::CompositorWorkspaceDef* workDef = compositorManager->addWorkspaceDefinition("MultiViewportWorkspace");
		workDef->connectOutput(nodeDef->getName(), 0);

		for(OgViewport* viewport : viewports)
			compositorManager->addWorkspace(viewport->sceneManager(), target, viewport->ogreCamera(), "MultiViewportWorkspace", true);
	}
예제 #4
0
    //-------------------------------------------------------------------------------------
    void OgreManager::initialize(void)
    {
        // Create dummy CompositorPassProvider (see http://www.ogre3d.org/forums/viewtopic.php?f=11&t=84816&p=525752&hilit=CompositorPassProvider#p525752)
        // If one of the resource locations contains a compositor with a custom pass, the editor doesn't work anymore. This is to prevent it
        Ogre::MyCompositorPassProvider* mCompositorPassProvider = OGRE_NEW Ogre::MyCompositorPassProvider;
        Ogre::CompositorManager2* compositorManager = mRoot->getCompositorManager2();
        compositorManager->setCompositorPassProvider(mCompositorPassProvider);

        // After resources have been setup and renderwindows created (in ogre widget), the Hlms managers are registered
        registerHlms();

        // Initialise, parse scripts etc
        try
        {
            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(false);
        }
        catch (Ogre::Exception e){}
        mPause = false;
        try
        {
            mRoot->renderOneFrame(); // Render first
        }
        catch (Ogre::Exception e) {}
    }
예제 #5
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by 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 go (ODS 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 "ogre3_renderman.h"
#include "OgreConfigFile.h"
#include "OgreArchiveManager.h"
#include "OgreHlms.h"
#include "OgreHlmsUnlit.h"
#include "OgreHlmsPbs.h"
#include "OgreHlmsManager.h"
#include "OgreHlmsCommon.h"
#include "OgreLogManager.h"
#include "OgreFrameStats.h"

namespace Magus
{
    //****************************************************************************/
    OgreManager::OgreManager(void)
    {
        mGlContext = 0;
        mCompositorPassProvider = 0;
        mPause = true;

        #if _DEBUG || DEBUG
            mResourcesCfg = "resources_d.cfg";
            mPluginsCfg = "plugins_d.cfg";
        #else
            mResourcesCfg = "resources.cfg";
            mPluginsCfg = "plugins.cfg";
        #endif

        // Create Ogre tt and initialize
        mRoot = new Ogre::Root(mPluginsCfg);

        // Setup renderer
        mCurrentRenderSystem = 0;
        const Ogre::RenderSystemList& rsList = mRoot->getAvailableRenderers();
        Ogre::RenderSystem* renderSystem = rsList[0];
        std::vector<Ogre::String> renderOrder;
        #if defined(Q_OS_WIN)
            renderOrder.push_back("Direct3D11");
        #endif
            renderOrder.push_back("OpenGL 3+");
        for (std::vector<Ogre::String>::iterator iter = renderOrder.begin(); iter != renderOrder.end(); iter++)
        {
            for (Ogre::RenderSystemList::const_iterator it = rsList.begin(); it != rsList.end(); it++)
            {
                if ((*it)->getName().find(*iter) != Ogre::String::npos)
                {
                    renderSystem = *it;
                    break;
                }
            }
            if (renderSystem != 0) break;
        }

        if (renderSystem == 0)
        {
            if (!mRoot->restoreConfig())
            {
                if (!mRoot->showConfigDialog())
                    OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Abort render system configuration", "OgreManager::OgreManager");
            }
        }

        renderSystem->setConfigOption("Full Screen", "No");
        renderSystem->setConfigOption("VSync", "Yes");
        mRoot->setRenderSystem(renderSystem);
        mCurrentRenderSystem = renderSystem;

        // Uncomment next line to show dialog
        //if(mRoot->restoreConfig() || mRoot->showConfigDialog())
        //{
            mRoot->initialise(false);
        //}


        // Initialize resources
        setupResources();

        // Start timer
        mTimer = new Ogre::Timer();
        mTimer->reset();
    }

    //****************************************************************************/
    OgreManager::~OgreManager(void)
    {
        // Added removeAllWorkspaces after Ogre 2.1 upgrade (commit 2783a361c0b8)
        // In debug mode, the application crashed in deleting mRoot
        Ogre::CompositorManager2* compositorManager = mRoot->getCompositorManager2();
        compositorManager->removeAllWorkspaces();

        // Delete the dummy CompositorPassProvider
        compositorManager->setCompositorPassProvider(0);
        OGRE_DELETE mCompositorPassProvider;

        // Destroy render textures
        // This is a piece of custom code specific for the HLMS Editor (assume that the OgreWidget is still available)
        QMap<int, QOgreWidget*>::iterator i;
        QOgreWidget* item = 0;
        for (i = mQOgreWidgetMap.begin(); i != mQOgreWidgetMap.end(); ++i)
        {
            item = i.value();
            item->cleanup();
        }

        // Delete Ogre root
        delete mRoot;
    }
예제 #6
0
		void SetUpCustomContent()
		{
			Ogre::String CustomCameraName = "TestRenderTargetCamera";
			Ogre::String CustomTextureName = "TestRenderTargetTexture";
			Ogre::String CustomMaterialName = "CustomRenderTargetMaterial";
			Ogre::String CustomWorkSpaceName = "TestCustomRenderTargetWorkSpaceName";

			m_CustomRTTCamera = mSceneManager->createCamera(CustomCameraName);
			m_CustomRTTCamera->setPosition(0, 30, 0);
			m_CustomRTTCamera->lookAt(0, 0, 0);
			m_CustomRTTCamera->setFarClipDistance(1000);
			m_CustomRTTCamera->setNearClipDistance(0.1);

			m_CustomRenderTexture = Ogre::TextureManager::getSingleton().createManual(CustomTextureName, 
				Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 
				512, 512, 1, Ogre::PF_A8B8G8R8, Ogre::TU_RENDERTARGET);
			m_CustomRenderTexture->load();

			Ogre::RenderTexture* rtt = m_CustomRenderTexture->getBuffer(0)->getRenderTarget();


			Ogre::CompositorManager2 *compositorManager = mRoot->getCompositorManager2();

			const Ogre::IdString workspaceName(CustomWorkSpaceName);
			if( !compositorManager->hasWorkspaceDefinition( workspaceName ) )
			{
				compositorManager->createBasicWorkspaceDef( workspaceName, mBackgroundColour,
					Ogre::IdString() );
			}

			m_CustomRenderTarget = compositorManager->addWorkspace( mSceneManager, (Ogre::RenderTarget*)rtt, m_CustomRTTCamera,
					workspaceName, false );
			//m_CustomRenderTarget->setEnabled(false);			// not auto update
#if 0
			// create manual object
			Ogre::MaterialPtr CustomMaterial = Ogre::MaterialManager::getSingleton().create(CustomMaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
			CustomMaterial->getTechnique(0)->removeAllPasses();
			Ogre::Pass* pass = CustomMaterial->getTechnique(0)->createPass();
			Ogre::TextureUnitState* tu = pass->createTextureUnitState();
			tu->setTextureName(CustomTextureName);
#endif
			Ogre::HlmsManager *hlmsManager = Ogre::Root::getSingleton().getHlmsManager();
			Ogre::Hlms *hlms = hlmsManager->getHlms( Ogre::HLMS_UNLIT );
			Ogre::HlmsDatablock *datablock = hlms->createDatablock( CustomMaterialName, CustomMaterialName,
				Ogre::HlmsMacroblock(), Ogre::HlmsBlendblock(), Ogre::HlmsParamVec() );
			Ogre::HlmsUnlitDatablock *unlitDb = static_cast<Ogre::HlmsUnlitDatablock*>( datablock );
			unlitDb->setTexture( 0, 0, m_CustomRenderTexture );
			
#if 1
			Ogre::ManualObject* CustomManualObject = mSceneManager->createManualObject();
			CustomManualObject->begin(CustomMaterialName);
			CustomManualObject->position(-100, -100, -100);
			CustomManualObject->textureCoord(0, 0);
			CustomManualObject->position(100, -100, -100);
			CustomManualObject->textureCoord(1, 0);
			CustomManualObject->position(100, 100, -100);
			CustomManualObject->textureCoord(1, 1);
			CustomManualObject->position(-100, 100, -100);
			CustomManualObject->textureCoord(0, 1);
			CustomManualObject->quad(0, 1, 2, 3);
			CustomManualObject->end();
//			CustomManualObject->setDatablock(0, CustomMaterialName);

			Ogre::SceneNode *sceneNodeLines = mSceneManager->getRootSceneNode( Ogre::SCENE_DYNAMIC )->
				createChildSceneNode( Ogre::SCENE_DYNAMIC );
			sceneNodeLines->attachObject(CustomManualObject);
			sceneNodeLines->scale(0.4f, 0.4f, 0.4f);
			sceneNodeLines->translate(0.0f, 0.0f, 0.0f, Ogre::SceneNode::TS_WORLD);
#endif
		}
예제 #7
0
 virtual Ogre::CompositorWorkspace* setupCompositor()
 {
     Ogre::CompositorManager2 *compositorManager = mRoot->getCompositorManager2();
     return compositorManager->addWorkspace( mSceneManager, mRenderWindow, mCamera,
                                             "PbsMaterialsWorkspace", true );
 }