2015-04-12 13:34:50 +00:00
|
|
|
#ifndef OPENMW_MWRENDER_RENDERINGMANAGER_H
|
|
|
|
#define OPENMW_MWRENDER_RENDERINGMANAGER_H
|
2011-10-20 19:02:19 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Light>
|
2017-11-15 14:20:59 +00:00
|
|
|
#include <osg/Camera>
|
2011-11-12 05:19:22 +00:00
|
|
|
|
2015-05-14 16:46:04 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
2019-11-24 13:40:19 +00:00
|
|
|
#include <osgUtil/IncrementalCompileOperation>
|
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
#include "objects.hpp"
|
2013-02-03 17:03:09 +00:00
|
|
|
|
2011-11-12 05:19:22 +00:00
|
|
|
#include "renderinginterface.hpp"
|
2015-05-02 20:45:27 +00:00
|
|
|
#include "rendermode.hpp"
|
2011-11-24 06:48:54 +00:00
|
|
|
|
2018-07-21 10:37:02 +00:00
|
|
|
#include <deque>
|
2019-02-22 19:16:47 +00:00
|
|
|
#include <memory>
|
2018-07-21 10:37:02 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
namespace osg
|
2011-10-20 22:15:30 +00:00
|
|
|
{
|
2015-04-12 13:34:50 +00:00
|
|
|
class Group;
|
2015-05-01 16:21:50 +00:00
|
|
|
class PositionAttitudeTransform;
|
2011-10-20 22:15:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-12 18:48:41 +00:00
|
|
|
namespace osgUtil
|
|
|
|
{
|
|
|
|
class IntersectionVisitor;
|
|
|
|
class Intersector;
|
|
|
|
}
|
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
namespace Resource
|
2011-10-20 19:02:19 +00:00
|
|
|
{
|
2015-04-12 13:34:50 +00:00
|
|
|
class ResourceSystem;
|
2011-10-20 22:15:30 +00:00
|
|
|
}
|
2011-10-20 19:02:19 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
namespace osgViewer
|
2012-07-03 20:48:16 +00:00
|
|
|
{
|
2015-04-12 13:34:50 +00:00
|
|
|
class Viewer;
|
2012-07-03 20:48:16 +00:00
|
|
|
}
|
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
namespace ESM
|
2013-08-16 11:01:52 +00:00
|
|
|
{
|
2015-04-12 13:34:50 +00:00
|
|
|
struct Cell;
|
2019-08-03 13:37:00 +00:00
|
|
|
struct RefNum;
|
2013-08-16 11:01:52 +00:00
|
|
|
}
|
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
namespace Terrain
|
|
|
|
{
|
|
|
|
class World;
|
|
|
|
}
|
|
|
|
|
2016-01-06 11:46:06 +00:00
|
|
|
namespace Fallback
|
2015-06-16 18:36:48 +00:00
|
|
|
{
|
2016-01-06 11:46:06 +00:00
|
|
|
class Map;
|
2015-06-16 18:36:48 +00:00
|
|
|
}
|
|
|
|
|
2016-02-09 00:02:40 +00:00
|
|
|
namespace SceneUtil
|
|
|
|
{
|
2018-02-26 22:27:09 +00:00
|
|
|
class ShadowManager;
|
2016-02-09 00:02:40 +00:00
|
|
|
class WorkQueue;
|
2016-02-09 14:30:53 +00:00
|
|
|
class UnrefQueue;
|
2016-02-09 00:02:40 +00:00
|
|
|
}
|
|
|
|
|
2018-04-07 13:11:23 +00:00
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
2019-02-16 12:27:02 +00:00
|
|
|
struct Navigator;
|
2018-07-21 10:37:02 +00:00
|
|
|
struct Settings;
|
2018-04-07 13:11:23 +00:00
|
|
|
}
|
|
|
|
|
2011-10-20 22:15:30 +00:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2012-08-12 11:50:37 +00:00
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
class StateUpdater;
|
|
|
|
|
2015-04-19 15:55:56 +00:00
|
|
|
class EffectManager;
|
2020-06-07 06:35:33 +00:00
|
|
|
class FogManager;
|
2015-04-14 13:55:56 +00:00
|
|
|
class SkyManager;
|
2015-05-01 16:21:50 +00:00
|
|
|
class NpcAnimation;
|
2015-05-04 15:41:30 +00:00
|
|
|
class Pathgrid;
|
2015-05-21 21:54:39 +00:00
|
|
|
class Camera;
|
2015-06-02 14:35:35 +00:00
|
|
|
class Water;
|
2017-03-06 18:04:17 +00:00
|
|
|
class TerrainStorage;
|
|
|
|
class LandManager;
|
2018-04-07 13:11:23 +00:00
|
|
|
class NavMesh;
|
2018-07-21 10:37:02 +00:00
|
|
|
class ActorsPaths;
|
2019-11-27 22:45:01 +00:00
|
|
|
class RecastMesh;
|
2019-06-13 13:37:00 +00:00
|
|
|
class ObjectPaging;
|
2015-04-14 13:55:56 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
class RenderingManager : public MWRender::RenderingInterface
|
2013-04-29 12:50:40 +00:00
|
|
|
{
|
2015-04-12 13:34:50 +00:00
|
|
|
public:
|
2018-04-07 13:11:23 +00:00
|
|
|
RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode,
|
|
|
|
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
2019-01-22 06:08:48 +00:00
|
|
|
const std::string& resourcePath, DetourNavigator::Navigator& navigator);
|
2015-04-14 13:55:56 +00:00
|
|
|
~RenderingManager();
|
2014-01-17 09:52:44 +00:00
|
|
|
|
2019-11-24 13:40:19 +00:00
|
|
|
osgUtil::IncrementalCompileOperation* getIncrementalCompileOperation();
|
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
MWRender::Objects& getObjects();
|
2013-04-29 10:31:46 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
Resource::ResourceSystem* getResourceSystem();
|
2011-11-04 03:47:15 +00:00
|
|
|
|
2016-02-09 00:02:40 +00:00
|
|
|
SceneUtil::WorkQueue* getWorkQueue();
|
2016-02-09 18:04:59 +00:00
|
|
|
SceneUtil::UnrefQueue* getUnrefQueue();
|
2016-02-09 19:57:30 +00:00
|
|
|
Terrain::World* getTerrain();
|
2016-02-09 00:02:40 +00:00
|
|
|
|
2017-09-26 12:14:28 +00:00
|
|
|
osg::Uniform* mUniformNear;
|
|
|
|
osg::Uniform* mUniformFar;
|
|
|
|
|
2016-02-09 00:17:02 +00:00
|
|
|
void preloadCommonAssets();
|
|
|
|
|
2016-02-06 23:36:31 +00:00
|
|
|
double getReferenceTime() const;
|
|
|
|
|
2015-12-04 23:44:04 +00:00
|
|
|
osg::Group* getLightRoot();
|
|
|
|
|
2015-06-11 21:16:05 +00:00
|
|
|
void setNightEyeFactor(float factor);
|
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
void setAmbientColour(const osg::Vec4f& colour);
|
|
|
|
|
2015-06-16 18:56:48 +00:00
|
|
|
void skySetDate(int day, int month);
|
|
|
|
int skyGetMasserPhase() const;
|
|
|
|
int skyGetSecundaPhase() const;
|
|
|
|
void skySetMoonColour(bool red);
|
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
void setSunDirection(const osg::Vec3f& direction);
|
2016-05-10 15:39:57 +00:00
|
|
|
void setSunColour(const osg::Vec4f& diffuse, const osg::Vec4f& specular);
|
2015-04-14 13:55:56 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
void configureAmbient(const ESM::Cell* cell);
|
2015-04-21 21:27:26 +00:00
|
|
|
void configureFog(const ESM::Cell* cell);
|
2017-09-21 10:08:45 +00:00
|
|
|
void configureFog(float fogDepth, float underwaterFog, float dlFactor, float dlOffset, const osg::Vec4f& colour);
|
2015-04-14 13:55:56 +00:00
|
|
|
|
2015-05-02 20:45:27 +00:00
|
|
|
void addCell(const MWWorld::CellStore* store);
|
2015-04-12 13:34:50 +00:00
|
|
|
void removeCell(const MWWorld::CellStore* store);
|
2013-02-27 08:20:42 +00:00
|
|
|
|
2017-03-09 01:17:25 +00:00
|
|
|
void enableTerrain(bool enable);
|
|
|
|
|
2015-05-14 15:34:55 +00:00
|
|
|
void updatePtr(const MWWorld::Ptr& old, const MWWorld::Ptr& updated);
|
|
|
|
|
2015-04-23 21:50:46 +00:00
|
|
|
void rotateObject(const MWWorld::Ptr& ptr, const osg::Quat& rot);
|
|
|
|
void moveObject(const MWWorld::Ptr& ptr, const osg::Vec3f& pos);
|
|
|
|
void scaleObject(const MWWorld::Ptr& ptr, const osg::Vec3f& scale);
|
|
|
|
|
2015-05-21 22:55:43 +00:00
|
|
|
void removeObject(const MWWorld::Ptr& ptr);
|
|
|
|
|
2015-06-02 14:35:35 +00:00
|
|
|
void setWaterEnabled(bool enabled);
|
|
|
|
void setWaterHeight(float level);
|
|
|
|
|
2015-06-03 14:40:16 +00:00
|
|
|
/// Take a screenshot of w*h onto the given image, not including the GUI.
|
2019-02-20 13:37:00 +00:00
|
|
|
void screenshot(osg::Image* image, int w, int h, osg::Matrixd cameraTransform=osg::Matrixd()); // make a new render at given size
|
2020-04-22 18:29:50 +00:00
|
|
|
void screenshotFramebuffer(osg::Image* image, int w, int h); // copy directly from framebuffer and scale to given size
|
2017-11-11 13:32:28 +00:00
|
|
|
bool screenshot360(osg::Image* image, std::string settingStr);
|
2015-06-03 14:40:16 +00:00
|
|
|
|
2015-06-05 00:26:16 +00:00
|
|
|
struct RayResult
|
|
|
|
{
|
|
|
|
bool mHit;
|
|
|
|
osg::Vec3f mHitNormalWorld;
|
|
|
|
osg::Vec3f mHitPointWorld;
|
|
|
|
MWWorld::Ptr mHitObject;
|
2016-07-06 13:03:37 +00:00
|
|
|
float mRatio;
|
2015-06-05 00:26:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
RayResult castRay(const osg::Vec3f& origin, const osg::Vec3f& dest, bool ignorePlayer, bool ignoreActors=false);
|
|
|
|
|
2015-05-24 01:36:34 +00:00
|
|
|
/// Return the object under the mouse cursor / crosshair position, given by nX and nY normalized screen coordinates,
|
|
|
|
/// where (0,0) is the top left corner.
|
2015-06-05 00:26:16 +00:00
|
|
|
RayResult castCameraToViewportRay(const float nX, const float nY, float maxDistance, bool ignorePlayer, bool ignoreActors=false);
|
2015-05-24 01:36:34 +00:00
|
|
|
|
|
|
|
/// Get the bounding box of the given object in screen coordinates as (minX, minY, maxX, maxY), with (0,0) being the top left corner.
|
|
|
|
osg::Vec4f getScreenBounds(const MWWorld::Ptr& ptr);
|
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
void setSkyEnabled(bool enabled);
|
|
|
|
|
2015-05-02 20:45:27 +00:00
|
|
|
bool toggleRenderMode(RenderMode mode);
|
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
SkyManager* getSkyManager();
|
|
|
|
|
2016-09-14 14:18:29 +00:00
|
|
|
void spawnEffect(const std::string &model, const std::string &texture, const osg::Vec3f &worldPosition, float scale = 1.f, bool isMagicVFX = true);
|
2015-04-19 15:55:56 +00:00
|
|
|
|
|
|
|
/// Clear all savegame-specific data
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
/// Clear all worldspace-specific data
|
|
|
|
void notifyWorldSpaceChanged();
|
|
|
|
|
2015-04-18 23:57:52 +00:00
|
|
|
void update(float dt, bool paused);
|
|
|
|
|
2015-05-01 16:21:50 +00:00
|
|
|
Animation* getAnimation(const MWWorld::Ptr& ptr);
|
2015-12-18 16:21:51 +00:00
|
|
|
const Animation* getAnimation(const MWWorld::ConstPtr& ptr) const;
|
2015-05-01 16:21:50 +00:00
|
|
|
|
2015-06-16 18:36:48 +00:00
|
|
|
void addWaterRippleEmitter(const MWWorld::Ptr& ptr);
|
|
|
|
void removeWaterRippleEmitter(const MWWorld::Ptr& ptr);
|
2015-12-04 22:28:11 +00:00
|
|
|
void emitWaterRipple(const osg::Vec3f& pos);
|
2015-06-16 18:36:48 +00:00
|
|
|
|
2015-05-21 21:54:39 +00:00
|
|
|
void updatePlayerPtr(const MWWorld::Ptr &ptr);
|
|
|
|
|
2015-06-16 18:36:48 +00:00
|
|
|
void removePlayer(const MWWorld::Ptr& player);
|
2015-05-01 16:21:50 +00:00
|
|
|
void setupPlayer(const MWWorld::Ptr& player);
|
|
|
|
void renderPlayer(const MWWorld::Ptr& player);
|
2015-04-25 13:19:17 +00:00
|
|
|
|
2015-05-21 21:54:39 +00:00
|
|
|
void rebuildPtr(const MWWorld::Ptr& ptr);
|
|
|
|
|
2015-05-14 16:46:04 +00:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
|
|
|
|
2015-06-01 13:34:46 +00:00
|
|
|
float getNearClipDistance() const;
|
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
float getTerrainHeightAt(const osg::Vec3f& pos);
|
|
|
|
|
2015-05-21 21:54:39 +00:00
|
|
|
// camera stuff
|
|
|
|
bool vanityRotateCamera(const float *rot);
|
|
|
|
void setCameraDistance(float dist, bool adjust, bool override);
|
|
|
|
void resetCamera();
|
|
|
|
float getCameraDistance() const;
|
|
|
|
Camera* getCamera();
|
2015-12-03 14:16:20 +00:00
|
|
|
const osg::Vec3f& getCameraPosition() const;
|
2019-09-19 17:48:43 +00:00
|
|
|
void togglePOV(bool force = false);
|
2015-05-21 21:54:39 +00:00
|
|
|
void togglePreviewMode(bool enable);
|
|
|
|
bool toggleVanityMode(bool enable);
|
|
|
|
void allowVanityMode(bool allow);
|
|
|
|
void changeVanityModeScale(float factor);
|
|
|
|
|
2015-12-07 15:11:47 +00:00
|
|
|
/// temporarily override the field of view with given value.
|
|
|
|
void overrideFieldOfView(float val);
|
|
|
|
/// reset a previous overrideFieldOfView() call, i.e. revert to field of view specified in the settings file.
|
|
|
|
void resetFieldOfView();
|
|
|
|
|
2018-06-16 06:18:04 +00:00
|
|
|
osg::Vec3f getHalfExtents(const MWWorld::ConstPtr& object) const;
|
|
|
|
|
2017-02-01 02:00:33 +00:00
|
|
|
void exportSceneGraph(const MWWorld::Ptr& ptr, const std::string& filename, const std::string& format);
|
|
|
|
|
2017-03-06 18:04:17 +00:00
|
|
|
LandManager* getLandManager() const;
|
|
|
|
|
2018-06-12 23:48:31 +00:00
|
|
|
bool toggleBorders();
|
|
|
|
|
2018-07-21 10:37:02 +00:00
|
|
|
void updateActorPath(const MWWorld::ConstPtr& actor, const std::deque<osg::Vec3f>& path,
|
|
|
|
const osg::Vec3f& halfExtents, const osg::Vec3f& start, const osg::Vec3f& end) const;
|
|
|
|
|
|
|
|
void removeActorPath(const MWWorld::ConstPtr& actor) const;
|
|
|
|
|
2018-08-30 22:39:44 +00:00
|
|
|
void setNavMeshNumber(const std::size_t value);
|
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
void setActiveGrid(const osg::Vec4i &grid);
|
|
|
|
|
2020-05-08 13:37:00 +00:00
|
|
|
void pagingEnableObject(int type, const MWWorld::ConstPtr& ptr, bool enabled);
|
2019-08-03 13:37:00 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
private:
|
2015-05-14 16:46:04 +00:00
|
|
|
void updateProjectionMatrix();
|
2015-05-14 19:42:04 +00:00
|
|
|
void updateTextureFiltering();
|
2015-06-11 21:16:05 +00:00
|
|
|
void updateAmbient();
|
2015-06-02 14:35:35 +00:00
|
|
|
void setFogColor(const osg::Vec4f& color);
|
2015-05-14 16:46:04 +00:00
|
|
|
|
2017-03-07 03:02:06 +00:00
|
|
|
void reportStats() const;
|
2017-02-22 01:18:18 +00:00
|
|
|
|
2017-11-15 14:20:59 +00:00
|
|
|
void renderCameraToImage(osg::Camera *camera, osg::Image *image, int w, int h);
|
|
|
|
|
2019-01-20 16:27:52 +00:00
|
|
|
void updateNavMesh();
|
|
|
|
|
2019-11-27 22:45:01 +00:00
|
|
|
void updateRecastMesh();
|
|
|
|
|
2017-03-12 18:48:41 +00:00
|
|
|
osg::ref_ptr<osgUtil::IntersectionVisitor> getIntersectionVisitor(osgUtil::Intersector* intersector, bool ignorePlayer, bool ignoreActors);
|
|
|
|
|
|
|
|
osg::ref_ptr<osgUtil::IntersectionVisitor> mIntersectionVisitor;
|
|
|
|
|
2015-05-14 19:42:04 +00:00
|
|
|
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
2015-04-12 13:34:50 +00:00
|
|
|
osg::ref_ptr<osg::Group> mRootNode;
|
2016-02-08 15:45:56 +00:00
|
|
|
osg::ref_ptr<osg::Group> mSceneRoot;
|
2015-04-12 13:34:50 +00:00
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
2012-03-29 09:27:13 +00:00
|
|
|
|
2016-02-09 00:02:40 +00:00
|
|
|
osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;
|
2016-02-09 14:30:53 +00:00
|
|
|
osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;
|
2016-02-09 00:02:40 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
osg::ref_ptr<osg::Light> mSunLight;
|
2012-04-11 16:53:13 +00:00
|
|
|
|
2018-04-07 13:11:23 +00:00
|
|
|
DetourNavigator::Navigator& mNavigator;
|
|
|
|
std::unique_ptr<NavMesh> mNavMesh;
|
2018-08-30 22:39:44 +00:00
|
|
|
std::size_t mNavMeshNumber = 0;
|
2018-07-21 10:37:02 +00:00
|
|
|
std::unique_ptr<ActorsPaths> mActorsPaths;
|
2019-11-27 22:45:01 +00:00
|
|
|
std::unique_ptr<RecastMesh> mRecastMesh;
|
2017-04-28 15:30:26 +00:00
|
|
|
std::unique_ptr<Pathgrid> mPathgrid;
|
|
|
|
std::unique_ptr<Objects> mObjects;
|
|
|
|
std::unique_ptr<Water> mWater;
|
|
|
|
std::unique_ptr<Terrain::World> mTerrain;
|
2017-03-06 18:04:17 +00:00
|
|
|
TerrainStorage* mTerrainStorage;
|
2019-06-13 13:37:00 +00:00
|
|
|
std::unique_ptr<ObjectPaging> mObjectPaging;
|
2017-04-28 15:30:26 +00:00
|
|
|
std::unique_ptr<SkyManager> mSky;
|
2020-06-07 06:35:33 +00:00
|
|
|
std::unique_ptr<FogManager> mFog;
|
2017-04-28 15:30:26 +00:00
|
|
|
std::unique_ptr<EffectManager> mEffectManager;
|
2018-02-26 22:27:09 +00:00
|
|
|
std::unique_ptr<SceneUtil::ShadowManager> mShadowManager;
|
2017-02-22 14:22:40 +00:00
|
|
|
osg::ref_ptr<NpcAnimation> mPlayerAnimation;
|
2015-11-20 20:57:04 +00:00
|
|
|
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> mPlayerNode;
|
2017-04-28 15:30:26 +00:00
|
|
|
std::unique_ptr<Camera> mCamera;
|
2015-12-03 14:16:20 +00:00
|
|
|
osg::Vec3f mCurrentCameraPos;
|
2015-04-14 13:55:56 +00:00
|
|
|
|
|
|
|
osg::ref_ptr<StateUpdater> mStateUpdater;
|
|
|
|
|
2015-06-11 21:16:05 +00:00
|
|
|
osg::Vec4f mAmbientColor;
|
|
|
|
float mNightEyeFactor;
|
|
|
|
|
2015-05-24 00:34:20 +00:00
|
|
|
float mNearClip;
|
2015-04-21 21:27:26 +00:00
|
|
|
float mViewDistance;
|
2020-06-07 06:35:33 +00:00
|
|
|
bool mFieldOfViewOverridden;
|
2015-12-07 15:11:47 +00:00
|
|
|
float mFieldOfViewOverride;
|
2015-05-14 16:46:04 +00:00
|
|
|
float mFieldOfView;
|
2015-12-07 15:29:30 +00:00
|
|
|
float mFirstPersonFieldOfView;
|
2015-04-21 21:27:26 +00:00
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
void operator = (const RenderingManager&);
|
|
|
|
RenderingManager(const RenderingManager&);
|
2015-04-12 13:34:50 +00:00
|
|
|
};
|
2011-10-20 19:02:19 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|