mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
underwater view
This commit is contained in:
parent
2aad3a0bd8
commit
84f45b1972
6 changed files with 18 additions and 18 deletions
|
@ -310,9 +310,7 @@ void OMW::Engine::go()
|
|||
|
||||
// This has to be added BEFORE MyGUI is initialized, as it needs
|
||||
// to find core.xml here.
|
||||
std::cout << "Before the water\n";
|
||||
|
||||
std::cout << "After the water" << mResDir << "\n";
|
||||
//addResourcesDirectory(mResDir);
|
||||
|
||||
addResourcesDirectory(mResDir / "mygui");
|
||||
|
|
|
@ -230,9 +230,9 @@ void RenderingManager::toggleLight()
|
|||
|
||||
setAmbientMode();
|
||||
}
|
||||
void RenderingManager::checkUnderwater(){
|
||||
void RenderingManager::checkUnderwater(float y){
|
||||
if(mWater){
|
||||
mWater->checkUnderwater();
|
||||
mWater->checkUnderwater(y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class RenderingManager: private RenderingInterface {
|
|||
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
|
||||
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
|
||||
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).
|
||||
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "water.hpp"
|
||||
|
||||
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 {
|
||||
Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Water", -1);
|
||||
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
|
||||
|
@ -10,11 +10,13 @@ namespace MWRender {
|
|||
mIsUnderwater = false;
|
||||
mCamera->addListener(this);
|
||||
|
||||
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);
|
||||
mWaterPlane = Ogre::Plane(Ogre::Vector3::UNIT_Y, mTop);
|
||||
|
||||
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->setMaterialName("Examples/Water0");
|
||||
|
||||
|
||||
|
@ -58,24 +60,22 @@ namespace MWRender {
|
|||
}
|
||||
}
|
||||
|
||||
void Water::checkUnderwater() {
|
||||
Ogre::Vector3 pos = mCamera->getPosition();
|
||||
if (mIsUnderwater && pos.y > 0) {
|
||||
void Water::checkUnderwater(float y) {
|
||||
|
||||
if (mIsUnderwater && y > mTop) {
|
||||
try {
|
||||
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
|
||||
} catch(...) {
|
||||
}
|
||||
std::cout << "Removing water compositor" << "\n";
|
||||
mIsUnderwater = false;
|
||||
}
|
||||
|
||||
if (!mIsUnderwater && pos.y < 0) {
|
||||
if (!mIsUnderwater && y < mTop) {
|
||||
try {
|
||||
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", true);
|
||||
} catch(...) {
|
||||
}
|
||||
mIsUnderwater = true;
|
||||
std::cout << "Adding water compositor" << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace MWRender {
|
|||
|
||||
Ogre::Vector3 mOldCameraPos;
|
||||
bool mIsUnderwater;
|
||||
int mTop;
|
||||
|
||||
|
||||
|
||||
|
@ -36,7 +37,7 @@ namespace MWRender {
|
|||
Water (Ogre::Camera *camera, int top);
|
||||
~Water();
|
||||
|
||||
void checkUnderwater();
|
||||
void checkUnderwater(float y);
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -522,10 +522,11 @@ namespace MWWorld
|
|||
ptr.getRefData().getPosition().pos[0] = x;
|
||||
ptr.getRefData().getPosition().pos[1] = y;
|
||||
ptr.getRefData().getPosition().pos[2] = z;
|
||||
|
||||
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();
|
||||
if (currentCell)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue