2011-10-20 19:02:19 +00:00
|
|
|
#ifndef _GAME_RENDERING_MANAGER_H
|
|
|
|
#define _GAME_RENDERING_MANAGER_H
|
|
|
|
|
|
|
|
#include "sky.hpp"
|
2012-01-21 16:59:08 +00:00
|
|
|
#include "terrain.hpp"
|
2011-10-30 04:25:29 +00:00
|
|
|
#include "debugging.hpp"
|
2011-11-12 05:19:22 +00:00
|
|
|
|
2012-02-18 17:25:28 +00:00
|
|
|
#include <openengine/ogre/fader.hpp>
|
2011-10-20 22:15:30 +00:00
|
|
|
|
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-08 04:35:39 +00:00
|
|
|
|
2011-11-12 05:19:22 +00:00
|
|
|
#include "renderinginterface.hpp"
|
2011-11-24 06:48:54 +00:00
|
|
|
|
2011-11-12 20:58:22 +00:00
|
|
|
#include "objects.hpp"
|
2011-11-24 06:48:54 +00:00
|
|
|
#include "actors.hpp"
|
2011-11-12 20:58:22 +00:00
|
|
|
#include "player.hpp"
|
2012-03-24 12:06:01 +00:00
|
|
|
#include "occlusionquery.hpp"
|
2011-10-20 19:02:19 +00:00
|
|
|
|
2011-10-20 22:15:30 +00:00
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class SceneManager;
|
|
|
|
class SceneNode;
|
|
|
|
class Quaternion;
|
|
|
|
class Vector3;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWWorld
|
2011-10-20 19:02:19 +00:00
|
|
|
{
|
2012-07-03 11:55:53 +00:00
|
|
|
class Ptr;
|
|
|
|
class CellStore;
|
2011-10-20 22:15:30 +00:00
|
|
|
}
|
2011-10-20 19:02:19 +00:00
|
|
|
|
2012-07-03 20:48:16 +00:00
|
|
|
namespace sh
|
|
|
|
{
|
|
|
|
class Factory;
|
|
|
|
}
|
|
|
|
|
2011-10-20 22:15:30 +00:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2012-04-11 16:53:13 +00:00
|
|
|
class Shadows;
|
|
|
|
class LocalMap;
|
|
|
|
class Water;
|
2012-04-29 01:33:10 +00:00
|
|
|
class Compositors;
|
2012-09-14 19:12:16 +00:00
|
|
|
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
|
|
|
|
2012-05-27 19:39:18 +00:00
|
|
|
class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener {
|
2011-10-20 22:15:30 +00:00
|
|
|
|
2011-11-21 11:52:28 +00:00
|
|
|
private:
|
|
|
|
|
2011-11-24 06:48:54 +00:00
|
|
|
|
2011-11-21 11:52:28 +00:00
|
|
|
virtual MWRender::Objects& getObjects();
|
2011-11-24 06:48:54 +00:00
|
|
|
virtual MWRender::Actors& getActors();
|
2011-10-20 22:15:30 +00:00
|
|
|
|
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) {
|
2012-08-17 09:23:02 +00:00
|
|
|
mPlayer->togglePlayerLooking(enable);
|
|
|
|
}
|
|
|
|
|
2012-08-17 06:10:37 +00:00
|
|
|
void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
|
|
|
|
|
2012-08-08 20:15:52 +00:00
|
|
|
void attachCameraTo(const MWWorld::Ptr &ptr);
|
2012-08-14 16:33:29 +00:00
|
|
|
void renderPlayer(const MWWorld::Ptr &ptr);
|
2011-11-21 11:52:28 +00:00
|
|
|
|
2012-02-22 18:17:37 +00:00
|
|
|
SkyManager* getSkyManager();
|
2012-04-29 01:33:10 +00:00
|
|
|
Compositors* getCompositors();
|
2012-02-22 18:17:37 +00:00
|
|
|
|
2011-11-21 11:52:28 +00:00
|
|
|
void toggleLight();
|
|
|
|
bool toggleRenderMode(int mode);
|
2012-03-30 13:38:14 +00:00
|
|
|
|
2012-02-18 17:25:28 +00:00
|
|
|
OEngine::Render::Fader* getFader();
|
2011-11-21 11:52:28 +00:00
|
|
|
|
2012-07-03 11:55:53 +00:00
|
|
|
void removeCell (MWWorld::CellStore *store);
|
2011-11-21 11:52:28 +00:00
|
|
|
|
|
|
|
/// \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.
|
2012-07-03 11:55:53 +00:00
|
|
|
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
|
|
|
|
2012-04-05 17:27:54 +00:00
|
|
|
static const bool useMRT();
|
|
|
|
|
2012-07-03 11:55:53 +00:00
|
|
|
void preCellChange (MWWorld::CellStore* store);
|
2012-03-14 19:44:06 +00:00
|
|
|
///< 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-11-21 11:52:28 +00:00
|
|
|
|
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);
|
2012-08-11 08:13:16 +00:00
|
|
|
|
|
|
|
/// Rotates object accordingly to its type
|
2012-08-11 09:23:54 +00:00
|
|
|
/// \param rot euler angles in radians
|
2012-08-11 08:13:16 +00:00
|
|
|
/// \param adjust indicates should rotation be set or adjusted
|
|
|
|
/// \return true if object needs to be rotated physically
|
2012-08-08 20:15:52 +00:00
|
|
|
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);
|
2012-03-29 16:33:08 +00:00
|
|
|
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).
|
2012-07-03 11:55:53 +00:00
|
|
|
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store);
|
2011-11-21 11:52:28 +00:00
|
|
|
|
2012-11-03 19:29:55 +00:00
|
|
|
void update (float duration, bool paused);
|
2012-03-30 13:38:14 +00:00
|
|
|
|
2012-02-23 20:12:06 +00:00
|
|
|
void setAmbientColour(const Ogre::ColourValue& colour);
|
2012-02-23 19:33:34 +00:00
|
|
|
void setSunColour(const Ogre::ColourValue& colour);
|
|
|
|
void setSunDirection(const Ogre::Vector3& direction);
|
|
|
|
void sunEnable();
|
|
|
|
void sunDisable();
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-04-02 17:37:24 +00:00
|
|
|
void disableLights();
|
|
|
|
void enableLights();
|
|
|
|
|
2012-06-22 10:56:04 +00:00
|
|
|
bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }
|
|
|
|
OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-04-11 16:53:13 +00:00
|
|
|
Shadows* getShadows();
|
|
|
|
|
2012-04-19 18:59:57 +00:00
|
|
|
void switchToInterior();
|
|
|
|
void switchToExterior();
|
|
|
|
|
2012-06-22 10:56:04 +00:00
|
|
|
void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches);
|
|
|
|
|
2012-02-24 15:12:43 +00:00
|
|
|
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);
|
2012-07-03 11:55:53 +00:00
|
|
|
void configureAmbient(MWWorld::CellStore &mCell);
|
2012-03-10 14:28:18 +00:00
|
|
|
|
2012-07-03 11:55:53 +00:00
|
|
|
void requestMap (MWWorld::CellStore* cell);
|
2012-03-10 14:28:18 +00:00
|
|
|
///< request the local map for a cell
|
2012-03-30 13:38:14 +00:00
|
|
|
|
2011-11-21 11:52:28 +00:00
|
|
|
/// configure fog according to cell
|
2012-07-03 11:55:53 +00:00
|
|
|
void configureFog(MWWorld::CellStore &mCell);
|
2012-03-30 13:38:14 +00:00
|
|
|
|
2012-02-26 12:13:29 +00:00
|
|
|
/// configure fog manually
|
|
|
|
void configureFog(const float density, const Ogre::ColourValue& colour);
|
2012-03-30 13:38:14 +00:00
|
|
|
|
2011-11-21 13:08:44 +00:00
|
|
|
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.
|
|
|
|
|
2012-05-14 19:37:43 +00:00
|
|
|
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);
|
|
|
|
|
2012-05-27 19:39:18 +00:00
|
|
|
Ogre::Viewport* getViewport() { return mRendering.getViewport(); }
|
|
|
|
|
2012-05-29 04:45:44 +00:00
|
|
|
static bool waterShaderSupported();
|
|
|
|
|
2012-09-14 19:12:16 +00:00
|
|
|
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
|
|
|
|
|
2012-09-14 19:12:16 +00:00
|
|
|
bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
|
2012-08-28 15:30:34 +00:00
|
|
|
///< see MWRender::LocalMap::isPositionExplored
|
|
|
|
|
2012-09-14 19:12:16 +00:00
|
|
|
void setupExternalRendering (MWRender::ExternalRendering& rendering);
|
2012-09-12 22:54:32 +00:00
|
|
|
|
2013-01-07 12:19:52 +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
|
|
|
|
2012-05-27 19:39:18 +00:00
|
|
|
protected:
|
|
|
|
virtual void windowResized(Ogre::RenderWindow* rw);
|
|
|
|
virtual void windowClosed(Ogre::RenderWindow* rw);
|
|
|
|
|
2011-11-19 06:01:19 +00:00
|
|
|
private:
|
2011-11-21 11:52:28 +00:00
|
|
|
|
2012-07-03 20:48:16 +00:00
|
|
|
sh::Factory* mFactory;
|
|
|
|
|
2011-11-04 03:47:15 +00:00
|
|
|
void setAmbientMode();
|
2012-03-24 12:06:01 +00:00
|
|
|
|
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;
|
2012-03-24 12:06:01 +00:00
|
|
|
|
|
|
|
OcclusionQuery* mOcclusionQuery;
|
|
|
|
|
2012-01-21 16:59:08 +00:00
|
|
|
TerrainManager* mTerrainManager;
|
2012-03-24 14:14:33 +00:00
|
|
|
|
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;
|
2012-01-23 13:33:06 +00:00
|
|
|
|
2011-11-22 07:39:28 +00:00
|
|
|
MWRender::Objects mObjects;
|
2011-11-24 06:48:54 +00:00
|
|
|
MWRender::Actors mActors;
|
2011-11-02 04:13:33 +00:00
|
|
|
|
2011-11-21 11:52:28 +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
|
|
|
|
2011-11-21 11:52:28 +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
|
|
|
|
2011-11-21 11:52:28 +00:00
|
|
|
MWRender::Player *mPlayer;
|
2012-03-29 09:27:13 +00:00
|
|
|
|
2012-03-08 06:46:34 +00:00
|
|
|
MWRender::Debugging *mDebugging;
|
2012-03-10 14:28:18 +00:00
|
|
|
|
|
|
|
MWRender::LocalMap* mLocalMap;
|
2012-04-11 16:53:13 +00:00
|
|
|
|
|
|
|
MWRender::Shadows* mShadows;
|
|
|
|
|
2012-04-29 01:33:10 +00:00
|
|
|
MWRender::Compositors* mCompositors;
|
2012-09-25 00:35:50 +00:00
|
|
|
|
|
|
|
VideoPlayer* mVideoPlayer;
|
2011-10-20 19:02:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|