mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Correct water levels
This commit is contained in:
parent
ff2bbc9fc5
commit
2aad3a0bd8
5 changed files with 32 additions and 13 deletions
|
@ -57,7 +57,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
cameraPitchNode->attachObject(rend.getCamera());
|
||||
|
||||
mPlayer = new MWRender::Player (rend.getCamera(), playerNode);
|
||||
mWater = new MWRender::Water(rend.getCamera());
|
||||
mWater = 0;
|
||||
|
||||
//std::cout << "Three";
|
||||
}
|
||||
|
@ -84,6 +84,10 @@ MWRender::Player& RenderingManager::getPlayer(){
|
|||
|
||||
void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){
|
||||
objects.removeCell(store);
|
||||
if(mWater){
|
||||
delete mWater;
|
||||
mWater = 0;
|
||||
}
|
||||
}
|
||||
void RenderingManager::addObject (const MWWorld::Ptr& ptr){
|
||||
const MWWorld::Class& class_ =
|
||||
|
@ -114,6 +118,11 @@ bool RenderingManager::getPhysicsDebugRendering() const{
|
|||
void RenderingManager::update (float duration){
|
||||
|
||||
|
||||
}
|
||||
void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store){
|
||||
if(store->cell->data.flags & store->cell->HasWater)
|
||||
mWater = new MWRender::Water(rend.getCamera(), store->cell->water);
|
||||
|
||||
}
|
||||
|
||||
void RenderingManager::skyEnable ()
|
||||
|
@ -222,7 +231,9 @@ void RenderingManager::toggleLight()
|
|||
setAmbientMode();
|
||||
}
|
||||
void RenderingManager::checkUnderwater(){
|
||||
mWater->checkUnderwater();
|
||||
if(mWater){
|
||||
mWater->checkUnderwater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ class RenderingManager: private RenderingInterface {
|
|||
virtual MWRender::Creatures& getCreatures();
|
||||
virtual MWRender::Objects& getObjects();
|
||||
virtual MWRender::Player& getPlayer();
|
||||
void cellAdded (MWWorld::Ptr::CellStore *store);
|
||||
|
||||
void toggleLight();
|
||||
bool toggleRenderMode(int mode);
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
#include "water.hpp"
|
||||
|
||||
namespace MWRender {
|
||||
Water::Water (Ogre::Camera *camera) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()) {
|
||||
std::cout << "1\n";
|
||||
Water::Water (Ogre::Camera *camera, int top) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()) {
|
||||
try {
|
||||
Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Water", -1);
|
||||
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
|
||||
} catch(...) {
|
||||
}
|
||||
mIsUnderwater = false;
|
||||
|
||||
mCamera->addListener(this);
|
||||
|
||||
|
||||
mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, 0);
|
||||
Ogre::MeshManager::getSingleton().createPlane("water", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, 7000, 7000, 1, 1, true, 1, 3,5, Ogre::Vector3::UNIT_Z);
|
||||
|
||||
mWater = mSceneManager->createEntity("Water", "water");
|
||||
mWater->setMaterialName("Examples/Water0");
|
||||
mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, top);
|
||||
Ogre::MeshManager::getSingleton().createPlane("water", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, 14000, 14000, 1, 1, true, 1, 3,5, Ogre::Vector3::UNIT_Z);
|
||||
|
||||
|
||||
mWater = mSceneManager->createEntity("water");
|
||||
mWater->setMaterialName("Examples/Water0");
|
||||
|
||||
|
||||
|
||||
|
||||
mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
|
||||
mWaterNode->attachObject(mWater);
|
||||
|
@ -26,6 +27,12 @@ namespace MWRender {
|
|||
|
||||
|
||||
Water::~Water() {
|
||||
mCamera->removeListener(this);
|
||||
|
||||
mWaterNode->detachObject(mWater);
|
||||
mSceneManager->destroyEntity(mWater);
|
||||
mSceneManager->destroySceneNode(mWaterNode);
|
||||
|
||||
Ogre::MeshManager::getSingleton().remove("water");
|
||||
//Ogre::TextureManager::getSingleton().remove("refraction");
|
||||
//Ogre::TextureManager::getSingleton().remove("reflection");
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace MWRender {
|
|||
|
||||
public:
|
||||
|
||||
Water (Ogre::Camera *camera);
|
||||
Water (Ogre::Camera *camera, int top);
|
||||
~Water();
|
||||
|
||||
void checkUnderwater();
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace MWWorld
|
|||
mActiveCells.insert(cell);
|
||||
if(result.second){
|
||||
insertCell(*cell, mEnvironment);
|
||||
//mRendering.cellAdded (cell);
|
||||
mRendering.cellAdded (cell);
|
||||
mRendering.configureAmbient(*cell);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue