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

301 lines
9 KiB
C++
Raw Normal View History

#ifndef OPENMW_MWRENDER_RENDERINGMANAGER_H
#define OPENMW_MWRENDER_RENDERINGMANAGER_H
2011-10-20 19:02:19 +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
#include <components/settings/settings.hpp>
#include "objects.hpp"
2011-11-12 05:19:22 +00:00
#include "renderinginterface.hpp"
2015-05-02 20:45:27 +00:00
#include "rendermode.hpp"
#include <deque>
namespace osg
{
class Group;
2015-05-01 16:21:50 +00:00
class PositionAttitudeTransform;
}
namespace osgUtil
{
class IntersectionVisitor;
class Intersector;
}
namespace Resource
2011-10-20 19:02:19 +00:00
{
class ResourceSystem;
}
2011-10-20 19:02:19 +00:00
namespace osgViewer
2012-07-03 20:48:16 +00:00
{
class Viewer;
2012-07-03 20:48:16 +00:00
}
namespace ESM
{
struct Cell;
}
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
}
namespace SceneUtil
{
class WorkQueue;
class UnrefQueue;
}
namespace DetourNavigator
{
class Navigator;
struct Settings;
}
namespace MWRender
{
2012-08-12 11:50:37 +00:00
class StateUpdater;
2015-04-19 15:55:56 +00:00
class EffectManager;
class SkyManager;
2015-05-01 16:21:50 +00:00
class NpcAnimation;
class Pathgrid;
2015-05-21 21:54:39 +00:00
class Camera;
2015-06-02 14:35:35 +00:00
class Water;
class TerrainStorage;
class LandManager;
class NavMesh;
class ActorsPaths;
class RenderingManager : public MWRender::RenderingInterface
2013-04-29 12:50:40 +00:00
{
public:
RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr<osg::Group> rootNode,
Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
const Fallback::Map* fallback, const std::string& resourcePath,
DetourNavigator::Navigator& navigator);
~RenderingManager();
2014-01-17 09:52:44 +00:00
MWRender::Objects& getObjects();
Resource::ResourceSystem* getResourceSystem();
2011-11-04 03:47:15 +00:00
SceneUtil::WorkQueue* getWorkQueue();
SceneUtil::UnrefQueue* getUnrefQueue();
2016-02-09 19:57:30 +00:00
Terrain::World* getTerrain();
osg::Uniform* mUniformNear;
osg::Uniform* mUniformFar;
2016-02-09 00:17:02 +00:00
void preloadCommonAssets();
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);
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);
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 20:45:27 +00:00
void addCell(const MWWorld::CellStore* store);
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.
2017-11-15 15:07:01 +00:00
void screenshot(osg::Image* image, int w, int h, osg::Matrixd cameraTransform=osg::Matrixd());
bool screenshot360(osg::Image* image, std::string settingStr);
2015-06-03 14:40:16 +00:00
struct RayResult
{
bool mHit;
osg::Vec3f mHitNormalWorld;
osg::Vec3f mHitPointWorld;
MWWorld::Ptr mHitObject;
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 MWWorld::Ptr& ptr);
void setSkyEnabled(bool enabled);
2015-05-02 20:45:27 +00:00
bool toggleRenderMode(RenderMode mode);
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);
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);
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();
const osg::Vec3f& getCameraPosition() const;
2015-05-21 21:54:39 +00:00
void togglePOV();
void togglePreviewMode(bool enable);
bool toggleVanityMode(bool enable);
void allowVanityMode(bool allow);
void togglePlayerLooking(bool enable);
void changeVanityModeScale(float factor);
/// 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-12 23:48:31 +00: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;
private:
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);
2017-03-07 03:02:06 +00:00
void reportStats() const;
2017-11-15 14:20:59 +00:00
void renderCameraToImage(osg::Camera *camera, osg::Image *image, int w, int h);
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;
osg::ref_ptr<osg::Group> mRootNode;
2016-02-08 15:45:56 +00: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 16:53:13 +00:00
DetourNavigator::Navigator& mNavigator;
std::unique_ptr<NavMesh> mNavMesh;
std::unique_ptr<ActorsPaths> mActorsPaths;
std::unique_ptr<Pathgrid> mPathgrid;
std::unique_ptr<Objects> mObjects;
std::unique_ptr<Water> mWater;
std::unique_ptr<Terrain::World> mTerrain;
TerrainStorage* mTerrainStorage;
std::unique_ptr<SkyManager> mSky;
std::unique_ptr<EffectManager> mEffectManager;
osg::ref_ptr<NpcAnimation> mPlayerAnimation;
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> mPlayerNode;
std::unique_ptr<Camera> mCamera;
osg::Vec3f mCurrentCameraPos;
osg::ref_ptr<StateUpdater> mStateUpdater;
float mLandFogStart;
float mLandFogEnd;
float mUnderwaterFogStart;
float mUnderwaterFogEnd;
osg::Vec4f mUnderwaterColor;
float mUnderwaterWeight;
float mUnderwaterIndoorFog;
2015-06-02 14:35:35 +00:00
osg::Vec4f mFogColor;
2015-06-11 21:16:05 +00:00
osg::Vec4f mAmbientColor;
float mNightEyeFactor;
2015-05-24 00:34:20 +00:00
float mNearClip;
float mViewDistance;
bool mDistantFog : 1;
bool mDistantTerrain : 1;
bool mFieldOfViewOverridden : 1;
float mFieldOfViewOverride;
float mFieldOfView;
float mFirstPersonFieldOfView;
2018-06-12 23:48:31 +00:00
bool mBorders;
void operator = (const RenderingManager&);
RenderingManager(const RenderingManager&);
};
2011-10-20 19:02:19 +00:00
}
#endif