1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-18 13:12:50 +00:00

135 lines
3.3 KiB
C++
Raw Normal View History

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>
#include <osg/Vec3d>
2015-10-28 21:22:14 +01:00
#include <components/settings/settings.hpp>
2015-06-02 16:35:35 +02:00
namespace osg
{
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;
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-06-02 16:35:35 +02:00
class ResourceSystem;
}
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
{
class Refraction;
class Reflection;
2015-06-16 20:36:48 +02:00
class RippleSimulation;
class RainIntensityUpdater;
2015-06-16 20:36:48 +02:00
/// Water rendering
2015-06-02 16:35:35 +02:00
class Water
{
osg::ref_ptr<RainIntensityUpdater> mRainIntensityUpdater;
2015-06-02 16:35:35 +02:00
osg::ref_ptr<osg::Group> mParent;
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
std::unique_ptr<RippleSimulation> mSimulation;
2015-06-16 20:36:48 +02: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;
float mTop;
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;
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();
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();
public:
Water(osg::Group* parent, osg::Group* sceneRoot,
Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico,
const std::string& resourcePath);
~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
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);
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();
2015-06-02 16:35:35 +02:00
void changeCell(const MWWorld::CellStore* store);
void setHeight(const float height);
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);
osg::Node* getReflectionNode();
osg::Node* getRefractionNode();
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-01-14 18:34:14 -05:00
}
#endif