예제 #1
0
파일: manager.cpp 프로젝트: jhooks1/openmw
    void setSceneManager(Ogre::SceneManager* _scene)
    {
        if (nullptr != mSceneManager)
        {
            mSceneManager->removeRenderQueueListener(this);
            mSceneManager = nullptr;
        }

        mSceneManager = _scene;

        if (nullptr != mSceneManager)
        {
            mSceneManager->addRenderQueueListener(this);
        }
    }
예제 #2
0
void ApplicationContext::createDummyScene()
{
    mWindow->removeAllViewports();
    Ogre::SceneManager* sm = mRoot->createSceneManager(Ogre::ST_GENERIC, "DummyScene");
    sm->addRenderQueueListener(mOverlaySystem);
    Ogre::Camera* cam = sm->createCamera("DummyCamera");
    mWindow->addViewport(cam);
#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM
    // Initialize shader generator.
    // Must be before resource loading in order to allow parsing extended material attributes.
    if (!initialiseRTShaderSystem())
    {
        OGRE_EXCEPT(Ogre::Exception::ERR_FILE_NOT_FOUND,
                    "Shader Generator Initialization failed - Core shader libs path not found",
                    "ApplicationContext::createDummyScene");
    }

    mShaderGenerator->addSceneManager(sm);
#endif // OGRE_BUILD_COMPONENT_RTSHADERSYSTEM
}
void EC_MeshmoonWater::CreateOcean()
{
#ifdef MESHMOON_TRITON
    if (!visible.Get() || state_.ocean)
        return;

    Ogre::SceneManager *ogreSceneManager = OgreSceneManager();
    if (!ogreSceneManager)
    {
        LogError(LC + "Failed to initialize Triton library, renderer not available!");
        return;
    }

    OgreRendererPtr renderer = Renderer();
    if (!renderer)
        return;

    // On Windows assuming we're using D3D9, but fall back to OpenGL if that's not the case.
    void* d3dDevice = 0;
#ifdef DIRECTX_ENABLED
    Ogre::D3D9RenderWindow* renderWindow = dynamic_cast<Ogre::D3D9RenderWindow*>(renderer->GetCurrentRenderWindow());
    if (renderWindow)
        d3dDevice = renderWindow->getD3D9Device();
#endif

    state_.environment = new Triton::Environment();
    state_.environment->SetLicenseCode(TRITON_USERNAME, TRITON_LICENCE_KEY);

    QString resourcePath = QDir::toNativeSeparators(QDir(Application::InstallationDirectory()).absoluteFilePath("media/meshmoon/triton"));
    state_.resourceLoader = new Triton::ResourceLoader(resourcePath.toStdString().c_str());

    Triton::EnvironmentError error = state_.environment->Initialize(Triton::FLAT_YUP,
        d3dDevice == 0 ? Triton::OPENGL_2_0 : Triton::DIRECTX_9,
        state_.resourceLoader, d3dDevice);
    if (error != Triton::SUCCEEDED)
    {
        LogError(LC + "Error while initializing Triton.");
        return;
    }

    // Create ocean.
    if (!state_.Setup(Triton::Ocean::Create(state_.environment, static_cast<Triton::WaterModelTypes>(simulationModel.Get()+1), enableHeightQueries.Get()),
            static_cast<SimulationModel>(simulationModel.Get()), reflectionsEnabled.Get(), enableHeightQueries.Get()))
    {
        LogError(LC + "Failed to create Triton ocean!");
        DestroyOcean();
        return;
    }
    
    // Set attributes
    state_.ocean->EnableSpray(sprayEnabled.Get());
    state_.ocean->EnableWireframe(drawDebug.Get());
    state_.ocean->SetChoppiness(waveChoppiness.Get());
    state_.ocean->SetRefractionColor(ToTritonVector3(waterColor.Get()));
    state_.environment->SetSeaLevel(seaLevel.Get());
    
    UpdateWeatherConditions();
    
    // Add listeners to render ocean in right time.
    renderQueueListener_ = new MeshmoonWaterRenderQueueListener(this, 0xFFFFFFF0);
    renderSystemListener_ = new MeshmoonWaterRenderSystemListener(this);
    renderTargetListener_ = new MeshmoonWaterRenderTargetListener(this);

    ogreSceneManager->addRenderQueueListener(renderQueueListener_);
    ogreSceneManager->getRenderQueue()->getQueueGroup(renderQueueListener_->renderQueueId); // Registers our custom queue id to be executed.
    Ogre::Root::getSingleton().getRenderSystem()->addListener(renderSystemListener_);
#endif
}
void application::choose_scene_mgr()
{
    scene_mgr = root->createSceneManager(Ogre::ST_GENERIC);
    overlay = new Ogre::OverlaySystem();
    scene_mgr->addRenderQueueListener(overlay);
}