示例#1
0
文件: scene.cpp 项目: emoose/openmw
    void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
    {
        std::cout << "Changing to interior\n";


        bool loadcell = (mCurrentCell == NULL);
        if(!loadcell)
        {
            std::string nam = std::string(cellName);
            std::string curnam = std::string(mCurrentCell->cell->mName);
            std::transform(nam.begin(), nam.end(), nam.begin(), ::tolower);
            std::transform(curnam.begin(), curnam.end(), curnam.begin(), ::tolower);
            loadcell = nam != curnam;
        }
        if(loadcell)
        {
            CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName);

            // remove active
            CellStoreCollection::iterator active = mActiveCells.begin();

            // count number of cells to unload
            int numUnload = 0;
            while (active!=mActiveCells.end())
            {
                ++active;
                ++numUnload;
            }

            // unload
            int current = 0;
            active = mActiveCells.begin();
            while (active!=mActiveCells.end())
            {
                MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);

                unloadCell (active++);
                ++current;
            }

            // Load cell.
            std::cout << "cellName:" << cellName << std::endl;


            MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1);
            loadCell (cell);

            mCurrentCell = cell;

            // adjust fog
            mRendering.switchToInterior();
            mRendering.configureFog(*cell);
        }
        // adjust player
        playerCellChange (mCurrentCell, position);
        
        // Sky system
        MWBase::Environment::get().getWorld()->adjustSky();

        mCellChanged = true;

        MWBase::Environment::get().getWindowManager ()->loadingDone ();
    }
示例#2
0
文件: scene.cpp 项目: 0xmono/openmw
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
{
    Nif::NIFFile::CacheLock lock;
    MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0.5);

    Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen();
    Loading::ScopedLoad load(loadingListener);

    mRendering.enableTerrain(false);

    std::string loadingInteriorText = "#{sLoadingMessage2}";
    loadingListener->setLabel(loadingInteriorText);

    CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName);
    bool loadcell = (mCurrentCell == NULL);
    if(!loadcell)
        loadcell = *mCurrentCell != *cell;

    if(!loadcell)
    {
        MWBase::World *world = MWBase::Environment::get().getWorld();
        world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]);

        float x = Ogre::Radian(position.rot[0]).valueDegrees();
        float y = Ogre::Radian(position.rot[1]).valueDegrees();
        float z = Ogre::Radian(position.rot[2]).valueDegrees();
        world->rotateObject(world->getPlayerPtr(), x, y, z);

        world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr());
        world->getFader()->fadeIn(0.5f);
        return;
    }

    std::cout << "Changing to interior\n";

    // remove active
    CellStoreCollection::iterator active = mActiveCells.begin();

    // count number of cells to unload
    int numUnload = 0;
    while (active!=mActiveCells.end())
    {
        ++active;
        ++numUnload;
    }

    // unload
    int current = 0;
    active = mActiveCells.begin();
    while (active!=mActiveCells.end())
    {
        unloadCell (active++);
        ++current;
    }

    int refsToLoad = cell->count();
    loadingListener->setProgressRange(refsToLoad);

    // Load cell.
    std::cout << "cellName: " << cell->getCell()->mName << std::endl;

    //Loading Interior loading text

    loadCell (cell, loadingListener);

    mCurrentCell = cell;

    // adjust fog
    mRendering.configureFog(*mCurrentCell);

    // adjust player
    playerCellChange (mCurrentCell, position);

    // Sky system
    MWBase::Environment::get().getWorld()->adjustSky();

    mCellChanged = true;
    MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(0.5);

    loadingListener->removeWallpaper();
}
示例#3
0
文件: scene.cpp 项目: emoose/openmw
    void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
    {
        mRendering.preCellChange(mCurrentCell);

        // remove active
        MWBase::Environment::get().getMechanicsManager()->removeActor (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());

        CellStoreCollection::iterator active = mActiveCells.begin();

        // get the number of cells to unload
        int numUnload = 0;
        while (active!=mActiveCells.end())
        {
            if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior))
            {
                if (std::abs (X-(*active)->cell->mData.mX)<=1 &&
                    std::abs (Y-(*active)->cell->mData.mY)<=1)
                {
                    // keep cells within the new 3x3 grid
                    ++active;
                    continue;
                }
            }
            ++active;
            ++numUnload;
        }

        int current = 0;
        active = mActiveCells.begin();
        while (active!=mActiveCells.end())
        {
            if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior))
            {
                if (std::abs (X-(*active)->cell->mData.mX)<=1 &&
                    std::abs (Y-(*active)->cell->mData.mY)<=1)
                {
                    // keep cells within the new 3x3 grid
                    ++active;
                    continue;
                }
            }

            MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);
            unloadCell (active++);
            ++current;
        }

        int numLoad = 0;
        // get the number of cells to load
        for (int x=X-1; x<=X+1; ++x)
            for (int y=Y-1; y<=Y+1; ++y)
            {
                CellStoreCollection::iterator iter = mActiveCells.begin();

                while (iter!=mActiveCells.end())
                {
                    assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior));

                    if (x==(*iter)->cell->mData.mX &&
                        y==(*iter)->cell->mData.mY)
                        break;

                    ++iter;
                }

                if (iter==mActiveCells.end())
                    ++numLoad;
            }

        // Load cells
        current = 0;
        for (int x=X-1; x<=X+1; ++x)
            for (int y=Y-1; y<=Y+1; ++y)
            {
                CellStoreCollection::iterator iter = mActiveCells.begin();

                while (iter!=mActiveCells.end())
                {
                    assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior));

                    if (x==(*iter)->cell->mData.mX &&
                        y==(*iter)->cell->mData.mY)
                        break;

                    ++iter;
                }

                if (iter==mActiveCells.end())
                {
                    CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y);

                    MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, current, numLoad);
                    loadCell (cell);
                    ++current;
                }
            }

        // find current cell
        CellStoreCollection::iterator iter = mActiveCells.begin();

        while (iter!=mActiveCells.end())
        {
            assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior));

            if (X==(*iter)->cell->mData.mX &&
                Y==(*iter)->cell->mData.mY)
                break;

            ++iter;
        }

        assert (iter!=mActiveCells.end());

        mCurrentCell = *iter;

        // adjust player
        playerCellChange (mCurrentCell, position, adjustPlayerPos);

        // Sky system
        MWBase::Environment::get().getWorld()->adjustSky();

        mRendering.switchToExterior();

        mCellChanged = true;

        MWBase::Environment::get().getWindowManager ()->loadingDone ();
    }
示例#4
0
文件: scene.cpp 项目: 0xmono/openmw
void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
{
    Nif::NIFFile::CacheLock cachelock;

    Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen();
    Loading::ScopedLoad load(loadingListener);

    mRendering.enableTerrain(true);

    std::string loadingExteriorText = "#{sLoadingMessage3}";
    loadingListener->setLabel(loadingExteriorText);

    CellStoreCollection::iterator active = mActiveCells.begin();

    // get the number of cells to unload
    int numUnload = 0;
    while (active!=mActiveCells.end())
    {
        if ((*active)->getCell()->isExterior())
        {
            if (std::abs (X-(*active)->getCell()->getGridX())<=1 &&
                    std::abs (Y-(*active)->getCell()->getGridY())<=1)
            {
                // keep cells within the new 3x3 grid
                ++active;
                continue;
            }
        }
        ++active;
        ++numUnload;
    }

    active = mActiveCells.begin();
    while (active!=mActiveCells.end())
    {
        if ((*active)->getCell()->isExterior())
        {
            if (std::abs (X-(*active)->getCell()->getGridX())<=1 &&
                    std::abs (Y-(*active)->getCell()->getGridY())<=1)
            {
                // keep cells within the new 3x3 grid
                ++active;
                continue;
            }
        }
        unloadCell (active++);
    }

    int refsToLoad = 0;
    // get the number of refs to load
    for (int x=X-1; x<=X+1; ++x)
        for (int y=Y-1; y<=Y+1; ++y)
        {
            CellStoreCollection::iterator iter = mActiveCells.begin();

            while (iter!=mActiveCells.end())
            {
                assert ((*iter)->getCell()->isExterior());

                if (x==(*iter)->getCell()->getGridX() &&
                        y==(*iter)->getCell()->getGridY())
                    break;

                ++iter;
            }

            if (iter==mActiveCells.end())
                refsToLoad += MWBase::Environment::get().getWorld()->getExterior(x, y)->count();
        }

    loadingListener->setProgressRange(refsToLoad);

    // Load cells
    for (int x=X-1; x<=X+1; ++x)
        for (int y=Y-1; y<=Y+1; ++y)
        {
            CellStoreCollection::iterator iter = mActiveCells.begin();

            while (iter!=mActiveCells.end())
            {
                assert ((*iter)->getCell()->isExterior());

                if (x==(*iter)->getCell()->getGridX() &&
                        y==(*iter)->getCell()->getGridY())
                    break;

                ++iter;
            }

            if (iter==mActiveCells.end())
            {
                CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y);

                loadCell (cell, loadingListener);
            }
        }

    // find current cell
    CellStoreCollection::iterator iter = mActiveCells.begin();

    while (iter!=mActiveCells.end())
    {
        assert ((*iter)->getCell()->isExterior());

        if (X==(*iter)->getCell()->getGridX() &&
                Y==(*iter)->getCell()->getGridY())
            break;

        ++iter;
    }

    assert (iter!=mActiveCells.end());

    mCurrentCell = *iter;

    // adjust player
    playerCellChange (mCurrentCell, position, adjustPlayerPos);

    // Sky system
    MWBase::Environment::get().getWorld()->adjustSky();

    mCellChanged = true;

    loadingListener->removeWallpaper();
}