2015-06-02 14:35:35 +00:00
|
|
|
#ifndef OPENMW_MWRENDER_WATER_H
|
|
|
|
#define OPENMW_MWRENDER_WATER_H
|
2012-01-14 23:34:14 +00:00
|
|
|
|
2015-11-03 01:17:42 +00:00
|
|
|
#include <memory>
|
2016-02-09 00:17:02 +00:00
|
|
|
#include <vector>
|
2015-11-03 01:17:42 +00:00
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
#include <osg/ref_ptr>
|
2015-11-03 01:17:42 +00:00
|
|
|
#include <osg/Vec3f>
|
2017-10-16 17:47:08 +00:00
|
|
|
#include <osg/Uniform>
|
2017-11-10 18:18:16 +00:00
|
|
|
#include <osg/Camera>
|
2012-07-03 13:32:38 +00:00
|
|
|
|
2015-10-28 20:22:14 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
namespace osg
|
2012-07-03 13:32:38 +00:00
|
|
|
{
|
2015-06-02 14:35:35 +00:00
|
|
|
class Group;
|
|
|
|
class PositionAttitudeTransform;
|
2016-03-10 12:17:01 +00:00
|
|
|
class Geometry;
|
2015-10-28 19:24:52 +00:00
|
|
|
class Node;
|
2012-10-09 15:10:25 +00:00
|
|
|
}
|
2012-05-29 04:45:44 +00:00
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
namespace osgUtil
|
|
|
|
{
|
|
|
|
class IncrementalCompileOperation;
|
|
|
|
}
|
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
namespace Resource
|
2015-02-09 18:28:29 +00:00
|
|
|
{
|
2015-06-02 14:35:35 +00:00
|
|
|
class ResourceSystem;
|
2015-02-09 18:28:29 +00:00
|
|
|
}
|
|
|
|
|
2015-06-16 18:36:48 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2015-11-03 01:17:42 +00:00
|
|
|
class CellStore;
|
|
|
|
class Ptr;
|
2015-06-16 18:36:48 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 11:46:06 +00:00
|
|
|
namespace Fallback
|
|
|
|
{
|
|
|
|
class Map;
|
|
|
|
}
|
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2013-01-16 08:13:36 +00:00
|
|
|
|
2015-10-28 18:57:58 +00:00
|
|
|
class Refraction;
|
|
|
|
class Reflection;
|
2015-06-16 18:36:48 +00:00
|
|
|
class RippleSimulation;
|
|
|
|
|
2012-07-03 13:32:38 +00:00
|
|
|
/// Water rendering
|
2015-06-02 14:35:35 +00:00
|
|
|
class Water
|
2012-03-29 16:33:08 +00:00
|
|
|
{
|
2017-10-16 22:13:55 +00:00
|
|
|
osg::ref_ptr<osg::Uniform> mRainIntensityUniform;
|
2017-10-16 17:47:08 +00:00
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
osg::ref_ptr<osg::Group> mParent;
|
2015-10-26 20:36:19 +00:00
|
|
|
osg::ref_ptr<osg::Group> mSceneRoot;
|
2015-06-02 14:35:35 +00:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mWaterNode;
|
2016-03-10 12:17:01 +00:00
|
|
|
osg::ref_ptr<osg::Geometry> mWaterGeom;
|
2015-06-02 14:35:35 +00:00
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
2015-06-02 23:18:36 +00:00
|
|
|
osg::ref_ptr<osgUtil::IncrementalCompileOperation> mIncrementalCompileOperation;
|
2012-01-14 23:34:14 +00:00
|
|
|
|
2017-04-28 15:30:26 +00:00
|
|
|
std::unique_ptr<RippleSimulation> mSimulation;
|
2015-06-16 18:36:48 +00:00
|
|
|
|
2015-10-28 18:57:58 +00:00
|
|
|
osg::ref_ptr<Refraction> mRefraction;
|
|
|
|
osg::ref_ptr<Reflection> mReflection;
|
|
|
|
|
2015-10-28 19:24:52 +00:00
|
|
|
const std::string mResourcePath;
|
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
bool mEnabled;
|
2012-04-12 14:46:56 +00:00
|
|
|
bool mToggled;
|
2015-03-08 00:07:29 +00:00
|
|
|
float mTop;
|
2019-02-21 16:14:18 +00:00
|
|
|
bool mInterior;
|
2012-01-14 23:34:14 +00:00
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
osg::Callback* mCullCallback;
|
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
osg::Vec3f getSceneNodeCoordinates(int gridX, int gridY);
|
2012-04-12 14:46:56 +00:00
|
|
|
void updateVisible();
|
2012-04-03 12:23:23 +00:00
|
|
|
|
2015-11-03 01:24:50 +00:00
|
|
|
void createSimpleWaterStateSet(osg::Node* node, float alpha);
|
2015-10-28 19:24:52 +00:00
|
|
|
|
|
|
|
/// @param reflection the reflection camera (required)
|
|
|
|
/// @param refraction the refraction camera (optional)
|
|
|
|
void createShaderWaterStateSet(osg::Node* node, Reflection* reflection, Refraction* refraction);
|
|
|
|
|
2015-10-28 20:22:14 +00:00
|
|
|
void updateWaterMaterial();
|
|
|
|
|
2012-03-29 16:33:08 +00:00
|
|
|
public:
|
2015-10-26 20:36:19 +00:00
|
|
|
Water(osg::Group* parent, osg::Group* sceneRoot,
|
2019-01-22 06:08:48 +00:00
|
|
|
Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico,
|
2015-10-26 20:36:19 +00:00
|
|
|
const std::string& resourcePath);
|
2012-03-29 16:33:08 +00:00
|
|
|
~Water();
|
2012-01-14 23:34:14 +00:00
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
void setCullCallback(osg::Callback* callback);
|
|
|
|
|
2016-02-09 00:17:02 +00:00
|
|
|
void listAssetsToPreload(std::vector<std::string>& textures);
|
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
void setEnabled(bool enabled);
|
2012-04-03 13:13:47 +00:00
|
|
|
|
2014-05-16 07:21:08 +00:00
|
|
|
bool toggle();
|
2012-01-14 23:34:14 +00:00
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
bool isUnderwater(const osg::Vec3f& pos) const;
|
|
|
|
|
2013-02-27 08:20:42 +00:00
|
|
|
/// adds an emitter, position will be tracked automatically using its scene node
|
|
|
|
void addEmitter (const MWWorld::Ptr& ptr, float scale = 1.f, float force = 1.f);
|
|
|
|
void removeEmitter (const MWWorld::Ptr& ptr);
|
|
|
|
void updateEmitterPtr (const MWWorld::Ptr& old, const MWWorld::Ptr& ptr);
|
2015-12-04 22:28:11 +00:00
|
|
|
void emitRipple(const osg::Vec3f& pos);
|
|
|
|
|
2015-06-16 18:36:48 +00:00
|
|
|
void removeCell(const MWWorld::CellStore* store); ///< remove all emitters in this cell
|
|
|
|
|
|
|
|
void clearRipples();
|
2013-02-23 04:53:20 +00:00
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
void changeCell(const MWWorld::CellStore* store);
|
2012-03-29 16:33:08 +00:00
|
|
|
void setHeight(const float height);
|
2012-01-14 23:34:14 +00:00
|
|
|
|
2015-06-16 18:36:48 +00:00
|
|
|
void update(float dt);
|
|
|
|
|
2017-11-10 18:18:16 +00:00
|
|
|
osg::Camera *getReflectionCamera();
|
|
|
|
osg::Camera *getRefractionCamera();
|
|
|
|
|
2015-10-28 20:22:14 +00:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
2017-10-16 17:47:08 +00:00
|
|
|
|
|
|
|
osg::Uniform *getRainIntensityUniform();
|
2012-03-29 16:33:08 +00:00
|
|
|
};
|
2012-01-14 23:34:14 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|