1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 22:49:55 +00:00
openmw-tes3mp/apps/openmw/mwrender/water.hpp

128 lines
3.2 KiB
C++
Raw Normal View History

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