1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00
OpenMW/apps/openmw/mwrender/renderingmanager.hpp

316 lines
9.6 KiB
C++
Raw Normal View History

#ifndef OPENMW_MWRENDER_RENDERINGMANAGER_H
#define OPENMW_MWRENDER_RENDERINGMANAGER_H
2011-10-20 15:02:19 -04:00
#include <osg/ref_ptr>
#include <osg/Light>
2017-11-15 15:20:59 +01:00
#include <osg/Camera>
2011-11-12 00:19:22 -05:00
#include <components/settings/settings.hpp>
2019-11-24 17:40:19 +04:00
#include <osgUtil/IncrementalCompileOperation>
#include "objects.hpp"
2011-11-12 00:19:22 -05:00
#include "renderinginterface.hpp"
2015-05-02 22:45:27 +02:00
#include "rendermode.hpp"
#include <deque>
2019-02-22 23:16:47 +04:00
#include <memory>
namespace osg
{
class Group;
2015-05-01 18:21:50 +02:00
class PositionAttitudeTransform;
}
namespace osgUtil
{
class IntersectionVisitor;
class Intersector;
}
namespace Resource
2011-10-20 15:02:19 -04:00
{
class ResourceSystem;
}
2011-10-20 15:02:19 -04:00
namespace osgViewer
2012-07-03 22:48:16 +02:00
{
class Viewer;
2012-07-03 22:48:16 +02:00
}
namespace ESM
{
struct Cell;
struct RefNum;
}
2015-06-03 01:18:36 +02:00
namespace Terrain
{
class World;
}
2016-01-06 12:46:06 +01:00
namespace Fallback
2015-06-16 20:36:48 +02:00
{
2016-01-06 12:46:06 +01:00
class Map;
2015-06-16 20:36:48 +02:00
}
namespace SceneUtil
{
2018-02-26 22:27:09 +00:00
class ShadowManager;
class WorkQueue;
class UnrefQueue;
}
namespace DetourNavigator
{
2019-02-16 15:27:02 +03:00
struct Navigator;
struct Settings;
}
namespace MWRender
{
2020-01-12 11:42:47 +04:00
class GroundcoverUpdater;
class StateUpdater;
class SharedUniformStateUpdater;
2015-04-19 17:55:56 +02:00
class EffectManager;
class ScreenshotManager;
2020-06-07 10:35:33 +04:00
class FogManager;
class SkyManager;
2015-05-01 18:21:50 +02:00
class NpcAnimation;
class Pathgrid;
2015-05-21 23:54:39 +02:00
class Camera;
class ViewOverShoulderController;
2015-06-02 16:35:35 +02:00
class Water;
class TerrainStorage;
class LandManager;
class NavMesh;
class ActorsPaths;
2019-11-27 23:45:01 +01:00
class RecastMesh;
class ObjectPaging;
2020-01-12 11:42:47 +04:00
class Groundcover;
2021-06-01 12:15:25 -07:00
class PostProcessor;
class RenderingManager : public MWRender::RenderingInterface
2013-04-29 05:50:40 -07:00
{
public:
RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode,
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
const std::string& resourcePath, DetourNavigator::Navigator& navigator);
~RenderingManager();
2014-01-17 10:52:44 +01:00
2019-11-24 17:40:19 +04:00
osgUtil::IncrementalCompileOperation* getIncrementalCompileOperation();
MWRender::Objects& getObjects() override;
Resource::ResourceSystem* getResourceSystem();
2011-11-03 23:47:15 -04:00
SceneUtil::WorkQueue* getWorkQueue();
SceneUtil::UnrefQueue* getUnrefQueue();
2016-02-09 20:57:30 +01:00
Terrain::World* getTerrain();
2016-02-09 01:17:02 +01:00
void preloadCommonAssets();
double getReferenceTime() const;
2015-12-05 00:44:04 +01:00
osg::Group* getLightRoot();
2015-06-11 23:16:05 +02:00
void setNightEyeFactor(float factor);
void setAmbientColour(const osg::Vec4f& colour);
2015-06-16 20:56:48 +02:00
void skySetDate(int day, int month);
int skyGetMasserPhase() const;
int skyGetSecundaPhase() const;
void skySetMoonColour(bool red);
void setSunDirection(const osg::Vec3f& direction);
void setSunColour(const osg::Vec4f& diffuse, const osg::Vec4f& specular);
void configureAmbient(const ESM::Cell* cell);
void configureFog(const ESM::Cell* cell);
void configureFog(float fogDepth, float underwaterFog, float dlFactor, float dlOffset, const osg::Vec4f& colour);
2015-05-02 22:45:27 +02:00
void addCell(const MWWorld::CellStore* store);
void removeCell(const MWWorld::CellStore* store);
2013-02-27 09:20:42 +01:00
2017-03-09 02:17:25 +01:00
void enableTerrain(bool enable);
2015-05-14 17:34:55 +02:00
void updatePtr(const MWWorld::Ptr& old, const MWWorld::Ptr& updated);
2015-04-23 23:50:46 +02: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-22 00:55:43 +02:00
void removeObject(const MWWorld::Ptr& ptr);
2015-06-02 16:35:35 +02:00
void setWaterEnabled(bool enabled);
void setWaterHeight(float level);
2015-06-03 16:40:16 +02:00
/// Take a screenshot of w*h onto the given image, not including the GUI.
void screenshot(osg::Image* image, int w, int h);
bool screenshot360(osg::Image* image);
2015-06-03 16:40:16 +02:00
struct RayResult
{
bool mHit;
osg::Vec3f mHitNormalWorld;
osg::Vec3f mHitPointWorld;
MWWorld::Ptr mHitObject;
ESM::RefNum mHitRefnum;
float mRatio;
};
RayResult castRay(const osg::Vec3f& origin, const osg::Vec3f& dest, bool ignorePlayer, bool ignoreActors=false);
/// 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.
RayResult castCameraToViewportRay(const float nX, const float nY, float maxDistance, bool ignorePlayer, bool ignoreActors=false);
/// 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 osg::BoundingBox &worldbb);
void setSkyEnabled(bool enabled);
2015-05-02 22:45:27 +02:00
bool toggleRenderMode(RenderMode mode);
SkyManager* getSkyManager();
2016-09-14 23:18:29 +09: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 17:55:56 +02:00
/// Clear all savegame-specific data
void clear();
/// Clear all worldspace-specific data
void notifyWorldSpaceChanged();
2015-04-19 01:57:52 +02:00
void update(float dt, bool paused);
2015-05-01 18:21:50 +02:00
Animation* getAnimation(const MWWorld::Ptr& ptr);
2015-12-18 17:21:51 +01:00
const Animation* getAnimation(const MWWorld::ConstPtr& ptr) const;
2015-05-01 18:21:50 +02:00
2015-06-16 20:36:48 +02:00
void addWaterRippleEmitter(const MWWorld::Ptr& ptr);
void removeWaterRippleEmitter(const MWWorld::Ptr& ptr);
void emitWaterRipple(const osg::Vec3f& pos);
2015-06-16 20:36:48 +02:00
2015-05-21 23:54:39 +02:00
void updatePlayerPtr(const MWWorld::Ptr &ptr);
2015-06-16 20:36:48 +02:00
void removePlayer(const MWWorld::Ptr& player);
2015-05-01 18:21:50 +02:00
void setupPlayer(const MWWorld::Ptr& player);
void renderPlayer(const MWWorld::Ptr& player);
2015-04-25 15:19:17 +02:00
2015-05-21 23:54:39 +02:00
void rebuildPtr(const MWWorld::Ptr& ptr);
void processChangedSettings(const Settings::CategorySettingVector& settings);
2015-06-01 15:34:46 +02:00
float getNearClipDistance() const;
2015-06-03 01:18:36 +02:00
float getTerrainHeightAt(const osg::Vec3f& pos);
2015-05-21 23:54:39 +02:00
// camera stuff
Camera* getCamera() { return mCamera.get(); }
const osg::Vec3f& getCameraPosition() const { return mCurrentCameraPos; }
2015-05-21 23:54:39 +02: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();
osg::Vec3f getHalfExtents(const MWWorld::ConstPtr& object) const;
void exportSceneGraph(const MWWorld::Ptr& ptr, const std::string& filename, const std::string& format);
LandManager* getLandManager() const;
2018-06-13 01:48:31 +02:00
bool toggleBorders();
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;
void setNavMeshNumber(const std::size_t value);
void setActiveGrid(const osg::Vec4i &grid);
bool pagingEnableObject(int type, const MWWorld::ConstPtr& ptr, bool enabled);
void pagingBlacklistObject(int type, const MWWorld::ConstPtr &ptr);
bool pagingUnlockCache();
void getPagedRefnums(const osg::Vec4i &activeGrid, std::set<ESM::RefNum> &out);
2021-08-04 17:49:57 -07:00
void updateProjectionMatrix();
2021-08-04 17:49:57 -07:00
private:
2015-05-14 21:42:04 +02:00
void updateTextureFiltering();
2015-06-11 23:16:05 +02:00
void updateAmbient();
2015-06-02 16:35:35 +02:00
void setFogColor(const osg::Vec4f& color);
2020-06-22 01:54:08 +02:00
void updateThirdPersonViewMode();
2017-03-07 04:02:06 +01:00
void reportStats() const;
2019-01-20 19:27:52 +03:00
void updateNavMesh();
2019-11-27 23:45:01 +01:00
void updateRecastMesh();
osg::ref_ptr<osgUtil::IntersectionVisitor> getIntersectionVisitor(osgUtil::Intersector* intersector, bool ignorePlayer, bool ignoreActors);
osg::ref_ptr<osgUtil::IntersectionVisitor> mIntersectionVisitor;
2015-05-14 21:42:04 +02:00
osg::ref_ptr<osgViewer::Viewer> mViewer;
osg::ref_ptr<osg::Group> mRootNode;
2016-02-08 16:45:56 +01:00
osg::ref_ptr<osg::Group> mSceneRoot;
Resource::ResourceSystem* mResourceSystem;
osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;
osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;
osg::ref_ptr<osg::Light> mSunLight;
2012-04-11 18:53:13 +02:00
DetourNavigator::Navigator& mNavigator;
std::unique_ptr<NavMesh> mNavMesh;
std::size_t mNavMeshNumber = 0;
std::unique_ptr<ActorsPaths> mActorsPaths;
2019-11-27 23:45:01 +01:00
std::unique_ptr<RecastMesh> mRecastMesh;
std::unique_ptr<Pathgrid> mPathgrid;
std::unique_ptr<Objects> mObjects;
std::unique_ptr<Water> mWater;
std::unique_ptr<Terrain::World> mTerrain;
2020-01-12 11:42:47 +04:00
std::unique_ptr<TerrainStorage> mTerrainStorage;
std::unique_ptr<ObjectPaging> mObjectPaging;
2020-01-12 11:42:47 +04:00
std::unique_ptr<Groundcover> mGroundcover;
osg::ref_ptr<GroundcoverUpdater> mGroundcoverUpdater;
std::unique_ptr<SkyManager> mSky;
2020-06-07 10:35:33 +04:00
std::unique_ptr<FogManager> mFog;
std::unique_ptr<ScreenshotManager> mScreenshotManager;
std::unique_ptr<EffectManager> mEffectManager;
2018-02-26 22:27:09 +00:00
std::unique_ptr<SceneUtil::ShadowManager> mShadowManager;
2021-08-04 17:49:57 -07:00
osg::ref_ptr<PostProcessor> mPostProcessor;
osg::ref_ptr<NpcAnimation> mPlayerAnimation;
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> mPlayerNode;
std::unique_ptr<Camera> mCamera;
std::unique_ptr<ViewOverShoulderController> mViewOverShoulderController;
osg::Vec3f mCurrentCameraPos;
osg::ref_ptr<StateUpdater> mStateUpdater;
osg::ref_ptr<SharedUniformStateUpdater> mSharedUniformStateUpdater;
2015-06-11 23:16:05 +02:00
osg::Vec4f mAmbientColor;
2021-03-30 18:12:57 -07:00
float mMinimumAmbientLuminance;
2015-06-11 23:16:05 +02:00
float mNightEyeFactor;
2015-05-24 02:34:20 +02:00
float mNearClip;
float mViewDistance;
2020-06-07 10:35:33 +04:00
bool mFieldOfViewOverridden;
float mFieldOfViewOverride;
float mFieldOfView;
float mFirstPersonFieldOfView;
void operator = (const RenderingManager&);
RenderingManager(const RenderingManager&);
};
2011-10-20 15:02:19 -04:00
}
#endif