mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 09:53:50 +00:00
Very basic exterior water
This commit is contained in:
parent
bf09762b6a
commit
a0838369b2
6 changed files with 40 additions and 9 deletions
|
@ -84,6 +84,9 @@ MWRender::Player& RenderingManager::getPlayer(){
|
|||
|
||||
void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){
|
||||
objects.removeCell(store);
|
||||
|
||||
}
|
||||
void RenderingManager::removeWater (){
|
||||
if(mWater){
|
||||
delete mWater;
|
||||
mWater = 0;
|
||||
|
@ -120,8 +123,12 @@ 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);
|
||||
if(store->cell->data.flags & store->cell->HasWater){
|
||||
if(mWater == 0)
|
||||
mWater = new MWRender::Water(rend.getCamera(), store->cell);
|
||||
//else
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ class RenderingManager: private RenderingInterface {
|
|||
bool toggleRenderMode(int mode);
|
||||
|
||||
void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this?
|
||||
void removeWater();
|
||||
|
||||
void addObject (const MWWorld::Ptr& ptr);
|
||||
void removeObject (const MWWorld::Ptr& ptr);
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
#include "water.hpp"
|
||||
|
||||
namespace MWRender {
|
||||
Water::Water (Ogre::Camera *camera, int top) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()), mTop(top) {
|
||||
Water::Water (Ogre::Camera *camera, const ESM::Cell* cell) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()) {
|
||||
try {
|
||||
Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Water", -1);
|
||||
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
|
||||
} catch(...) {
|
||||
}
|
||||
mTop = cell->water;
|
||||
|
||||
std::cout << "Making water\n";
|
||||
mIsUnderwater = false;
|
||||
mCamera->addListener(this);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
|
||||
mWater = mSceneManager->createEntity("water");
|
||||
|
@ -23,6 +26,13 @@ namespace MWRender {
|
|||
|
||||
|
||||
mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
|
||||
|
||||
//if(!(cell->data.flags & cell->Interior))
|
||||
//{
|
||||
mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY));
|
||||
//}
|
||||
//else
|
||||
// mWaterNode->setPosition(10000, 0, 10000); //Don't mess with y
|
||||
mWaterNode->attachObject(mWater);
|
||||
|
||||
}
|
||||
|
@ -95,5 +105,10 @@ namespace MWRender {
|
|||
|
||||
void Water::cameraDestroyed(Ogre::Camera *cam) {
|
||||
}
|
||||
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));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
#define GAME_MWRENDER_WATER_H
|
||||
|
||||
#include <Ogre.h>
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
|
||||
namespace MWRender {
|
||||
|
||||
/// Water rendering
|
||||
class Water : Ogre::RenderTargetListener, Ogre::Camera::Listener {
|
||||
static const int CELL_SIZE = 8192;
|
||||
Ogre::Camera *mCamera;
|
||||
Ogre::SceneManager *mSceneManager;
|
||||
Ogre::Viewport *mViewport;
|
||||
|
@ -31,13 +32,15 @@ namespace MWRender {
|
|||
void cameraPreRenderScene(Ogre::Camera *cam);
|
||||
void cameraPostRenderScene(Ogre::Camera *cam);
|
||||
void cameraDestroyed(Ogre::Camera *cam);
|
||||
Ogre::Vector3 getSceneNodeCoordinates(int gridX, int gridY);
|
||||
|
||||
public:
|
||||
|
||||
Water (Ogre::Camera *camera, int top);
|
||||
Water (Ogre::Camera *camera, const ESM::Cell* cell);
|
||||
~Water();
|
||||
|
||||
void checkUnderwater(float y);
|
||||
void changeCell(float x, float y);
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace MWWorld
|
|||
mPhysics->removeObject (node->getName());
|
||||
}
|
||||
}
|
||||
mRendering.removeCell(active);
|
||||
|
||||
//mPhysics->removeObject("Unnamed_43");
|
||||
mWorld->getLocalScripts().clearCell (active);
|
||||
mEnvironment.mMechanicsManager->dropActors (active);
|
||||
|
@ -95,7 +95,6 @@ namespace MWWorld
|
|||
mActiveCells.insert(cell);
|
||||
if(result.second){
|
||||
insertCell(*cell, mEnvironment);
|
||||
mRendering.cellAdded (cell);
|
||||
mRendering.configureAmbient(*cell);
|
||||
|
||||
}
|
||||
|
@ -180,6 +179,7 @@ namespace MWWorld
|
|||
assert (iter!=mActiveCells.end());
|
||||
|
||||
mCurrentCell = *iter;
|
||||
std::cout << "GridX: " << mCurrentCell->cell->data.gridX << "GridY: " << mCurrentCell->cell->data.gridY << "\n";
|
||||
|
||||
// adjust player
|
||||
playerCellChange (mWorld->getExterior(X, Y), position, adjustPlayerPos);
|
||||
|
@ -188,6 +188,7 @@ namespace MWWorld
|
|||
mWorld->adjustSky();
|
||||
|
||||
mCellChanged = true;
|
||||
mRendering.cellAdded(mCurrentCell);
|
||||
}
|
||||
|
||||
//We need the ogre renderer and a scene node.
|
||||
|
@ -214,6 +215,7 @@ namespace MWWorld
|
|||
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
|
||||
{
|
||||
std::cout << "Changing to interior\n";
|
||||
mRendering.removeWater();
|
||||
// remove active
|
||||
CellStoreCollection::iterator active = mActiveCells.begin();
|
||||
|
||||
|
@ -227,6 +229,7 @@ namespace MWWorld
|
|||
Ptr::CellStore *cell = mWorld->getInterior(cellName);
|
||||
|
||||
loadCell (cell);
|
||||
|
||||
|
||||
// adjust player
|
||||
mCurrentCell = cell;
|
||||
|
@ -236,12 +239,14 @@ namespace MWWorld
|
|||
mWorld->adjustSky();
|
||||
|
||||
mCellChanged = true;
|
||||
mRendering.cellAdded(cell);
|
||||
}
|
||||
|
||||
void Scene::changeToExteriorCell (const ESM::Position& position)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
mRendering.removeWater();
|
||||
|
||||
mWorld->positionToIndex (position.pos[0], position.pos[1], x, y);
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ namespace MWWorld
|
|||
ptr.getRefData().getPosition().pos[2] = z;
|
||||
if (ptr==mPlayer->getPlayer())
|
||||
{
|
||||
//std::cout << "Current pos" << ptr.getRefData().getPosition().pos[1];
|
||||
//std::cout << "X:" << ptr.getRefData().getPosition().pos[0] << " Z: " << ptr.getRefData().getPosition().pos[1] << "\n";
|
||||
|
||||
mRendering.checkUnderwater( ptr.getRefData().getPosition().pos[2]);
|
||||
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
|
||||
|
|
Loading…
Reference in a new issue