mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 21:53:52 +00:00
Switching cells in exterior works
This commit is contained in:
parent
ec94ecacaf
commit
e1aba44da6
4 changed files with 21 additions and 7 deletions
|
@ -133,9 +133,13 @@ void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){
|
||||||
if(store->cell->data.flags & store->cell->HasWater){
|
if(store->cell->data.flags & store->cell->HasWater){
|
||||||
if(mWater == 0)
|
if(mWater == 0)
|
||||||
mWater = new MWRender::Water(rend.getCamera(), store->cell);
|
mWater = new MWRender::Water(rend.getCamera(), store->cell);
|
||||||
|
else
|
||||||
|
mWater->changeCell(store->cell);
|
||||||
//else
|
//else
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
removeWater();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ namespace MWRender {
|
||||||
|
|
||||||
|
|
||||||
mIsUnderwater = false;
|
mIsUnderwater = false;
|
||||||
mCamera->addListener(this);
|
//mCamera->addListener(this);
|
||||||
|
|
||||||
mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, mTop);
|
mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, 0);
|
||||||
|
|
||||||
Ogre::MeshManager::getSingleton().createPlane("water", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, CELL_SIZE*3 + 10000, CELL_SIZE * 3 + 10000, 10, 10, true, 1, 3,5, Ogre::Vector3::UNIT_Z);
|
Ogre::MeshManager::getSingleton().createPlane("water", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, CELL_SIZE*3 + 10000, CELL_SIZE * 3 + 10000, 10, 10, true, 1, 3,5, Ogre::Vector3::UNIT_Z);
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ namespace MWRender {
|
||||||
|
|
||||||
|
|
||||||
mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
|
mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
|
||||||
|
mWaterNode->setPosition(0, mTop, 0);
|
||||||
|
|
||||||
|
|
||||||
if(!(cell->data.flags & cell->Interior))
|
if(!(cell->data.flags & cell->Interior))
|
||||||
|
@ -40,7 +41,7 @@ namespace MWRender {
|
||||||
|
|
||||||
Water::~Water() {
|
Water::~Water() {
|
||||||
Ogre::MeshManager::getSingleton().remove("water");
|
Ogre::MeshManager::getSingleton().remove("water");
|
||||||
mCamera->removeListener(this);
|
//mCamera->removeListener(this);
|
||||||
|
|
||||||
mWaterNode->detachObject(mWater);
|
mWaterNode->detachObject(mWater);
|
||||||
mSceneManager->destroyEntity(mWater);
|
mSceneManager->destroyEntity(mWater);
|
||||||
|
@ -51,6 +52,17 @@ namespace MWRender {
|
||||||
Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
|
Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Water::changeCell(const ESM::Cell* cell){
|
||||||
|
mTop = cell->water;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!(cell->data.flags & cell->Interior))
|
||||||
|
mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY));
|
||||||
|
else
|
||||||
|
mWaterNode->setPosition(0, mTop, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Water::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) {
|
void Water::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) {
|
||||||
mWater->setVisible(false);
|
mWater->setVisible(false);
|
||||||
|
@ -106,7 +118,7 @@ namespace MWRender {
|
||||||
void Water::cameraDestroyed(Ogre::Camera *cam) {
|
void Water::cameraDestroyed(Ogre::Camera *cam) {
|
||||||
}
|
}
|
||||||
Ogre::Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY){
|
Ogre::Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY){
|
||||||
Ogre::Vector3 out = Ogre::Vector3(gridX * CELL_SIZE + (CELL_SIZE / 2), 0, -gridY * CELL_SIZE - (CELL_SIZE / 2));
|
Ogre::Vector3 out = Ogre::Vector3(gridX * CELL_SIZE + (CELL_SIZE / 2), mTop, -gridY * CELL_SIZE - (CELL_SIZE / 2));
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace MWRender {
|
||||||
~Water();
|
~Water();
|
||||||
|
|
||||||
void checkUnderwater(float y);
|
void checkUnderwater(float y);
|
||||||
void changeCell(float x, float y);
|
void changeCell(const ESM::Cell* cell);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -218,7 +218,6 @@ namespace MWWorld
|
||||||
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
|
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
|
||||||
{
|
{
|
||||||
std::cout << "Changing to interior\n";
|
std::cout << "Changing to interior\n";
|
||||||
mRendering.removeWater();
|
|
||||||
// remove active
|
// remove active
|
||||||
CellStoreCollection::iterator active = mActiveCells.begin();
|
CellStoreCollection::iterator active = mActiveCells.begin();
|
||||||
|
|
||||||
|
@ -250,7 +249,6 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
mRendering.removeWater();
|
|
||||||
|
|
||||||
mWorld->positionToIndex (position.pos[0], position.pos[1], x, y);
|
mWorld->positionToIndex (position.pos[0], position.pos[1], x, y);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue