2014-01-05 18:22:29 +01:00
|
|
|
#ifndef GAME_RENDERING_MANAGER_H
|
|
|
|
#define GAME_RENDERING_MANAGER_H
|
2011-10-20 15:02:19 -04:00
|
|
|
|
|
|
|
#include "sky.hpp"
|
2011-10-30 00:25:29 -04:00
|
|
|
#include "debugging.hpp"
|
2011-11-12 00:19:22 -05:00
|
|
|
|
2012-05-23 01:32:36 +02:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
2011-10-20 15:02:19 -04:00
|
|
|
#include <boost/filesystem.hpp>
|
2011-11-07 23:35:39 -05:00
|
|
|
|
2013-02-03 18:03:09 +01:00
|
|
|
#include <OgreRenderTargetListener.h>
|
|
|
|
|
2011-11-12 00:19:22 -05:00
|
|
|
#include "renderinginterface.hpp"
|
2011-11-24 01:48:54 -05:00
|
|
|
|
2011-11-12 15:58:22 -05:00
|
|
|
#include "objects.hpp"
|
2011-11-24 01:48:54 -05:00
|
|
|
#include "actors.hpp"
|
2013-04-29 05:50:40 -07:00
|
|
|
#include "camera.hpp"
|
2012-03-24 13:06:01 +01:00
|
|
|
#include "occlusionquery.hpp"
|
2011-10-20 15:02:19 -04:00
|
|
|
|
2011-10-20 18:15:30 -04:00
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class SceneNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWWorld
|
2011-10-20 15:02:19 -04:00
|
|
|
{
|
2012-07-03 13:55:53 +02:00
|
|
|
class Ptr;
|
|
|
|
class CellStore;
|
2011-10-20 18:15:30 -04:00
|
|
|
}
|
2011-10-20 15:02:19 -04:00
|
|
|
|
2012-07-03 22:48:16 +02:00
|
|
|
namespace sh
|
|
|
|
{
|
|
|
|
class Factory;
|
|
|
|
}
|
|
|
|
|
2013-08-16 13:01:52 +02:00
|
|
|
namespace Terrain
|
|
|
|
{
|
2013-08-27 16:01:16 +02:00
|
|
|
class World;
|
2013-08-16 13:01:52 +02:00
|
|
|
}
|
|
|
|
|
2011-10-20 18:15:30 -04:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2012-04-11 18:53:13 +02:00
|
|
|
class Shadows;
|
|
|
|
class LocalMap;
|
|
|
|
class Water;
|
2012-09-20 13:56:37 +02:00
|
|
|
class GlobalMap;
|
2013-01-16 09:59:19 -08:00
|
|
|
class Animation;
|
2014-01-17 10:52:44 +01:00
|
|
|
class EffectManager;
|
2011-10-22 00:15:15 -04:00
|
|
|
|
2013-07-29 02:32:08 +02:00
|
|
|
class RenderingManager: private RenderingInterface, public Ogre::RenderTargetListener, public OEngine::Render::WindowSizeListener
|
2013-04-29 05:50:40 -07:00
|
|
|
{
|
|
|
|
private:
|
2011-11-21 12:52:28 +01:00
|
|
|
virtual MWRender::Objects& getObjects();
|
2011-11-24 01:48:54 -05:00
|
|
|
virtual MWRender::Actors& getActors();
|
2011-10-20 18:15:30 -04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
public:
|
2012-09-02 19:40:26 +02:00
|
|
|
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
2013-04-29 05:50:40 -07:00
|
|
|
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,
|
|
|
|
MWWorld::Fallback* fallback);
|
2011-11-12 15:58:22 -05:00
|
|
|
virtual ~RenderingManager();
|
2011-11-03 23:47:15 -04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
void togglePOV()
|
|
|
|
{ mCamera->toggleViewMode(); }
|
2012-08-12 15:50:37 +04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
void togglePreviewMode(bool enable)
|
|
|
|
{ mCamera->togglePreviewMode(enable); }
|
2012-08-14 14:37:48 +04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
bool toggleVanityMode(bool enable)
|
|
|
|
{ return mCamera->toggleVanityMode(enable); }
|
2012-08-14 14:37:48 +04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
void allowVanityMode(bool allow)
|
|
|
|
{ mCamera->allowVanityMode(allow); }
|
2012-08-14 14:37:48 +04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
void togglePlayerLooking(bool enable)
|
|
|
|
{ mCamera->togglePlayerLooking(enable); }
|
2012-08-17 13:23:02 +04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
void changeVanityModeScale(float factor)
|
|
|
|
{
|
|
|
|
if(mCamera->isVanityOrPreviewModeEnabled())
|
|
|
|
mCamera->setCameraDistance(-factor/120.f*10, true, true);
|
2013-03-08 00:12:56 +01:00
|
|
|
}
|
|
|
|
|
2013-05-17 22:53:43 +02:00
|
|
|
void resetCamera();
|
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
bool vanityRotateCamera(const float *rot);
|
2013-07-20 16:55:35 +02:00
|
|
|
void setCameraDistance(float dist, bool adjust = false, bool override = true);
|
2014-01-01 23:59:17 +01:00
|
|
|
float getCameraDistance() const;
|
2013-04-09 19:24:41 +01:00
|
|
|
|
2013-04-28 23:44:44 -07:00
|
|
|
void setupPlayer(const MWWorld::Ptr &ptr);
|
2012-08-14 20:33:29 +04:00
|
|
|
void renderPlayer(const MWWorld::Ptr &ptr);
|
2011-11-21 12:52:28 +01:00
|
|
|
|
2012-02-22 19:17:37 +01:00
|
|
|
SkyManager* getSkyManager();
|
|
|
|
|
2013-12-15 18:50:25 +02:00
|
|
|
MWRender::Camera* getCamera() const;
|
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
void toggleLight();
|
|
|
|
bool toggleRenderMode(int mode);
|
2012-03-30 15:38:14 +02:00
|
|
|
|
2012-07-03 13:55:53 +02:00
|
|
|
void removeCell (MWWorld::CellStore *store);
|
2011-11-21 12:52:28 +01: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 13:55:53 +02:00
|
|
|
void cellAdded (MWWorld::CellStore *store);
|
|
|
|
void waterAdded(MWWorld::CellStore *store);
|
2011-10-20 15:02:19 -04:00
|
|
|
|
2014-05-11 02:07:28 +02:00
|
|
|
/// Clear all savegame-specific data (i.e. fog of war textures)
|
|
|
|
void clear();
|
|
|
|
|
2013-08-20 09:52:27 +02:00
|
|
|
void enableTerrain(bool enable);
|
|
|
|
|
2012-01-21 20:05:08 -05:00
|
|
|
void removeWater();
|
2011-10-20 15:02:19 -04:00
|
|
|
|
2014-05-11 02:07:28 +02:00
|
|
|
/// Write current fog of war for this cell to the CellStore
|
|
|
|
void writeFog (MWWorld::CellStore* store);
|
2012-03-14 20:44:06 +01:00
|
|
|
|
2011-11-11 00:20:53 -05:00
|
|
|
void addObject (const MWWorld::Ptr& ptr);
|
|
|
|
void removeObject (const MWWorld::Ptr& ptr);
|
2011-11-21 12:52:28 +01:00
|
|
|
|
2011-10-20 15:02:19 -04:00
|
|
|
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
|
|
|
|
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
|
2012-08-11 12:13:16 +04:00
|
|
|
|
2013-04-28 01:14:58 -07:00
|
|
|
/// Updates an object's rotation
|
|
|
|
void rotateObject (const MWWorld::Ptr& ptr);
|
2011-11-11 00:20:53 -05:00
|
|
|
|
2012-03-29 15:49:24 +02:00
|
|
|
void setWaterHeight(const float height);
|
2014-05-16 09:21:08 +02:00
|
|
|
bool toggleWater();
|
2011-11-11 00:20:53 -05:00
|
|
|
|
2013-02-24 14:59:21 +04: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);
|
2011-11-21 12:52:28 +01:00
|
|
|
|
2013-07-17 19:11:03 -07:00
|
|
|
/// Specifies an updated Ptr object for the player (used on cell change).
|
|
|
|
void updatePlayerPtr(const MWWorld::Ptr &ptr);
|
|
|
|
|
2013-08-08 17:16:24 -07:00
|
|
|
/// Currently for NPCs only. Rebuilds the NPC, updating their root model, animation sources,
|
|
|
|
/// and equipment.
|
|
|
|
void rebuildPtr(const MWWorld::Ptr &ptr);
|
|
|
|
|
2012-11-03 19:29:55 +00:00
|
|
|
void update (float duration, bool paused);
|
2012-03-30 15:38:14 +02:00
|
|
|
|
2012-02-23 21:12:06 +01:00
|
|
|
void setAmbientColour(const Ogre::ColourValue& colour);
|
2012-02-23 20:33:34 +01:00
|
|
|
void setSunColour(const Ogre::ColourValue& colour);
|
2014-06-16 17:08:02 -04:00
|
|
|
void setSunDirection(const Ogre::Vector3& direction, bool is_moon);
|
2013-02-03 15:46:23 +01:00
|
|
|
void sunEnable(bool real); ///< @param real whether or not to really disable the sunlight (otherwise just set diffuse to 0)
|
|
|
|
void sunDisable(bool real);
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2013-02-03 15:46:23 +01:00
|
|
|
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 19:37:24 +02:00
|
|
|
|
2013-02-03 18:03:09 +01:00
|
|
|
|
|
|
|
void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
|
|
|
|
void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
|
|
|
|
|
2012-06-22 12:56:04 +02:00
|
|
|
bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }
|
|
|
|
OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2013-08-19 20:30:22 +02:00
|
|
|
float getTerrainHeightAt (Ogre::Vector3 worldPos);
|
|
|
|
|
2012-04-11 18:53:13 +02:00
|
|
|
Shadows* getShadows();
|
|
|
|
|
2014-05-17 05:21:17 +02:00
|
|
|
void notifyWorldSpaceChanged();
|
2012-04-19 20:59:57 +02:00
|
|
|
|
2012-06-22 12:56:04 +02:00
|
|
|
void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches);
|
|
|
|
|
2012-02-24 16:12:43 +01:00
|
|
|
void setGlare(bool glare);
|
2011-10-20 15:02:19 -04: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 13:55:53 +02:00
|
|
|
void configureAmbient(MWWorld::CellStore &mCell);
|
2012-03-10 15:28:18 +01:00
|
|
|
|
2013-02-27 09:20:42 +01: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);
|
|
|
|
|
2014-03-05 21:45:43 +01:00
|
|
|
void updateTerrain ();
|
|
|
|
///< update the terrain according to the player position. Usually done automatically, but should be done manually
|
|
|
|
/// before calling requestMap
|
|
|
|
|
2012-07-03 13:55:53 +02:00
|
|
|
void requestMap (MWWorld::CellStore* cell);
|
2012-03-10 15:28:18 +01:00
|
|
|
///< request the local map for a cell
|
2012-03-30 15:38:14 +02:00
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
/// configure fog according to cell
|
2012-07-03 13:55:53 +02:00
|
|
|
void configureFog(MWWorld::CellStore &mCell);
|
2012-03-30 15:38:14 +02:00
|
|
|
|
2012-02-26 13:13:29 +01:00
|
|
|
/// configure fog manually
|
|
|
|
void configureFog(const float density, const Ogre::ColourValue& colour);
|
2012-03-30 15:38:14 +02:00
|
|
|
|
2012-05-14 21:37:43 +02: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-23 01:32:36 +02:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
|
|
|
|
2012-05-27 21:39:18 +02:00
|
|
|
Ogre::Viewport* getViewport() { return mRendering.getViewport(); }
|
|
|
|
|
2012-09-14 21:12:16 +02:00
|
|
|
void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y);
|
2012-08-28 17:30:34 +02:00
|
|
|
///< see MWRender::LocalMap::getInteriorMapPosition
|
|
|
|
|
2012-09-14 21:12:16 +02:00
|
|
|
bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
|
2012-08-28 17:30:34 +02:00
|
|
|
///< see MWRender::LocalMap::isPositionExplored
|
|
|
|
|
2013-01-16 09:59:19 -08:00
|
|
|
Animation* getAnimation(const MWWorld::Ptr &ptr);
|
|
|
|
|
2013-08-19 20:30:22 +02:00
|
|
|
void frameStarted(float dt, bool paused);
|
2014-01-24 17:49:16 +01:00
|
|
|
void screenshot(Ogre::Image& image, int w, int h);
|
2012-09-25 02:35:50 +02:00
|
|
|
|
2014-01-20 13:00:43 +01:00
|
|
|
void spawnEffect (const std::string& model, const std::string& texture, const Ogre::Vector3& worldPosition, float scale=1.f);
|
2014-01-17 10:52:44 +01:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
protected:
|
2013-07-29 02:32:08 +02:00
|
|
|
virtual void windowResized(int x, int y);
|
2012-05-27 21:39:18 +02:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
private:
|
2012-07-03 22:48:16 +02:00
|
|
|
sh::Factory* mFactory;
|
|
|
|
|
2011-11-03 23:47:15 -04:00
|
|
|
void setAmbientMode();
|
2013-03-03 19:28:11 +01:00
|
|
|
void applyFog(bool underwater);
|
2012-03-24 13:06:01 +01:00
|
|
|
|
2012-05-23 01:32:36 +02:00
|
|
|
void setMenuTransparency(float val);
|
|
|
|
|
2012-04-11 18:53:13 +02:00
|
|
|
bool mSunEnabled;
|
|
|
|
|
2013-03-15 10:17:30 +01:00
|
|
|
MWWorld::Fallback* mFallback;
|
|
|
|
|
2011-10-20 15:02:19 -04:00
|
|
|
SkyManager* mSkyManager;
|
2012-03-24 13:06:01 +01:00
|
|
|
|
|
|
|
OcclusionQuery* mOcclusionQuery;
|
|
|
|
|
2013-08-27 16:01:16 +02:00
|
|
|
Terrain::World* mTerrain;
|
2012-03-24 15:14:33 +01:00
|
|
|
|
2012-03-29 15:49:24 +02:00
|
|
|
MWRender::Water *mWater;
|
2011-11-02 00:13:33 -04:00
|
|
|
|
2012-09-20 13:56:37 +02:00
|
|
|
GlobalMap* mGlobalMap;
|
|
|
|
|
2011-11-22 02:39:28 -05:00
|
|
|
OEngine::Render::OgreRenderer &mRendering;
|
2012-01-23 14:33:06 +01:00
|
|
|
|
2013-12-08 23:05:21 +01:00
|
|
|
MWRender::Objects* mObjects;
|
|
|
|
MWRender::Actors* mActors;
|
2011-11-02 00:13:33 -04:00
|
|
|
|
2014-01-17 10:52:44 +01:00
|
|
|
MWRender::EffectManager* mEffectManager;
|
|
|
|
|
2013-04-29 03:31:46 -07:00
|
|
|
MWRender::NpcAnimation *mPlayerAnimation;
|
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
// 0 normal, 1 more bright, 2 max
|
2011-11-03 23:47:15 -04:00
|
|
|
int mAmbientMode;
|
|
|
|
|
|
|
|
Ogre::ColourValue mAmbientColor;
|
2012-02-08 00:32:22 +01:00
|
|
|
Ogre::Light* mSun;
|
2011-11-03 23:47:15 -04:00
|
|
|
|
2013-02-26 14:01:10 +01:00
|
|
|
Ogre::SceneNode *mRootNode;
|
2011-11-02 00:13:33 -04:00
|
|
|
|
2013-02-27 09:20:42 +01:00
|
|
|
Ogre::ColourValue mFogColour;
|
|
|
|
float mFogStart;
|
|
|
|
float mFogEnd;
|
|
|
|
|
2011-11-22 02:39:28 -05:00
|
|
|
OEngine::Physic::PhysicEngine* mPhysicsEngine;
|
2011-11-02 00:13:33 -04:00
|
|
|
|
2013-04-29 05:50:40 -07:00
|
|
|
MWRender::Camera *mCamera;
|
2012-03-29 13:27:13 +04:00
|
|
|
|
2012-03-08 10:46:34 +04:00
|
|
|
MWRender::Debugging *mDebugging;
|
2012-03-10 15:28:18 +01:00
|
|
|
|
|
|
|
MWRender::LocalMap* mLocalMap;
|
2012-04-11 18:53:13 +02:00
|
|
|
|
|
|
|
MWRender::Shadows* mShadows;
|
2011-10-20 15:02:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|