openmw-tes3coop/apps/openmw/mwrender/renderingmanager.hpp

218 lines
6.3 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>
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"
namespace osg
{
class Group;
2015-05-01 16:21:50 +00:00
class PositionAttitudeTransform;
}
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;
}
2015-06-16 18:36:48 +00:00
namespace MWWorld
{
class Fallback;
}
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 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,
const MWWorld::Fallback* fallback, const std::string& resourcePath);
~RenderingManager();
2014-01-17 09:52:44 +00:00
MWRender::Objects& getObjects();
Resource::ResourceSystem* getResourceSystem();
2011-11-04 03:47:15 +00:00
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& colour);
void configureAmbient(const ESM::Cell* cell);
void configureFog(const ESM::Cell* cell);
void configureFog(float fogDepth, float underwaterFog, 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
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.
void screenshot(osg::Image* image, int w, int h);
struct RayResult
{
bool mHit;
osg::Vec3f mHitNormalWorld;
osg::Vec3f mHitPointWorld;
MWWorld::Ptr mHitObject;
};
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();
osg::Vec3f getEyePos();
2011-11-02 04:13:33 +00:00
2015-04-19 15:55:56 +00:00
void spawnEffect(const std::string &model, const std::string &texture, const osg::Vec3f &worldPosition, float scale = 1.f);
/// 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);
Animation* getPlayerAnimation();
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);
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);
2015-05-14 19:42:04 +00:00
osg::ref_ptr<osgViewer::Viewer> mViewer;
osg::ref_ptr<osg::Group> mRootNode;
2015-05-01 16:21:50 +00:00
osg::ref_ptr<osg::Group> mLightRoot;
Resource::ResourceSystem* mResourceSystem;
osg::ref_ptr<osg::Light> mSunLight;
2012-04-11 16:53:13 +00:00
std::auto_ptr<Pathgrid> mPathgrid;
std::auto_ptr<Objects> mObjects;
2015-06-02 14:35:35 +00:00
std::auto_ptr<Water> mWater;
2015-06-02 23:18:36 +00:00
std::auto_ptr<Terrain::World> mTerrain;
std::auto_ptr<SkyManager> mSky;
2015-04-19 15:55:56 +00:00
std::auto_ptr<EffectManager> mEffectManager;
2015-05-01 16:21:50 +00:00
std::auto_ptr<NpcAnimation> mPlayerAnimation;
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> mPlayerNode;
2015-05-21 21:54:39 +00:00
std::auto_ptr<Camera> mCamera;
osg::Vec3f mCurrentCameraPos;
osg::ref_ptr<StateUpdater> mStateUpdater;
float mFogDepth;
osg::Vec4f mUnderwaterColor;
float mUnderwaterWeight;
float mUnderwaterFog;
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;
float mFieldOfView;
void operator = (const RenderingManager&);
RenderingManager(const RenderingManager&);
};
2011-10-20 19:02:19 +00:00
}
#endif