1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 03:53:52 +00:00

underwater view

This commit is contained in:
Jason Hooks 2012-01-20 17:59:56 -05:00
parent 2aad3a0bd8
commit 84f45b1972
6 changed files with 18 additions and 18 deletions

View file

@ -310,9 +310,7 @@ void OMW::Engine::go()
// This has to be added BEFORE MyGUI is initialized, as it needs // This has to be added BEFORE MyGUI is initialized, as it needs
// to find core.xml here. // to find core.xml here.
std::cout << "Before the water\n";
std::cout << "After the water" << mResDir << "\n";
//addResourcesDirectory(mResDir); //addResourcesDirectory(mResDir);
addResourcesDirectory(mResDir / "mygui"); addResourcesDirectory(mResDir / "mygui");

View file

@ -230,9 +230,9 @@ void RenderingManager::toggleLight()
setAmbientMode(); setAmbientMode();
} }
void RenderingManager::checkUnderwater(){ void RenderingManager::checkUnderwater(float y){
if(mWater){ if(mWater){
mWater->checkUnderwater(); mWater->checkUnderwater(y);
} }
} }

View file

@ -71,7 +71,7 @@ class RenderingManager: private RenderingInterface {
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position); void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale); void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation); void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation);
void checkUnderwater(); void checkUnderwater(float y);
/// \param store Cell the object was in previously (\a ptr has already been updated to the new cell). /// \param store Cell the object was in previously (\a ptr has already been updated to the new cell).
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store); void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);

View file

@ -1,7 +1,7 @@
#include "water.hpp" #include "water.hpp"
namespace MWRender { namespace MWRender {
Water::Water (Ogre::Camera *camera, int top) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()) { Water::Water (Ogre::Camera *camera, int top) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()), mTop(top) {
try { try {
Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Water", -1); Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Water", -1);
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false); Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
@ -10,11 +10,13 @@ namespace MWRender {
mIsUnderwater = false; mIsUnderwater = false;
mCamera->addListener(this); mCamera->addListener(this);
mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, top); mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, mTop);
Ogre::MeshManager::getSingleton().createPlane("water", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, 14000, 14000, 1, 1, true, 1, 3,5, Ogre::Vector3::UNIT_Z);
Ogre::MeshManager::getSingleton().createPlane("water", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, 14000, 14000, 10, 10, true, 1, 3,5, Ogre::Vector3::UNIT_Z);
mWater = mSceneManager->createEntity("water"); mWater = mSceneManager->createEntity("water");
mWater->setMaterialName("Examples/Water0"); mWater->setMaterialName("Examples/Water0");
@ -58,24 +60,22 @@ namespace MWRender {
} }
} }
void Water::checkUnderwater() { void Water::checkUnderwater(float y) {
Ogre::Vector3 pos = mCamera->getPosition();
if (mIsUnderwater && pos.y > 0) { if (mIsUnderwater && y > mTop) {
try { try {
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false); Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
} catch(...) { } catch(...) {
} }
std::cout << "Removing water compositor" << "\n";
mIsUnderwater = false; mIsUnderwater = false;
} }
if (!mIsUnderwater && pos.y < 0) { if (!mIsUnderwater && y < mTop) {
try { try {
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", true); Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", true);
} catch(...) { } catch(...) {
} }
mIsUnderwater = true; mIsUnderwater = true;
std::cout << "Adding water compositor" << "\n";
} }
} }

View file

@ -21,6 +21,7 @@ namespace MWRender {
Ogre::Vector3 mOldCameraPos; Ogre::Vector3 mOldCameraPos;
bool mIsUnderwater; bool mIsUnderwater;
int mTop;
@ -36,7 +37,7 @@ namespace MWRender {
Water (Ogre::Camera *camera, int top); Water (Ogre::Camera *camera, int top);
~Water(); ~Water();
void checkUnderwater(); void checkUnderwater(float y);
}; };

View file

@ -522,10 +522,11 @@ namespace MWWorld
ptr.getRefData().getPosition().pos[0] = x; ptr.getRefData().getPosition().pos[0] = x;
ptr.getRefData().getPosition().pos[1] = y; ptr.getRefData().getPosition().pos[1] = y;
ptr.getRefData().getPosition().pos[2] = z; ptr.getRefData().getPosition().pos[2] = z;
if (ptr==mPlayer->getPlayer()) if (ptr==mPlayer->getPlayer())
{ {
mRendering.checkUnderwater(); //std::cout << "Current pos" << ptr.getRefData().getPosition().pos[1];
mRendering.checkUnderwater( ptr.getRefData().getPosition().pos[2]);
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
if (currentCell) if (currentCell)
{ {