1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-12 21:39:26 +00:00
OpenMW/apps/openmw/mwrender/renderingmanager.hpp

280 lines
7.6 KiB
C++
Raw Normal View History

2011-10-20 19:02:19 +00:00
#ifndef _GAME_RENDERING_MANAGER_H
#define _GAME_RENDERING_MANAGER_H
#include "sky.hpp"
2011-10-30 04:25:29 +00:00
#include "debugging.hpp"
2011-11-12 05:19:22 +00:00
#include <openengine/ogre/fader.hpp>
2012-05-22 23:32:36 +00:00
#include <components/settings/settings.hpp>
2011-10-20 19:02:19 +00:00
#include <boost/filesystem.hpp>
#include <OgreRenderTargetListener.h>
2011-11-12 05:19:22 +00:00
#include "renderinginterface.hpp"
2011-11-12 20:58:22 +00:00
#include "objects.hpp"
#include "actors.hpp"
2013-04-29 12:50:40 +00:00
#include "camera.hpp"
#include "occlusionquery.hpp"
2011-10-20 19:02:19 +00:00
namespace Ogre
{
class SceneManager;
class SceneNode;
class Quaternion;
class Vector3;
}
namespace MWWorld
2011-10-20 19:02:19 +00:00
{
class Ptr;
class CellStore;
}
2011-10-20 19:02:19 +00:00
2012-07-03 20:48:16 +00:00
namespace sh
{
class Factory;
}
namespace Terrain
{
class World;
}
namespace MWRender
{
2012-04-11 16:53:13 +00:00
class Shadows;
class LocalMap;
class Water;
class Compositors;
class ExternalRendering;
2012-09-20 11:56:37 +00:00
class GlobalMap;
2012-09-25 00:35:50 +00:00
class VideoPlayer;
class Animation;
2011-10-22 04:15:15 +00:00
2013-07-29 00:32:08 +00:00
class RenderingManager: private RenderingInterface, public Ogre::RenderTargetListener, public OEngine::Render::WindowSizeListener
2013-04-29 12:50:40 +00:00
{
private:
virtual MWRender::Objects& getObjects();
virtual MWRender::Actors& getActors();
2013-04-29 12:50:40 +00:00
public:
2012-09-02 17:40:26 +00:00
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
2013-04-29 12:50:40 +00:00
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,
MWWorld::Fallback* fallback);
2011-11-12 20:58:22 +00:00
virtual ~RenderingManager();
2011-11-04 03:47:15 +00:00
2013-04-29 12:50:40 +00:00
void togglePOV()
{ mCamera->toggleViewMode(); }
2012-08-12 11:50:37 +00:00
2013-04-29 12:50:40 +00:00
void togglePreviewMode(bool enable)
{ mCamera->togglePreviewMode(enable); }
2012-08-14 10:37:48 +00:00
2013-04-29 12:50:40 +00:00
bool toggleVanityMode(bool enable)
{ return mCamera->toggleVanityMode(enable); }
2012-08-14 10:37:48 +00:00
2013-04-29 12:50:40 +00:00
void allowVanityMode(bool allow)
{ mCamera->allowVanityMode(allow); }
2012-08-14 10:37:48 +00:00
2013-04-29 12:50:40 +00:00
void togglePlayerLooking(bool enable)
{ mCamera->togglePlayerLooking(enable); }
2013-04-29 12:50:40 +00:00
void changeVanityModeScale(float factor)
{
if(mCamera->isVanityOrPreviewModeEnabled())
mCamera->setCameraDistance(-factor/120.f*10, true, true);
}
2013-05-17 20:53:43 +00:00
void resetCamera();
2013-04-29 12:50:40 +00:00
bool vanityRotateCamera(const float *rot);
void setCameraDistance(float dist, bool adjust = false, bool override = true);
void setupPlayer(const MWWorld::Ptr &ptr);
2012-08-14 16:33:29 +00:00
void renderPlayer(const MWWorld::Ptr &ptr);
SkyManager* getSkyManager();
Compositors* getCompositors();
void toggleLight();
bool toggleRenderMode(int mode);
OEngine::Render::Fader* getFader();
void removeCell (MWWorld::CellStore *store);
/// \todo this function should be removed later. Instead the rendering subsystems should track
/// when rebatching is needed and update automatically at the end of each frame.
void cellAdded (MWWorld::CellStore *store);
void waterAdded(MWWorld::CellStore *store);
2011-10-20 19:02:19 +00:00
2013-08-20 07:52:27 +00:00
void enableTerrain(bool enable);
2012-01-22 01:05:08 +00:00
void removeWater();
2011-10-20 19:02:19 +00:00
void preCellChange (MWWorld::CellStore* store);
///< this event is fired immediately before changing cell
2011-11-11 05:20:53 +00:00
void addObject (const MWWorld::Ptr& ptr);
void removeObject (const MWWorld::Ptr& ptr);
2011-10-20 19:02:19 +00:00
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
2013-04-28 08:14:58 +00:00
/// Updates an object's rotation
void rotateObject (const MWWorld::Ptr& ptr);
2011-11-11 05:20:53 +00:00
2012-03-29 13:49:24 +00:00
void setWaterHeight(const float height);
void toggleWater();
2011-11-11 05:20:53 +00:00
/// Updates object rendering after cell change
/// \param old Object reference in previous cell
/// \param cur Object reference in new cell
void updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur);
/// Specifies an updated Ptr object for the player (used on cell change).
void updatePlayerPtr(const MWWorld::Ptr &ptr);
/// Currently for NPCs only. Rebuilds the NPC, updating their root model, animation sources,
/// and equipment.
void rebuildPtr(const MWWorld::Ptr &ptr);
void update (float duration, bool paused);
void setAmbientColour(const Ogre::ColourValue& colour);
void setSunColour(const Ogre::ColourValue& colour);
void setSunDirection(const Ogre::Vector3& direction);
void sunEnable(bool real); ///< @param real whether or not to really disable the sunlight (otherwise just set diffuse to 0)
void sunDisable(bool real);
void disableLights(bool sun); ///< @param sun whether or not to really disable the sunlight (otherwise just set diffuse to 0)
void enableLights(bool sun);
2012-04-02 17:37:24 +00:00
void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }
OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }
float getTerrainHeightAt (Ogre::Vector3 worldPos);
2012-04-11 16:53:13 +00:00
Shadows* getShadows();
2012-04-19 18:59:57 +00:00
void switchToInterior();
void switchToExterior();
void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches);
void setGlare(bool glare);
2011-10-20 19:02:19 +00:00
void skyEnable ();
void skyDisable ();
void skySetHour (double hour);
void skySetDate (int day, int month);
int skyGetMasserPhase() const;
int skyGetSecundaPhase() const;
void skySetMoonColour (bool red);
void configureAmbient(MWWorld::CellStore &mCell);
2013-02-27 08:20:42 +00:00
void addWaterRippleEmitter (const MWWorld::Ptr& ptr, float scale = 1.f, float force = 1.f);
void removeWaterRippleEmitter (const MWWorld::Ptr& ptr);
void updateWaterRippleEmitterPtr (const MWWorld::Ptr& old, const MWWorld::Ptr& ptr);
void requestMap (MWWorld::CellStore* cell);
///< request the local map for a cell
/// configure fog according to cell
void configureFog(MWWorld::CellStore &mCell);
2012-02-26 12:13:29 +00:00
/// configure fog manually
void configureFog(const float density, const Ogre::ColourValue& colour);
Ogre::Vector4 boundingBoxToScreen(Ogre::AxisAlignedBox bounds);
///< transform the specified bounding box (in world coordinates) into screen coordinates.
/// @return packed vector4 (min_x, min_y, max_x, max_y)
2012-05-22 23:32:36 +00:00
void processChangedSettings(const Settings::CategorySettingVector& settings);
Ogre::Viewport* getViewport() { return mRendering.getViewport(); }
void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y);
2012-08-28 15:30:34 +00:00
///< see MWRender::LocalMap::getInteriorMapPosition
bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
2012-08-28 15:30:34 +00:00
///< see MWRender::LocalMap::isPositionExplored
void setupExternalRendering (MWRender::ExternalRendering& rendering);
2012-09-12 22:54:32 +00:00
Animation* getAnimation(const MWWorld::Ptr &ptr);
void playVideo(const std::string& name, bool allowSkipping);
2012-12-12 00:13:53 +00:00
void stopVideo();
void frameStarted(float dt, bool paused);
2012-09-25 00:35:50 +00:00
2013-04-29 12:50:40 +00:00
protected:
2013-07-29 00:32:08 +00:00
virtual void windowResized(int x, int y);
2013-04-29 12:50:40 +00:00
private:
2012-07-03 20:48:16 +00:00
sh::Factory* mFactory;
2011-11-04 03:47:15 +00:00
void setAmbientMode();
void applyFog(bool underwater);
2012-05-22 23:32:36 +00:00
void setMenuTransparency(float val);
2012-05-29 04:45:44 +00:00
void applyCompositors();
2012-04-11 16:53:13 +00:00
bool mSunEnabled;
MWWorld::Fallback* mFallback;
2011-10-20 19:02:19 +00:00
SkyManager* mSkyManager;
OcclusionQuery* mOcclusionQuery;
Terrain::World* mTerrain;
2012-03-29 13:49:24 +00:00
MWRender::Water *mWater;
2011-11-02 04:13:33 +00:00
2012-09-20 11:56:37 +00:00
GlobalMap* mGlobalMap;
2011-11-22 07:39:28 +00:00
OEngine::Render::OgreRenderer &mRendering;
MWRender::Objects* mObjects;
MWRender::Actors* mActors;
2011-11-02 04:13:33 +00:00
MWRender::NpcAnimation *mPlayerAnimation;
// 0 normal, 1 more bright, 2 max
2011-11-04 03:47:15 +00:00
int mAmbientMode;
Ogre::ColourValue mAmbientColor;
2012-02-07 23:32:22 +00:00
Ogre::Light* mSun;
2011-11-04 03:47:15 +00:00
2013-02-26 13:01:10 +00:00
Ogre::SceneNode *mRootNode;
2011-11-02 04:13:33 +00:00
2013-02-27 08:20:42 +00:00
Ogre::ColourValue mFogColour;
float mFogStart;
float mFogEnd;
2011-11-22 07:39:28 +00:00
OEngine::Physic::PhysicEngine* mPhysicsEngine;
2011-11-02 04:13:33 +00:00
2013-04-29 12:50:40 +00:00
MWRender::Camera *mCamera;
MWRender::Debugging *mDebugging;
MWRender::LocalMap* mLocalMap;
2012-04-11 16:53:13 +00:00
MWRender::Shadows* mShadows;
MWRender::Compositors* mCompositors;
2012-09-25 00:35:50 +00:00
VideoPlayer* mVideoPlayer;
2011-10-20 19:02:19 +00:00
};
}
#endif