2015-06-02 16:35:35 +02:00
|
|
|
#ifndef OPENMW_MWRENDER_WATER_H
|
|
|
|
#define OPENMW_MWRENDER_WATER_H
|
2012-01-14 18:34:14 -05:00
|
|
|
|
2015-11-03 02:17:42 +01:00
|
|
|
#include <memory>
|
2016-02-09 01:17:02 +01:00
|
|
|
#include <vector>
|
2015-11-03 02:17:42 +01:00
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
#include <osg/ref_ptr>
|
2015-11-03 02:17:42 +01:00
|
|
|
#include <osg/Vec3f>
|
2021-10-05 12:21:12 +00:00
|
|
|
#include <osg/Vec3d>
|
2012-07-03 15:32:38 +02:00
|
|
|
|
2015-10-28 21:22:14 +01:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
namespace osg
|
2012-07-03 15:32:38 +02:00
|
|
|
{
|
2015-06-02 16:35:35 +02:00
|
|
|
class Group;
|
|
|
|
class PositionAttitudeTransform;
|
2016-03-10 13:17:01 +01:00
|
|
|
class Geometry;
|
2015-10-28 20:24:52 +01:00
|
|
|
class Node;
|
2021-10-05 12:21:12 +00:00
|
|
|
class Callback;
|
2012-10-09 17:10:25 +02:00
|
|
|
}
|
2012-05-29 06:45:44 +02:00
|
|
|
|
2015-06-03 01:18:36 +02:00
|
|
|
namespace osgUtil
|
|
|
|
{
|
|
|
|
class IncrementalCompileOperation;
|
|
|
|
}
|
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
namespace Resource
|
2015-02-09 19:28:29 +01:00
|
|
|
{
|
2015-06-02 16:35:35 +02:00
|
|
|
class ResourceSystem;
|
2015-02-09 19:28:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-16 20:36:48 +02:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2015-11-03 02:17:42 +01:00
|
|
|
class CellStore;
|
|
|
|
class Ptr;
|
2015-06-16 20:36:48 +02:00
|
|
|
}
|
|
|
|
|
2016-01-06 12:46:06 +01:00
|
|
|
namespace Fallback
|
|
|
|
{
|
|
|
|
class Map;
|
|
|
|
}
|
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2013-01-16 09:13:36 +01:00
|
|
|
|
2015-10-28 19:57:58 +01:00
|
|
|
class Refraction;
|
|
|
|
class Reflection;
|
2015-06-16 20:36:48 +02:00
|
|
|
class RippleSimulation;
|
2021-03-08 10:58:51 +04:00
|
|
|
class RainIntensityUpdater;
|
2015-06-16 20:36:48 +02:00
|
|
|
|
2012-07-03 15:32:38 +02:00
|
|
|
/// Water rendering
|
2015-06-02 16:35:35 +02:00
|
|
|
class Water
|
2012-03-29 18:33:08 +02:00
|
|
|
{
|
2021-03-08 10:58:51 +04:00
|
|
|
osg::ref_ptr<RainIntensityUpdater> mRainIntensityUpdater;
|
2017-10-16 19:47:08 +02:00
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
osg::ref_ptr<osg::Group> mParent;
|
2015-10-26 21:36:19 +01:00
|
|
|
osg::ref_ptr<osg::Group> mSceneRoot;
|
2015-06-02 16:35:35 +02:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mWaterNode;
|
2016-03-10 13:17:01 +01:00
|
|
|
osg::ref_ptr<osg::Geometry> mWaterGeom;
|
2015-06-02 16:35:35 +02:00
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
2015-06-03 01:18:36 +02:00
|
|
|
osg::ref_ptr<osgUtil::IncrementalCompileOperation> mIncrementalCompileOperation;
|
2012-01-14 18:34:14 -05:00
|
|
|
|
2017-04-28 17:30:26 +02:00
|
|
|
std::unique_ptr<RippleSimulation> mSimulation;
|
2015-06-16 20:36:48 +02:00
|
|
|
|
2015-10-28 19:57:58 +01:00
|
|
|
osg::ref_ptr<Refraction> mRefraction;
|
|
|
|
osg::ref_ptr<Reflection> mReflection;
|
|
|
|
|
2015-10-28 20:24:52 +01:00
|
|
|
const std::string mResourcePath;
|
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
bool mEnabled;
|
2012-04-12 16:46:56 +02:00
|
|
|
bool mToggled;
|
2015-03-08 13:07:29 +13:00
|
|
|
float mTop;
|
2019-02-21 20:14:18 +04:00
|
|
|
bool mInterior;
|
2021-10-27 09:16:01 -07:00
|
|
|
bool mShowWorld;
|
2012-01-14 18:34:14 -05:00
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
osg::Callback* mCullCallback;
|
2021-10-05 12:21:12 +00:00
|
|
|
osg::ref_ptr<osg::Callback> mShaderWaterStateSetUpdater;
|
2019-06-13 13:37:00 +00:00
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
osg::Vec3f getSceneNodeCoordinates(int gridX, int gridY);
|
2012-04-12 16:46:56 +02:00
|
|
|
void updateVisible();
|
2012-04-03 14:23:23 +02:00
|
|
|
|
2015-11-03 02:24:50 +01:00
|
|
|
void createSimpleWaterStateSet(osg::Node* node, float alpha);
|
2015-10-28 20:24:52 +01: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 21:22:14 +01:00
|
|
|
void updateWaterMaterial();
|
|
|
|
|
2012-03-29 18:33:08 +02:00
|
|
|
public:
|
2015-10-26 21:36:19 +01:00
|
|
|
Water(osg::Group* parent, osg::Group* sceneRoot,
|
2019-01-22 10:08:48 +04:00
|
|
|
Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico,
|
2015-10-26 21:36:19 +01:00
|
|
|
const std::string& resourcePath);
|
2012-03-29 18:33:08 +02:00
|
|
|
~Water();
|
2012-01-14 18:34:14 -05:00
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
void setCullCallback(osg::Callback* callback);
|
|
|
|
|
2016-02-09 01:17:02 +01:00
|
|
|
void listAssetsToPreload(std::vector<std::string>& textures);
|
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
void setEnabled(bool enabled);
|
2012-04-03 15:13:47 +02:00
|
|
|
|
2014-05-16 09:21:08 +02:00
|
|
|
bool toggle();
|
2012-01-14 18:34:14 -05:00
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
bool isUnderwater(const osg::Vec3f& pos) const;
|
|
|
|
|
2013-02-27 09:20:42 +01: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 23:28:11 +01:00
|
|
|
void emitRipple(const osg::Vec3f& pos);
|
|
|
|
|
2015-06-16 20:36:48 +02:00
|
|
|
void removeCell(const MWWorld::CellStore* store); ///< remove all emitters in this cell
|
|
|
|
|
|
|
|
void clearRipples();
|
2013-02-23 05:53:20 +01:00
|
|
|
|
2015-06-02 16:35:35 +02:00
|
|
|
void changeCell(const MWWorld::CellStore* store);
|
2012-03-29 18:33:08 +02:00
|
|
|
void setHeight(const float height);
|
2021-03-08 10:58:51 +04:00
|
|
|
void setRainIntensity(const float rainIntensity);
|
2012-01-14 18:34:14 -05:00
|
|
|
|
2015-06-16 20:36:48 +02:00
|
|
|
void update(float dt);
|
|
|
|
|
2021-01-24 10:34:33 +01:00
|
|
|
osg::Node* getReflectionNode();
|
|
|
|
osg::Node* getRefractionNode();
|
2017-11-10 19:18:16 +01:00
|
|
|
|
2021-08-14 17:41:58 +00:00
|
|
|
osg::Vec3d getPosition() const;
|
|
|
|
|
2015-10-28 21:22:14 +01:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
2021-10-27 09:16:01 -07:00
|
|
|
|
|
|
|
void showWorld(bool show);
|
2012-03-29 18:33:08 +02:00
|
|
|
};
|
2012-01-14 18:34:14 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|