2011-10-20 19:02:19 +00:00
# include "renderingmanager.hpp"
2012-07-03 10:30:50 +00:00
# include <cassert>
2011-10-20 22:15:30 +00:00
2012-07-03 13:32:38 +00:00
# include <OgreRoot.h>
# include <OgreRenderWindow.h>
# include <OgreSceneManager.h>
# include <OgreViewport.h>
# include <OgreCamera.h>
# include <OgreTextureManager.h>
# include <OgreCompositorManager.h>
# include <OgreCompositorChain.h>
# include <OgreCompositionTargetPass.h>
# include <OgreCompositionPass.h>
# include <OgreHardwarePixelBuffer.h>
2011-10-20 22:15:30 +00:00
2012-07-03 20:48:16 +00:00
# include <extern/shiny/Main/Factory.hpp>
# include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp>
2011-10-20 22:15:30 +00:00
# include <components/esm/loadstat.hpp>
2012-08-12 12:36:46 +00:00
# include <components/esm_store/store.hpp>
2012-04-02 13:51:48 +00:00
# include <components/settings/settings.hpp>
2011-10-20 22:15:30 +00:00
2012-07-03 10:30:50 +00:00
# include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone
# include "../mwbase/environment.hpp"
2012-08-11 15:53:39 +00:00
# include "../mwbase/inputmanager.hpp" // FIXME
2012-08-12 16:11:09 +00:00
# include "../mwbase/windowmanager.hpp" // FIXME
2012-07-03 10:30:50 +00:00
# include "../mwworld/ptr.hpp"
# include "../mwworld/player.hpp"
2012-04-11 16:53:13 +00:00
# include "shadows.hpp"
# include "localmap.hpp"
# include "water.hpp"
2012-04-29 01:33:10 +00:00
# include "compositors.hpp"
2012-08-14 16:33:29 +00:00
# include "npcanimation.hpp"
2012-09-14 19:12:16 +00:00
# include "externalrendering.hpp"
2012-09-20 11:56:37 +00:00
# include "globalmap.hpp"
2011-11-01 03:59:16 +00:00
2011-10-20 22:15:30 +00:00
using namespace MWRender ;
using namespace Ogre ;
2011-10-20 19:02:19 +00:00
namespace MWRender {
2012-09-02 17:40:26 +00:00
RenderingManager : : RenderingManager ( OEngine : : Render : : OgreRenderer & _rend , const boost : : filesystem : : path & resDir ,
const boost : : filesystem : : path & cacheDir , OEngine : : Physic : : PhysicEngine * engine )
2012-09-20 11:56:37 +00:00
: mRendering ( _rend ) , mObjects ( mRendering ) , mActors ( mRendering ) , mAmbientMode ( 0 ) , mSunEnabled ( 0 ) , mPhysicsEngine ( engine )
2011-10-20 19:02:19 +00:00
{
2012-07-11 01:19:51 +00:00
// select best shader mode
2012-08-01 02:11:16 +00:00
bool openGL = ( Ogre : : Root : : getSingleton ( ) . getRenderSystem ( ) - > getName ( ) . find ( " OpenGL " ) ! = std : : string : : npos ) ;
// glsl is only supported in opengl mode and hlsl only in direct3d mode.
if ( Settings : : Manager : : getString ( " shader mode " , " General " ) = = " "
| | ( openGL & & Settings : : Manager : : getString ( " shader mode " , " General " ) = = " hlsl " )
| | ( ! openGL & & Settings : : Manager : : getString ( " shader mode " , " General " ) = = " glsl " ) )
2012-07-11 01:19:51 +00:00
{
2012-08-01 02:11:16 +00:00
Settings : : Manager : : setString ( " shader mode " , " General " , openGL ? " glsl " : " hlsl " ) ;
2012-07-11 01:19:51 +00:00
}
2012-04-02 16:01:49 +00:00
mRendering . createScene ( " PlayerCam " , Settings : : Manager : : getFloat ( " field of view " , " General " ) , 5 ) ;
2012-05-27 19:39:18 +00:00
mRendering . setWindowEventListener ( this ) ;
2011-10-20 22:15:30 +00:00
2012-04-29 01:33:10 +00:00
mCompositors = new Compositors ( mRendering . getViewport ( ) ) ;
2012-04-05 13:30:55 +00:00
mWater = 0 ;
2012-07-03 20:48:16 +00:00
// material system
2012-07-03 22:26:57 +00:00
sh : : OgrePlatform * platform = new sh : : OgrePlatform ( " General " , ( resDir / " materials " ) . string ( ) ) ;
2012-09-02 17:40:26 +00:00
if ( ! boost : : filesystem : : exists ( cacheDir ) )
boost : : filesystem : : create_directory ( cacheDir ) ;
platform - > setCacheFolder ( cacheDir . string ( ) ) ;
2012-07-03 20:48:16 +00:00
mFactory = new sh : : Factory ( platform ) ;
2012-07-11 07:08:55 +00:00
sh : : Language lang ;
std : : string l = Settings : : Manager : : getString ( " shader mode " , " General " ) ;
if ( l = = " glsl " )
lang = sh : : Language_GLSL ;
else if ( l = = " hlsl " )
lang = sh : : Language_HLSL ;
else
lang = sh : : Language_CG ;
mFactory - > setCurrentLanguage ( lang ) ;
2012-09-02 17:40:26 +00:00
mFactory - > setWriteSourceCache ( true ) ;
mFactory - > setReadSourceCache ( true ) ;
mFactory - > setReadMicrocodeCache ( true ) ;
mFactory - > setWriteMicrocodeCache ( true ) ;
2012-07-26 21:09:46 +00:00
mFactory - > loadAllFiles ( ) ;
2012-07-11 07:08:55 +00:00
2011-10-20 22:15:30 +00:00
// Set default mipmap level (NB some APIs ignore this)
2012-04-02 16:01:49 +00:00
TextureManager : : getSingleton ( ) . setDefaultNumMipmaps ( Settings : : Manager : : getInt ( " num mipmaps " , " General " ) ) ;
// Set default texture filtering options
TextureFilterOptions tfo ;
std : : string filter = Settings : : Manager : : getString ( " texture filtering " , " General " ) ;
if ( filter = = " anisotropic " ) tfo = TFO_ANISOTROPIC ;
else if ( filter = = " trilinear " ) tfo = TFO_TRILINEAR ;
2012-04-08 22:10:42 +00:00
else if ( filter = = " bilinear " ) tfo = TFO_BILINEAR ;
2012-09-14 23:02:07 +00:00
else /*if (filter == "none")*/ tfo = TFO_NONE ;
2012-04-02 16:01:49 +00:00
MaterialManager : : getSingleton ( ) . setDefaultTextureFiltering ( tfo ) ;
2012-04-08 22:10:42 +00:00
MaterialManager : : getSingleton ( ) . setDefaultAnisotropy ( ( filter = = " anisotropic " ) ? Settings : : Manager : : getInt ( " anisotropy " , " General " ) : 1 ) ;
2011-10-20 22:15:30 +00:00
2012-09-20 11:56:37 +00:00
ResourceGroupManager : : getSingleton ( ) . declareResource ( " GlobalMap.png " , " Texture " , ResourceGroupManager : : DEFAULT_RESOURCE_GROUP_NAME ) ;
2011-10-20 22:15:30 +00:00
ResourceGroupManager : : getSingleton ( ) . initialiseAllResourceGroups ( ) ;
2012-07-09 17:20:41 +00:00
// causes light flicker in opengl when moving..
//mRendering.getScene()->setCameraRelativeRendering(true);
2012-04-17 23:10:00 +00:00
2012-04-05 17:27:54 +00:00
// disable unsupported effects
2012-07-11 00:31:03 +00:00
//const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities();
2012-05-29 04:45:44 +00:00
if ( ! waterShaderSupported ( ) )
2012-04-05 17:27:54 +00:00
Settings : : Manager : : setBool ( " shader " , " Water " , false ) ;
2012-07-09 22:09:47 +00:00
if ( ! Settings : : Manager : : getBool ( " shaders " , " Objects " ) )
2012-04-13 11:28:31 +00:00
Settings : : Manager : : setBool ( " enabled " , " Shadows " , false ) ;
2012-04-05 11:09:59 +00:00
2012-07-23 19:39:22 +00:00
sh : : Factory : : getInstance ( ) . setShadersEnabled ( Settings : : Manager : : getBool ( " shaders " , " Objects " ) ) ;
2012-07-11 00:31:03 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " mrt_output " , useMRT ( ) ? " true " : " false " ) ;
2012-07-13 04:16:55 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " fog " , " true " ) ;
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " lighting " , " true " ) ;
2012-07-15 06:21:43 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " num_lights " , Settings : : Manager : : getString ( " num lights " , " Objects " ) ) ;
2012-07-23 22:08:53 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " terrain_num_lights " , Settings : : Manager : : getString ( " num lights " , " Terrain " ) ) ;
2012-07-19 21:30:41 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " underwater_effects " , Settings : : Manager : : getString ( " underwater effect " , " Water " ) ) ;
2012-07-20 12:45:42 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " simple_water " , Settings : : Manager : : getBool ( " shader " , " Water " ) ? " false " : " true " ) ;
2012-07-11 00:31:03 +00:00
2012-07-20 14:44:03 +00:00
sh : : Factory : : getInstance ( ) . setSharedParameter ( " viewportBackground " , sh : : makeProperty < sh : : Vector3 > ( new sh : : Vector3 ( 0 , 0 , 0 ) ) ) ;
sh : : Factory : : getInstance ( ) . setSharedParameter ( " waterEnabled " , sh : : makeProperty < sh : : FloatValue > ( new sh : : FloatValue ( 0.0 ) ) ) ;
2012-07-23 18:12:42 +00:00
sh : : Factory : : getInstance ( ) . setSharedParameter ( " waterLevel " , sh : : makeProperty < sh : : FloatValue > ( new sh : : FloatValue ( 0 ) ) ) ;
sh : : Factory : : getInstance ( ) . setSharedParameter ( " waterTimer " , sh : : makeProperty < sh : : FloatValue > ( new sh : : FloatValue ( 0 ) ) ) ;
sh : : Factory : : getInstance ( ) . setSharedParameter ( " windDir_windSpeed " , sh : : makeProperty < sh : : Vector3 > ( new sh : : Vector3 ( 0.5 , - 0.8 , 0.2 ) ) ) ;
sh : : Factory : : getInstance ( ) . setSharedParameter ( " waterSunFade_sunHeight " , sh : : makeProperty < sh : : Vector2 > ( new sh : : Vector2 ( 1 , 0.6 ) ) ) ;
2012-09-19 21:25:07 +00:00
sh : : Factory : : getInstance ( ) . setSharedParameter ( " gammaCorrection " , sh : : makeProperty < sh : : FloatValue > ( new sh : : FloatValue (
Settings : : Manager : : getFloat ( " gamma " , " Video " ) ) ) ) ;
2012-07-20 14:44:03 +00:00
2012-05-29 04:45:44 +00:00
applyCompositors ( ) ;
2012-04-04 23:21:36 +00:00
2011-10-20 22:15:30 +00:00
// Turn the entire scene (represented by the 'root' node) -90
// degrees around the x axis. This makes Z go upwards, and Y go into
// the screen (when x is to the right.) This is the orientation that
// Morrowind uses, and it automagically makes everything work as it
// should.
2011-11-22 07:39:28 +00:00
SceneNode * rt = mRendering . getScene ( ) - > getRootSceneNode ( ) ;
2012-09-14 22:57:29 +00:00
mMwRoot = rt - > createChildSceneNode ( " mwRoot " ) ;
2011-11-22 07:39:28 +00:00
mMwRoot - > pitch ( Degree ( - 90 ) ) ;
2012-08-14 18:39:42 +00:00
2011-11-22 07:39:28 +00:00
mObjects . setMwRoot ( mMwRoot ) ;
2011-11-25 04:13:34 +00:00
mActors . setMwRoot ( mMwRoot ) ;
2011-10-20 22:15:30 +00:00
2011-11-22 07:39:28 +00:00
Ogre : : SceneNode * playerNode = mMwRoot - > createChildSceneNode ( " player " ) ;
2012-08-12 11:50:37 +00:00
mPlayer = new MWRender : : Player ( mRendering . getCamera ( ) , playerNode ) ;
2012-03-08 06:46:34 +00:00
2012-04-11 16:53:13 +00:00
mShadows = new Shadows ( & mRendering ) ;
2012-04-23 13:27:03 +00:00
mTerrainManager = new TerrainManager ( mRendering . getScene ( ) , this ) ;
2012-04-11 16:53:13 +00:00
2012-04-23 13:27:03 +00:00
mSkyManager = new SkyManager ( mMwRoot , mRendering . getCamera ( ) ) ;
2011-10-20 22:15:30 +00:00
2012-03-24 16:59:26 +00:00
mOcclusionQuery = new OcclusionQuery ( & mRendering , mSkyManager - > getSunNode ( ) ) ;
2012-01-22 20:02:38 +00:00
2012-02-07 23:32:22 +00:00
mSun = 0 ;
2012-03-10 14:28:18 +00:00
2012-04-23 13:27:03 +00:00
mDebugging = new Debugging ( mMwRoot , engine ) ;
mLocalMap = new MWRender : : LocalMap ( & mRendering , this ) ;
2012-05-22 23:32:36 +00:00
2012-09-20 11:56:37 +00:00
mGlobalMap = new GlobalMap ( cacheDir . string ( ) ) ;
2012-05-22 23:32:36 +00:00
setMenuTransparency ( Settings : : Manager : : getFloat ( " menu transparency " , " GUI " ) ) ;
2011-10-20 19:02:19 +00:00
}
RenderingManager : : ~ RenderingManager ( )
{
2012-06-09 17:15:11 +00:00
mRendering . removeWindowEventListener ( this ) ;
2011-11-21 11:52:28 +00:00
delete mPlayer ;
2011-10-20 19:02:19 +00:00
delete mSkyManager ;
2012-03-08 06:46:34 +00:00
delete mDebugging ;
2012-06-06 19:08:20 +00:00
delete mShadows ;
2012-01-21 16:59:08 +00:00
delete mTerrainManager ;
2012-03-10 14:28:18 +00:00
delete mLocalMap ;
2012-03-24 12:06:01 +00:00
delete mOcclusionQuery ;
2012-04-29 01:33:10 +00:00
delete mCompositors ;
2012-06-06 19:08:20 +00:00
delete mWater ;
2012-09-20 11:56:37 +00:00
delete mGlobalMap ;
2011-10-20 19:02:19 +00:00
}
2012-02-22 18:17:37 +00:00
MWRender : : SkyManager * RenderingManager : : getSkyManager ( )
{
return mSkyManager ;
2011-11-01 03:59:16 +00:00
}
2011-11-24 06:48:54 +00:00
2011-11-01 03:59:16 +00:00
MWRender : : Objects & RenderingManager : : getObjects ( ) {
2011-11-22 07:39:28 +00:00
return mObjects ;
2011-11-01 03:59:16 +00:00
}
2011-11-24 06:48:54 +00:00
MWRender : : Actors & RenderingManager : : getActors ( ) {
return mActors ;
2011-11-01 03:59:16 +00:00
}
2011-11-24 06:48:54 +00:00
2012-02-18 17:25:28 +00:00
OEngine : : Render : : Fader * RenderingManager : : getFader ( )
{
return mRendering . getFader ( ) ;
}
2012-03-29 16:33:08 +00:00
void RenderingManager : : removeCell ( MWWorld : : Ptr : : CellStore * store )
{
mObjects . removeCell ( store ) ;
2011-11-25 04:13:34 +00:00
mActors . removeCell ( store ) ;
2012-03-08 06:46:34 +00:00
mDebugging - > cellRemoved ( store ) ;
2012-01-22 16:20:12 +00:00
if ( store - > cell - > isExterior ( ) )
mTerrainManager - > cellRemoved ( store ) ;
2012-01-22 01:05:08 +00:00
}
2012-03-29 16:33:08 +00:00
void RenderingManager : : removeWater ( )
{
2012-01-20 04:29:07 +00:00
if ( mWater ) {
2012-04-03 13:13:47 +00:00
mWater - > setActive ( false ) ;
2012-01-20 04:29:07 +00:00
}
2011-10-20 19:02:19 +00:00
}
2011-11-21 11:52:28 +00:00
2012-03-29 16:33:08 +00:00
void RenderingManager : : toggleWater ( )
{
if ( mWater )
mWater - > toggle ( ) ;
}
2011-11-21 11:52:28 +00:00
void RenderingManager : : cellAdded ( MWWorld : : Ptr : : CellStore * store )
{
2011-11-22 07:39:28 +00:00
mObjects . buildStaticGeometry ( * store ) ;
2012-03-08 06:46:34 +00:00
mDebugging - > cellAdded ( store ) ;
2012-01-22 16:20:12 +00:00
if ( store - > cell - > isExterior ( ) )
mTerrainManager - > cellAdded ( store ) ;
2012-04-03 14:53:33 +00:00
waterAdded ( store ) ;
2011-11-21 11:52:28 +00:00
}
2011-11-11 05:20:53 +00:00
void RenderingManager : : addObject ( const MWWorld : : Ptr & ptr ) {
2011-11-16 21:22:13 +00:00
const MWWorld : : Class & class_ =
MWWorld : : Class : : get ( ptr ) ;
class_ . insertObjectRendering ( ptr , * this ) ;
2011-10-20 19:02:19 +00:00
}
2011-11-21 11:52:28 +00:00
void RenderingManager : : removeObject ( const MWWorld : : Ptr & ptr )
{
2011-11-22 07:39:28 +00:00
if ( ! mObjects . deleteObject ( ptr ) )
2011-11-21 11:52:28 +00:00
{
/// \todo delete non-object MW-references
}
2011-11-25 04:13:34 +00:00
if ( ! mActors . deleteObject ( ptr ) )
2011-11-21 11:52:28 +00:00
{
/// \todo delete non-object MW-references
}
}
2011-10-20 19:02:19 +00:00
2011-11-21 11:52:28 +00:00
void RenderingManager : : moveObject ( const MWWorld : : Ptr & ptr , const Ogre : : Vector3 & position )
{
/// \todo move this to the rendering-subsystems
2011-11-22 07:39:28 +00:00
mRendering . getScene ( ) - > getSceneNode ( ptr . getRefData ( ) . getHandle ( ) ) - >
2011-11-21 11:52:28 +00:00
setPosition ( position ) ;
2011-10-20 19:02:19 +00:00
}
2011-11-21 11:52:28 +00:00
2011-10-20 19:02:19 +00:00
void RenderingManager : : scaleObject ( const MWWorld : : Ptr & ptr , const Ogre : : Vector3 & scale ) {
}
2012-08-08 20:15:52 +00:00
bool
RenderingManager : : rotateObject (
const MWWorld : : Ptr & ptr ,
Ogre : : Vector3 & rot ,
bool adjust )
{
2012-08-11 14:28:37 +00:00
bool isActive = ptr . getRefData ( ) . getBaseNode ( ) ! = 0 ;
bool isPlayer = isActive & & ptr . getRefData ( ) . getHandle ( ) = = " player " ;
2012-08-11 09:23:54 +00:00
bool force = true ;
if ( isPlayer ) {
2012-08-12 11:50:37 +00:00
force = mPlayer - > rotate ( rot , adjust ) ;
2012-08-08 20:15:52 +00:00
}
MWWorld : : Class : : get ( ptr ) . adjustRotation ( ptr , rot . x , rot . y , rot . z ) ;
2012-08-09 09:27:32 +00:00
if ( adjust ) {
2012-08-11 09:23:54 +00:00
/// \note Stored and passed in radians
2012-08-09 09:27:32 +00:00
float * f = ptr . getRefData ( ) . getPosition ( ) . rot ;
rot . x + = f [ 0 ] , rot . y + = f [ 1 ] , rot . z + = f [ 2 ] ;
}
2012-09-05 21:44:11 +00:00
2012-08-11 14:28:37 +00:00
if ( ! isPlayer & & isActive ) {
2012-08-11 09:23:54 +00:00
Ogre : : Quaternion xr ( Ogre : : Radian ( rot . x ) , Ogre : : Vector3 : : UNIT_X ) ;
Ogre : : Quaternion yr ( Ogre : : Radian ( rot . y ) , Ogre : : Vector3 : : UNIT_Y ) ;
Ogre : : Quaternion zr ( Ogre : : Radian ( rot . z ) , Ogre : : Vector3 : : UNIT_Z ) ;
2012-09-05 21:44:11 +00:00
2012-08-11 09:23:54 +00:00
ptr . getRefData ( ) . getBaseNode ( ) - > setOrientation ( xr * yr * zr ) ;
}
2012-09-05 21:44:11 +00:00
2012-08-11 09:23:54 +00:00
return force ;
2011-10-20 19:02:19 +00:00
}
2012-07-30 19:28:14 +00:00
void
RenderingManager : : moveObjectToCell (
const MWWorld : : Ptr & ptr ,
const Ogre : : Vector3 & pos ,
MWWorld : : CellStore * store )
{
Ogre : : SceneNode * child =
mRendering . getScene ( ) - > getSceneNode ( ptr . getRefData ( ) . getHandle ( ) ) ;
Ogre : : SceneNode * parent = child - > getParentSceneNode ( ) ;
parent - > removeChild ( child ) ;
if ( MWWorld : : Class : : get ( ptr ) . isActor ( ) ) {
mActors . updateObjectCell ( ptr ) ;
} else {
mObjects . updateObjectCell ( ptr ) ;
}
child - > setPosition ( pos ) ;
2011-10-20 19:02:19 +00:00
}
2012-08-16 09:15:38 +00:00
void RenderingManager : : update ( float duration )
{
Ogre : : Vector3 orig , dest ;
mPlayer - > setCameraDistance ( ) ;
if ( ! mPlayer - > getPosition ( orig , dest ) ) {
orig . z + = mPlayer - > getHeight ( ) * mMwRoot - > getScale ( ) . z ;
btVector3 btOrig ( orig . x , orig . y , orig . z ) ;
btVector3 btDest ( dest . x , dest . y , dest . z ) ;
std : : pair < std : : string , float > test =
mPhysicsEngine - > rayTest ( btOrig , btDest ) ;
if ( ! test . first . empty ( ) ) {
mPlayer - > setCameraDistance ( test . second * orig . distance ( dest ) , false , false ) ;
}
}
mPlayer - > update ( duration ) ;
2011-10-20 19:02:19 +00:00
2012-01-23 13:33:06 +00:00
mActors . update ( duration ) ;
2012-04-19 18:59:57 +00:00
mObjects . update ( duration ) ;
2012-03-24 16:59:26 +00:00
2012-03-25 22:31:03 +00:00
mOcclusionQuery - > update ( duration ) ;
2012-03-24 16:59:26 +00:00
2012-02-19 22:09:14 +00:00
mSkyManager - > update ( duration ) ;
2012-03-24 16:59:26 +00:00
mSkyManager - > setGlare ( mOcclusionQuery - > getSunVisibility ( ) ) ;
2012-02-19 22:22:29 +00:00
mRendering . update ( duration ) ;
2012-03-14 13:51:58 +00:00
2012-08-13 22:36:18 +00:00
MWWorld : : RefData & data =
2012-08-12 14:35:35 +00:00
MWBase : : Environment : : get ( )
. getWorld ( )
- > getPlayer ( )
. getPlayer ( )
2012-08-13 22:36:18 +00:00
. getRefData ( ) ;
2012-08-12 14:35:35 +00:00
2012-08-13 22:36:18 +00:00
float * fpos = data . getPosition ( ) . pos ;
/// \note only for LocalMap::updatePlayer()
2012-08-14 10:37:48 +00:00
Ogre : : Vector3 pos ( fpos [ 0 ] , - fpos [ 2 ] , - fpos [ 1 ] ) ;
2012-08-13 22:36:18 +00:00
Ogre : : SceneNode * node = data . getBaseNode ( ) ;
Ogre : : Quaternion orient =
node - > convertLocalToWorldOrientation ( node - > _getDerivedOrientation ( ) ) ;
2012-08-14 10:37:48 +00:00
mLocalMap - > updatePlayer ( pos , orient ) ;
2012-03-29 03:03:34 +00:00
2012-08-03 10:42:09 +00:00
if ( mWater ) {
Ogre : : Vector3 cam = mRendering . getCamera ( ) - > getRealPosition ( ) ;
2012-04-18 23:08:26 +00:00
2012-08-03 10:42:09 +00:00
MWBase : : World * world = MWBase : : Environment : : get ( ) . getWorld ( ) ;
mWater - > updateUnderwater (
world - > isUnderwater (
* world - > getPlayer ( ) . getPlayer ( ) . getCell ( ) - > cell ,
Ogre : : Vector3 ( cam . x , - cam . z , cam . y ) )
) ;
2012-07-23 18:12:42 +00:00
mWater - > update ( duration ) ;
2012-08-03 10:42:09 +00:00
}
2012-01-20 04:29:07 +00:00
}
2012-08-03 10:42:09 +00:00
2012-01-22 20:02:38 +00:00
void RenderingManager : : waterAdded ( MWWorld : : Ptr : : CellStore * store ) {
2012-05-17 17:54:09 +00:00
if ( store - > cell - > data . flags & store - > cell - > HasWater
| | ( ( ! ( store - > cell - > data . flags & ESM : : Cell : : Interior ) )
& & ! MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . lands . search ( store - > cell - > data . gridX , store - > cell - > data . gridY ) ) ) // always use water, if the cell does not have land.
{
2012-01-22 01:05:08 +00:00
if ( mWater = = 0 )
2012-04-29 01:33:10 +00:00
mWater = new MWRender : : Water ( mRendering . getCamera ( ) , this , store - > cell ) ;
2012-01-22 21:38:10 +00:00
else
mWater - > changeCell ( store - > cell ) ;
2012-04-03 13:13:47 +00:00
mWater - > setActive ( true ) ;
2012-01-22 01:05:08 +00:00
}
2012-01-22 21:38:10 +00:00
else
removeWater ( ) ;
2011-10-20 19:02:19 +00:00
}
2012-03-29 13:49:24 +00:00
void RenderingManager : : setWaterHeight ( const float height )
{
if ( mWater )
mWater - > setHeight ( height ) ;
}
2011-10-20 19:02:19 +00:00
void RenderingManager : : skyEnable ( )
{
2012-01-25 06:21:30 +00:00
if ( mSkyManager )
2011-10-20 19:02:19 +00:00
mSkyManager - > enable ( ) ;
2012-04-01 13:07:41 +00:00
mOcclusionQuery - > setSunNode ( mSkyManager - > getSunNode ( ) ) ;
2011-10-20 19:02:19 +00:00
}
void RenderingManager : : skyDisable ( )
{
2012-01-25 06:21:30 +00:00
if ( mSkyManager )
mSkyManager - > disable ( ) ;
2011-10-20 19:02:19 +00:00
}
void RenderingManager : : skySetHour ( double hour )
{
2012-01-25 06:21:30 +00:00
if ( mSkyManager )
mSkyManager - > setHour ( hour ) ;
2011-10-20 19:02:19 +00:00
}
void RenderingManager : : skySetDate ( int day , int month )
{
2012-01-25 06:21:30 +00:00
if ( mSkyManager )
mSkyManager - > setDate ( day , month ) ;
2011-10-20 19:02:19 +00:00
}
int RenderingManager : : skyGetMasserPhase ( ) const
{
2012-03-08 06:46:34 +00:00
2011-10-20 19:02:19 +00:00
return mSkyManager - > getMasserPhase ( ) ;
}
int RenderingManager : : skyGetSecundaPhase ( ) const
{
return mSkyManager - > getSecundaPhase ( ) ;
}
2012-01-25 06:21:30 +00:00
void RenderingManager : : skySetMoonColour ( bool red ) {
if ( mSkyManager )
mSkyManager - > setMoonColour ( red ) ;
2011-10-20 19:02:19 +00:00
}
2012-02-18 15:06:03 +00:00
bool RenderingManager : : toggleRenderMode ( int mode )
{
2012-07-03 10:30:50 +00:00
if ( mode = = MWBase : : World : : Render_CollisionDebug | | mode = = MWBase : : World : : Render_Pathgrid )
2012-03-08 06:46:34 +00:00
return mDebugging - > toggleRenderMode ( mode ) ;
2012-07-03 10:30:50 +00:00
else if ( mode = = MWBase : : World : : Render_Wireframe )
2012-02-18 15:06:03 +00:00
{
if ( mRendering . getCamera ( ) - > getPolygonMode ( ) = = PM_SOLID )
{
2012-04-29 01:33:10 +00:00
mCompositors - > setEnabled ( false ) ;
2012-04-04 23:21:36 +00:00
2012-02-18 15:06:03 +00:00
mRendering . getCamera ( ) - > setPolygonMode ( PM_WIREFRAME ) ;
return true ;
}
else
{
2012-04-29 01:33:10 +00:00
mCompositors - > setEnabled ( true ) ;
2012-04-04 23:21:36 +00:00
2012-02-18 15:06:03 +00:00
mRendering . getCamera ( ) - > setPolygonMode ( PM_SOLID ) ;
return false ;
}
}
2012-04-29 01:33:10 +00:00
else //if (mode == MWWorld::World::Render_Compositors)
{
return mCompositors - > toggle ( ) ;
}
2011-10-30 04:25:29 +00:00
}
2011-10-20 19:02:19 +00:00
2012-06-29 14:48:50 +00:00
void RenderingManager : : configureFog ( MWWorld : : Ptr : : CellStore & mCell )
2011-11-04 03:47:15 +00:00
{
2012-04-05 09:52:06 +00:00
Ogre : : ColourValue color ;
color . setAsABGR ( mCell . cell - > ambi . fog ) ;
2011-11-04 03:47:15 +00:00
2012-04-05 09:52:06 +00:00
configureFog ( mCell . cell - > ambi . fogDensity , color ) ;
2012-07-23 12:21:40 +00:00
if ( mWater )
mWater - > setViewportBackground ( Ogre : : ColourValue ( 0.8f , 0.9f , 1.0f ) ) ;
2012-02-26 12:13:29 +00:00
}
2011-11-04 03:47:15 +00:00
2012-02-26 12:13:29 +00:00
void RenderingManager : : configureFog ( const float density , const Ogre : : ColourValue & colour )
2012-03-08 06:46:34 +00:00
{
2012-04-05 09:52:06 +00:00
float max = Settings : : Manager : : getFloat ( " max viewing distance " , " Viewing distance " ) ;
2012-03-13 21:14:35 +00:00
2012-04-05 09:52:06 +00:00
float low = max / ( density ) * Settings : : Manager : : getFloat ( " fog start factor " , " Viewing distance " ) ;
float high = max / ( density ) * Settings : : Manager : : getFloat ( " fog end factor " , " Viewing distance " ) ;
2012-03-13 21:14:35 +00:00
2012-04-05 09:52:06 +00:00
mRendering . getScene ( ) - > setFog ( FOG_LINEAR , colour , 0 , low , high ) ;
2012-03-08 06:46:34 +00:00
2012-04-05 09:52:06 +00:00
mRendering . getCamera ( ) - > setFarClipDistance ( max / density ) ;
mRendering . getViewport ( ) - > setBackgroundColour ( colour ) ;
2012-07-23 12:21:40 +00:00
if ( mWater )
mWater - > setViewportBackground ( colour ) ;
2012-07-20 14:44:03 +00:00
sh : : Factory : : getInstance ( ) . setSharedParameter ( " viewportBackground " ,
sh : : makeProperty < sh : : Vector3 > ( new sh : : Vector3 ( colour . r , colour . g , colour . b ) ) ) ;
2011-11-04 03:47:15 +00:00
}
2012-02-26 12:13:29 +00:00
2011-11-04 03:47:15 +00:00
void RenderingManager : : setAmbientMode ( )
{
switch ( mAmbientMode )
{
case 0 :
2012-02-28 21:04:44 +00:00
setAmbientColour ( mAmbientColor ) ;
2011-11-04 03:47:15 +00:00
break ;
case 1 :
2012-02-28 21:04:44 +00:00
setAmbientColour ( 0.7f * mAmbientColor + 0.3f * ColourValue ( 1 , 1 , 1 ) ) ;
2011-11-04 03:47:15 +00:00
break ;
case 2 :
2012-02-28 21:04:44 +00:00
setAmbientColour ( ColourValue ( 1 , 1 , 1 ) ) ;
2011-11-04 03:47:15 +00:00
break ;
}
}
2012-06-29 14:48:50 +00:00
void RenderingManager : : configureAmbient ( MWWorld : : Ptr : : CellStore & mCell )
2011-11-04 03:47:15 +00:00
{
2012-04-05 09:52:06 +00:00
mAmbientColor . setAsABGR ( mCell . cell - > ambi . ambient ) ;
setAmbientMode ( ) ;
2011-11-04 03:47:15 +00:00
2012-04-05 09:52:06 +00:00
// Create a "sun" that shines light downwards. It doesn't look
// completely right, but leave it for now.
if ( ! mSun )
{
mSun = mRendering . getScene ( ) - > createLight ( ) ;
}
Ogre : : ColourValue colour ;
colour . setAsABGR ( mCell . cell - > ambi . sunlight ) ;
mSun - > setDiffuseColour ( colour ) ;
mSun - > setType ( Ogre : : Light : : LT_DIRECTIONAL ) ;
mSun - > setDirection ( 0 , - 1 , 0 ) ;
2011-11-04 03:47:15 +00:00
}
// Switch through lighting modes.
void RenderingManager : : toggleLight ( )
{
2012-04-05 09:52:06 +00:00
if ( mAmbientMode = = 2 )
mAmbientMode = 0 ;
else
+ + mAmbientMode ;
2011-11-04 03:47:15 +00:00
2012-04-05 09:52:06 +00:00
switch ( mAmbientMode )
{
case 0 : std : : cout < < " Setting lights to normal \n " ; break ;
case 1 : std : : cout < < " Turning the lights up \n " ; break ;
case 2 : std : : cout < < " Turning the lights to full \n " ; break ;
}
2011-11-04 03:47:15 +00:00
2012-04-05 09:52:06 +00:00
setAmbientMode ( ) ;
2011-11-04 03:47:15 +00:00
}
2011-11-21 13:08:44 +00:00
void RenderingManager : : playAnimationGroup ( const MWWorld : : Ptr & ptr , const std : : string & groupName ,
int mode , int number )
{
2011-12-27 00:23:46 +00:00
mActors . playAnimationGroup ( ptr , groupName , mode , number ) ;
2011-11-21 13:08:44 +00:00
}
2011-11-17 22:10:27 +00:00
2011-11-21 13:08:44 +00:00
void RenderingManager : : skipAnimation ( const MWWorld : : Ptr & ptr )
{
2011-12-29 02:52:05 +00:00
mActors . skipAnimation ( ptr ) ;
2011-11-21 13:08:44 +00:00
}
2011-11-17 22:10:27 +00:00
2012-02-23 19:33:34 +00:00
void RenderingManager : : setSunColour ( const Ogre : : ColourValue & colour )
{
2012-04-11 16:53:13 +00:00
if ( ! mSunEnabled ) return ;
2012-02-23 19:33:34 +00:00
mSun - > setDiffuseColour ( colour ) ;
2012-04-06 12:07:52 +00:00
mSun - > setSpecularColour ( colour ) ;
2012-02-28 21:04:44 +00:00
mTerrainManager - > setDiffuse ( colour ) ;
2012-02-23 19:33:34 +00:00
}
2012-02-23 20:12:06 +00:00
void RenderingManager : : setAmbientColour ( const Ogre : : ColourValue & colour )
{
mRendering . getScene ( ) - > setAmbientLight ( colour ) ;
2012-02-28 21:04:44 +00:00
mTerrainManager - > setAmbient ( colour ) ;
2011-10-20 19:02:19 +00:00
}
2012-02-23 20:12:06 +00:00
2012-02-23 19:33:34 +00:00
void RenderingManager : : sunEnable ( )
{
2012-04-11 16:53:13 +00:00
// Don't disable the light, as the shaders assume the first light to be directional.
//if (mSun) mSun->setVisible(true);
mSunEnabled = true ;
2012-02-23 19:33:34 +00:00
}
2012-02-23 20:12:06 +00:00
2012-02-23 19:33:34 +00:00
void RenderingManager : : sunDisable ( )
{
2012-04-11 16:53:13 +00:00
// Don't disable the light, as the shaders assume the first light to be directional.
//if (mSun) mSun->setVisible(false);
mSunEnabled = false ;
if ( mSun )
{
mSun - > setDiffuseColour ( ColourValue ( 0 , 0 , 0 ) ) ;
mSun - > setSpecularColour ( ColourValue ( 0 , 0 , 0 ) ) ;
}
2011-10-20 19:02:19 +00:00
}
2012-02-23 19:33:34 +00:00
void RenderingManager : : setSunDirection ( const Ogre : : Vector3 & direction )
{
2012-03-08 06:46:34 +00:00
// direction * -1 (because 'direction' is camera to sun vector and not sun to camera),
2012-02-28 19:28:46 +00:00
// then convert from MW to ogre coordinates (swap y,z and make y negative)
if ( mSun ) mSun - > setDirection ( Vector3 ( - direction . x , - direction . z , direction . y ) ) ;
2012-03-08 06:46:34 +00:00
2012-02-24 17:30:16 +00:00
mSkyManager - > setSunDirection ( direction ) ;
2012-02-23 19:33:34 +00:00
}
2012-02-24 15:12:43 +00:00
void RenderingManager : : setGlare ( bool glare )
{
mSkyManager - > setGlare ( glare ) ;
}
2012-03-10 14:28:18 +00:00
void RenderingManager : : requestMap ( MWWorld : : Ptr : : CellStore * cell )
{
if ( ! ( cell - > cell - > data . flags & ESM : : Cell : : Interior ) )
mLocalMap - > requestMap ( cell ) ;
else
mLocalMap - > requestMap ( cell , mObjects . getDimensions ( cell ) ) ;
}
2012-03-14 19:44:06 +00:00
void RenderingManager : : preCellChange ( MWWorld : : Ptr : : CellStore * cell )
{
mLocalMap - > saveFogOfWar ( cell ) ;
}
2012-04-02 17:37:24 +00:00
void RenderingManager : : disableLights ( )
{
mObjects . disableLights ( ) ;
2012-04-14 13:58:58 +00:00
sunDisable ( ) ;
2012-04-02 17:37:24 +00:00
}
void RenderingManager : : enableLights ( )
{
mObjects . enableLights ( ) ;
2012-04-14 13:58:58 +00:00
sunEnable ( ) ;
2012-04-02 17:37:24 +00:00
}
2012-04-05 17:27:54 +00:00
const bool RenderingManager : : useMRT ( )
{
return Settings : : Manager : : getBool ( " shader " , " Water " ) ;
}
2012-04-11 16:53:13 +00:00
Shadows * RenderingManager : : getShadows ( )
{
return mShadows ;
}
2012-04-19 18:59:57 +00:00
void RenderingManager : : switchToInterior ( )
{
2012-07-09 17:20:41 +00:00
// causes light flicker in opengl when moving..
//mRendering.getScene()->setCameraRelativeRendering(false);
2012-04-19 18:59:57 +00:00
}
void RenderingManager : : switchToExterior ( )
{
2012-07-09 17:20:41 +00:00
// causes light flicker in opengl when moving..
//mRendering.getScene()->setCameraRelativeRendering(true);
2012-04-19 18:59:57 +00:00
}
2012-05-14 19:37:43 +00:00
Ogre : : Vector4 RenderingManager : : boundingBoxToScreen ( Ogre : : AxisAlignedBox bounds )
{
Ogre : : Matrix4 mat = mRendering . getCamera ( ) - > getViewMatrix ( ) ;
const Ogre : : Vector3 * corners = bounds . getAllCorners ( ) ;
float min_x = 1.0f , max_x = 0.0f , min_y = 1.0f , max_y = 0.0f ;
2012-05-21 09:24:36 +00:00
// expand the screen-space bounding-box so that it completely encloses
2012-05-14 19:37:43 +00:00
// the object's AABB
for ( int i = 0 ; i < 8 ; i + + )
{
Ogre : : Vector3 corner = corners [ i ] ;
2012-05-21 09:24:36 +00:00
// multiply the AABB corner vertex by the view matrix to
2012-05-14 19:37:43 +00:00
// get a camera-space vertex
corner = mat * corner ;
// make 2D relative/normalized coords from the view-space vertex
// by dividing out the Z (depth) factor -- this is an approximation
float x = corner . x / corner . z + 0.5 ;
float y = corner . y / corner . z + 0.5 ;
2012-05-21 09:24:36 +00:00
if ( x < min_x )
2012-05-14 19:37:43 +00:00
min_x = x ;
2012-05-21 09:24:36 +00:00
if ( x > max_x )
2012-05-14 19:37:43 +00:00
max_x = x ;
2012-05-21 09:24:36 +00:00
if ( y < min_y )
2012-05-14 19:37:43 +00:00
min_y = y ;
2012-05-21 09:24:36 +00:00
if ( y > max_y )
2012-05-14 19:37:43 +00:00
max_y = y ;
}
return Vector4 ( min_x , min_y , max_x , max_y ) ;
}
2012-04-29 01:33:10 +00:00
Compositors * RenderingManager : : getCompositors ( )
{
return mCompositors ;
}
2012-05-22 23:32:36 +00:00
void RenderingManager : : processChangedSettings ( const Settings : : CategorySettingVector & settings )
{
2012-05-27 19:39:18 +00:00
bool changeRes = false ;
2012-05-22 23:32:36 +00:00
for ( Settings : : CategorySettingVector : : const_iterator it = settings . begin ( ) ;
it ! = settings . end ( ) ; + + it )
{
if ( it - > second = = " menu transparency " & & it - > first = = " GUI " )
{
setMenuTransparency ( Settings : : Manager : : getFloat ( " menu transparency " , " GUI " ) ) ;
}
2012-05-27 19:39:18 +00:00
else if ( it - > second = = " max viewing distance " & & it - > first = = " Viewing distance " )
{
if ( ! MWBase : : Environment : : get ( ) . getWorld ( ) - > isCellExterior ( ) & & ! MWBase : : Environment : : get ( ) . getWorld ( ) - > isCellQuasiExterior ( ) )
configureFog ( * MWBase : : Environment : : get ( ) . getWorld ( ) - > getPlayer ( ) . getPlayer ( ) . getCell ( ) ) ;
}
else if ( it - > first = = " Video " & & (
it - > second = = " resolution x "
| | it - > second = = " resolution y "
| | it - > second = = " fullscreen " ) )
changeRes = true ;
2012-05-29 02:54:54 +00:00
else if ( it - > second = = " field of view " & & it - > first = = " General " )
mRendering . setFov ( Settings : : Manager : : getFloat ( " field of view " , " General " ) ) ;
else if ( ( it - > second = = " texture filtering " & & it - > first = = " General " )
| | ( it - > second = = " anisotropy " & & it - > first = = " General " ) )
{
TextureFilterOptions tfo ;
std : : string filter = Settings : : Manager : : getString ( " texture filtering " , " General " ) ;
if ( filter = = " anisotropic " ) tfo = TFO_ANISOTROPIC ;
else if ( filter = = " trilinear " ) tfo = TFO_TRILINEAR ;
else if ( filter = = " bilinear " ) tfo = TFO_BILINEAR ;
2012-09-14 23:02:07 +00:00
else /*if (filter == "none")*/ tfo = TFO_NONE ;
2012-05-29 02:54:54 +00:00
MaterialManager : : getSingleton ( ) . setDefaultTextureFiltering ( tfo ) ;
MaterialManager : : getSingleton ( ) . setDefaultAnisotropy ( ( filter = = " anisotropic " ) ? Settings : : Manager : : getInt ( " anisotropy " , " General " ) : 1 ) ;
}
2012-05-29 04:45:44 +00:00
else if ( it - > second = = " shader " & & it - > first = = " Water " )
{
applyCompositors ( ) ;
2012-07-11 00:31:03 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " mrt_output " , useMRT ( ) ? " true " : " false " ) ;
2012-07-20 12:45:42 +00:00
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " simple_water " , Settings : : Manager : : getBool ( " shader " , " Water " ) ? " false " : " true " ) ;
2012-07-11 00:31:03 +00:00
mObjects . rebuildStaticGeometry ( ) ;
2012-09-11 17:18:26 +00:00
mRendering . getViewport ( ) - > setClearEveryFrame ( true ) ;
2012-05-29 04:45:44 +00:00
}
2012-07-19 21:30:41 +00:00
else if ( it - > second = = " underwater effect " & & it - > first = = " Water " )
{
sh : : Factory : : getInstance ( ) . setGlobalSetting ( " underwater_effects " , Settings : : Manager : : getString ( " underwater effect " , " Water " ) ) ;
mObjects . rebuildStaticGeometry ( ) ;
}
2012-07-11 01:19:51 +00:00
else if ( it - > second = = " shaders " & & it - > first = = " Objects " )
{
sh : : Factory : : getInstance ( ) . setShadersEnabled ( Settings : : Manager : : getBool ( " shaders " , " Objects " ) ) ;
mObjects . rebuildStaticGeometry ( ) ;
}
2012-09-19 21:47:42 +00:00
else if ( it - > second = = " gamma " & & it - > first = = " Video " )
{
sh : : Factory : : getInstance ( ) . setSharedParameter ( " gammaCorrection " , sh : : makeProperty < sh : : FloatValue > ( new sh : : FloatValue (
Settings : : Manager : : getFloat ( " gamma " , " Video " ) ) ) ) ;
}
2012-07-11 01:19:51 +00:00
else if ( it - > second = = " shader mode " & & it - > first = = " General " )
{
sh : : Language lang ;
std : : string l = Settings : : Manager : : getString ( " shader mode " , " General " ) ;
if ( l = = " glsl " )
lang = sh : : Language_GLSL ;
else if ( l = = " hlsl " )
lang = sh : : Language_HLSL ;
else
lang = sh : : Language_CG ;
sh : : Factory : : getInstance ( ) . setCurrentLanguage ( lang ) ;
mObjects . rebuildStaticGeometry ( ) ;
}
2012-07-11 02:28:45 +00:00
else if ( it - > first = = " Shadows " )
{
mShadows - > recreate ( ) ;
mObjects . rebuildStaticGeometry ( ) ;
}
2012-05-27 19:39:18 +00:00
}
if ( changeRes )
{
2012-05-28 07:19:25 +00:00
unsigned int x = Settings : : Manager : : getInt ( " resolution x " , " Video " ) ;
unsigned int y = Settings : : Manager : : getInt ( " resolution y " , " Video " ) ;
if ( x ! = mRendering . getWindow ( ) - > getWidth ( ) | | y ! = mRendering . getWindow ( ) - > getHeight ( ) )
{
mRendering . getWindow ( ) - > resize ( x , y ) ;
}
2012-05-27 19:39:18 +00:00
mRendering . getWindow ( ) - > setFullscreen ( Settings : : Manager : : getBool ( " fullscreen " , " Video " ) , x , y ) ;
2012-05-22 23:32:36 +00:00
}
2012-05-29 04:45:44 +00:00
if ( mWater )
mWater - > processChangedSettings ( settings ) ;
2012-05-22 23:32:36 +00:00
}
void RenderingManager : : setMenuTransparency ( float val )
{
Ogre : : TexturePtr tex = Ogre : : TextureManager : : getSingleton ( ) . getByName ( " transparent.png " ) ;
std : : vector < Ogre : : uint32 > buffer ;
buffer . resize ( 1 ) ;
buffer [ 0 ] = ( int ( 255 * val ) < < 24 ) ;
memcpy ( tex - > getBuffer ( ) - > lock ( Ogre : : HardwareBuffer : : HBL_DISCARD ) , & buffer [ 0 ] , 1 * 4 ) ;
tex - > getBuffer ( ) - > unlock ( ) ;
}
2012-05-27 19:39:18 +00:00
void RenderingManager : : windowResized ( Ogre : : RenderWindow * rw )
{
2012-05-28 07:19:25 +00:00
Settings : : Manager : : setInt ( " resolution x " , " Video " , rw - > getWidth ( ) ) ;
Settings : : Manager : : setInt ( " resolution y " , " Video " , rw - > getHeight ( ) ) ;
mRendering . adjustViewport ( ) ;
2012-05-27 19:39:18 +00:00
mCompositors - > recreate ( ) ;
mWater - > assignTextures ( ) ;
2012-05-28 07:19:25 +00:00
const Settings : : CategorySettingVector & changed = Settings : : Manager : : apply ( ) ;
MWBase : : Environment : : get ( ) . getInputManager ( ) - > processChangedSettings ( changed ) ; //FIXME
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > processChangedSettings ( changed ) ; // FIXME
2012-05-27 19:39:18 +00:00
}
void RenderingManager : : windowClosed ( Ogre : : RenderWindow * rw )
{
2012-08-12 15:20:46 +00:00
Ogre : : Root : : getSingleton ( ) . queueEndRendering ( ) ;
2012-05-27 19:39:18 +00:00
}
2012-05-29 04:45:44 +00:00
bool RenderingManager : : waterShaderSupported ( )
{
const RenderSystemCapabilities * caps = Root : : getSingleton ( ) . getRenderSystem ( ) - > getCapabilities ( ) ;
if ( caps - > getNumMultiRenderTargets ( ) < 2 | | ! Settings : : Manager : : getBool ( " shaders " , " Objects " ) )
return false ;
return true ;
}
void RenderingManager : : applyCompositors ( )
{
mCompositors - > removeAll ( ) ;
if ( useMRT ( ) )
{
mCompositors - > addCompositor ( " gbuffer " , 0 ) ;
mCompositors - > setCompositorEnabled ( " gbuffer " , true ) ;
mCompositors - > addCompositor ( " gbufferFinalizer " , 2 ) ;
mCompositors - > setCompositorEnabled ( " gbufferFinalizer " , true ) ;
}
if ( mWater )
mWater - > assignTextures ( ) ;
}
2012-06-22 10:56:04 +00:00
void RenderingManager : : getTriangleBatchCount ( unsigned int & triangles , unsigned int & batches )
{
if ( mCompositors - > anyCompositorEnabled ( ) )
{
mCompositors - > countTrianglesBatches ( triangles , batches ) ;
}
else
{
triangles = mRendering . getWindow ( ) - > getTriangleCount ( ) ;
batches = mRendering . getWindow ( ) - > getBatchCount ( ) ;
}
}
2012-08-08 20:15:52 +00:00
void RenderingManager : : attachCameraTo ( const MWWorld : : Ptr & ptr )
{
mPlayer - > attachTo ( ptr ) ;
}
2012-08-14 16:33:29 +00:00
void RenderingManager : : renderPlayer ( const MWWorld : : Ptr & ptr )
{
MWRender : : NpcAnimation * anim =
new MWRender : : NpcAnimation (
2012-09-13 17:03:31 +00:00
ptr , ptr . getRefData ( ) . getBaseNode ( ) ,
MWWorld : : Class : : get ( ptr ) . getInventoryStore ( ptr ) , RV_Actors
2012-08-14 16:33:29 +00:00
) ;
mPlayer - > setAnimation ( anim ) ;
}
2012-08-17 06:10:37 +00:00
void RenderingManager : : getPlayerData ( Ogre : : Vector3 & eyepos , float & pitch , float & yaw )
{
eyepos = mPlayer - > getPosition ( ) ;
eyepos . z + = mPlayer - > getHeight ( ) ;
mPlayer - > getSightAngles ( pitch , yaw ) ;
}
2012-08-28 15:30:34 +00:00
void RenderingManager : : getInteriorMapPosition ( Ogre : : Vector2 position , float & nX , float & nY , int & x , int & y )
{
return mLocalMap - > getInteriorMapPosition ( position , nX , nY , x , y ) ;
}
bool RenderingManager : : isPositionExplored ( float nX , float nY , int x , int y , bool interior )
{
return mLocalMap - > isPositionExplored ( nX , nY , x , y , interior ) ;
}
2012-09-14 19:12:16 +00:00
void RenderingManager : : setupExternalRendering ( MWRender : : ExternalRendering & rendering )
2012-09-14 12:34:18 +00:00
{
2012-09-14 19:12:16 +00:00
rendering . setup ( mRendering . getScene ( ) ) ;
2012-09-14 12:34:18 +00:00
}
2012-09-20 11:56:37 +00:00
void RenderingManager : : renderGlobalMap ( )
{
mGlobalMap - > render ( ) ;
}
2012-02-23 19:33:34 +00:00
} // namespace