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
|
|
|
|
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
|
|
|
|
2013-02-03 17:03:09 +00:00
|
|
|
#include <OgreRenderTargetListener.h>
|
|
|
|
|
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"
|
2013-04-29 12:50:40 +00:00
|
|
|
#include "camera.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;
|
|
|
|
}
|
|
|
|
|
2013-08-16 11:01:52 +00:00
|
|
|
namespace Terrain
|
|
|
|
{
|
2013-08-27 14:01:16 +00:00
|
|
|
class World;
|
2013-08-16 11:01:52 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2013-01-16 17:59:19 +00:00
|
|
|
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:
|
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
|
|
|
|
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); }
|
2012-08-17 09:23:02 +00:00
|
|
|
|
2013-04-29 12:50:40 +00:00
|
|
|
void changeVanityModeScale(float factor)
|
|
|
|
{
|
|
|
|
if(mCamera->isVanityOrPreviewModeEnabled())
|
|
|
|
mCamera->setCameraDistance(-factor/120.f*10, true, true);
|
2013-03-07 23:12:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-17 20:53:43 +00:00
|
|
|
void resetCamera();
|
|
|
|
|
2013-04-29 12:50:40 +00:00
|
|
|
bool vanityRotateCamera(const float *rot);
|
2013-07-20 14:55:35 +00:00
|
|
|
void setCameraDistance(float dist, bool adjust = false, bool override = true);
|
2013-04-09 18:24:41 +00:00
|
|
|
|
2013-04-29 06:44:44 +00:00
|
|
|
void setupPlayer(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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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);
|
2012-03-29 16:33:08 +00:00
|
|
|
void toggleWater();
|
2011-11-11 05:20:53 +00:00
|
|
|
|
2013-02-24 10:59:21 +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);
|
2011-11-21 11:52:28 +00:00
|
|
|
|
2013-07-18 02:11:03 +00:00
|
|
|
/// Specifies an updated Ptr object for the player (used on cell change).
|
|
|
|
void updatePlayerPtr(const MWWorld::Ptr &ptr);
|
|
|
|
|
2013-08-09 00:16:24 +00: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 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);
|
2013-02-03 14:46:23 +00: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 16:59:26 +00:00
|
|
|
|
2013-02-03 14:46:23 +00: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 17:37:24 +00:00
|
|
|
|
2013-02-03 17:03:09 +00:00
|
|
|
|
|
|
|
void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
|
|
|
|
void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
|
|
|
|
|
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
|
|
|
|
2013-08-19 18:30:22 +00:00
|
|
|
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();
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
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-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-16 17:59:19 +00:00
|
|
|
Animation* getAnimation(const MWWorld::Ptr &ptr);
|
|
|
|
|
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();
|
2013-08-19 18:30:22 +00:00
|
|
|
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);
|
2012-05-27 19:39:18 +00:00
|
|
|
|
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();
|
2013-03-03 18:28:11 +00:00
|
|
|
void applyFog(bool underwater);
|
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;
|
|
|
|
|
2013-03-15 09:17:30 +00:00
|
|
|
MWWorld::Fallback* mFallback;
|
|
|
|
|
2011-10-20 19:02:19 +00:00
|
|
|
SkyManager* mSkyManager;
|
2012-03-24 12:06:01 +00:00
|
|
|
|
|
|
|
OcclusionQuery* mOcclusionQuery;
|
|
|
|
|
2013-08-27 14:01:16 +00:00
|
|
|
Terrain::World* mTerrain;
|
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
|
|
|
|
2013-12-08 22:05:21 +00:00
|
|
|
MWRender::Objects* mObjects;
|
|
|
|
MWRender::Actors* mActors;
|
2011-11-02 04:13:33 +00:00
|
|
|
|
2013-04-29 10:31:46 +00:00
|
|
|
MWRender::NpcAnimation *mPlayerAnimation;
|
|
|
|
|
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
|
|
|
|
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;
|
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
|