1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 09:36:37 +00:00
OpenMW/apps/openmw/mwrender/renderingmanager.hpp

262 lines
7.1 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"
#include "terrain.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>
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"
2011-11-12 20:58:22 +00:00
#include "player.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 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;
2011-10-22 04:15:15 +00:00
class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener {
private:
virtual MWRender::Objects& getObjects();
virtual MWRender::Actors& getActors();
2011-10-20 19:02:19 +00:00
public:
2012-09-02 17:40:26 +00:00
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine);
2011-11-12 20:58:22 +00:00
virtual ~RenderingManager();
2011-11-04 03:47:15 +00:00
2012-08-12 11:50:37 +00:00
void togglePOV() {
mPlayer->toggleViewMode();
}
2012-08-14 10:37:48 +00:00
void togglePreviewMode(bool enable) {
mPlayer->togglePreviewMode(enable);
}
2012-08-18 14:05:10 +00:00
bool toggleVanityMode(bool enable, bool force) {
2012-08-14 10:37:48 +00:00
return mPlayer->toggleVanityMode(enable, force);
}
2012-08-18 14:05:10 +00:00
void allowVanityMode(bool allow) {
2012-08-14 10:37:48 +00:00
mPlayer->allowVanityMode(allow);
}
2012-08-18 14:05:10 +00:00
void togglePlayerLooking(bool enable) {
mPlayer->togglePlayerLooking(enable);
}
void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
void attachCameraTo(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
2012-01-22 01:05:08 +00:00
void removeWater();
2011-10-20 19:02:19 +00:00
static const bool useMRT();
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);
/// Rotates object accordingly to its type
2012-08-11 09:23:54 +00:00
/// \param rot euler angles in radians
/// \param adjust indicates should rotation be set or adjusted
/// \return true if object needs to be rotated physically
bool rotateObject (const MWWorld::Ptr& ptr, Ogre::Vector3 &rot, bool adjust = false);
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
2012-07-31 12:52:21 +00:00
/// Moves object rendering part to proper container
2011-11-11 05:20:53 +00:00
/// \param store Cell the object was in previously (\a ptr has already been updated to the new cell).
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store);
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();
void sunDisable();
2012-04-02 17:37:24 +00:00
void disableLights();
void enableLights();
bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }
OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }
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);
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);
void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
int number = 1);
///< Run animation for a MW-reference. Calls to this function for references that are currently not
/// in the rendered scene should be ignored.
///
/// \param mode: 0 normal, 1 immediate start, 2 immediate loop
/// \param number How offen the animation should be run
void skipAnimation (const MWWorld::Ptr& ptr);
///< Skip the animation for the given MW-reference for one frame. Calls to this function for
/// references that are currently not in the rendered scene should be ignored.
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(); }
2012-05-29 04:45:44 +00:00
static bool waterShaderSupported();
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
void playVideo(const std::string& name, bool allowSkipping);
2012-12-12 00:13:53 +00:00
void stopVideo();
2012-09-25 00:35:50 +00:00
protected:
virtual void windowResized(Ogre::RenderWindow* rw);
virtual void windowClosed(Ogre::RenderWindow* rw);
private:
2012-07-03 20:48:16 +00:00
sh::Factory* mFactory;
2011-11-04 03:47:15 +00:00
void setAmbientMode();
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;
2011-10-20 19:02:19 +00:00
SkyManager* mSkyManager;
OcclusionQuery* mOcclusionQuery;
TerrainManager* mTerrainManager;
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;
2011-11-22 07:39:28 +00:00
MWRender::Objects mObjects;
MWRender::Actors mActors;
2011-11-02 04:13:33 +00:00
// 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
/// Root node for all objects added to the scene. This is rotated so
/// that the OGRE coordinate system matches that used internally in
/// Morrowind.
2011-11-22 07:39:28 +00:00
Ogre::SceneNode *mMwRoot;
2011-11-02 04:13:33 +00:00
2011-11-22 07:39:28 +00:00
OEngine::Physic::PhysicEngine* mPhysicsEngine;
2011-11-02 04:13:33 +00:00
MWRender::Player *mPlayer;
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