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(); }
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 }