|
|
|
@ -20,10 +20,12 @@ using namespace Ogre;
|
|
|
|
|
namespace MWRender {
|
|
|
|
|
|
|
|
|
|
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment)
|
|
|
|
|
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mAmbientMode(0), mDebugging(engine)
|
|
|
|
|
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mAmbientMode(0)
|
|
|
|
|
{
|
|
|
|
|
mRendering.createScene("PlayerCam", 55, 5);
|
|
|
|
|
|
|
|
|
|
mDebugging = new Debugging(environment.mWorld->getStore(), mRendering.getScene(), engine);
|
|
|
|
|
|
|
|
|
|
// Set default mipmap level (NB some APIs ignore this)
|
|
|
|
|
TextureManager::getSingleton().setDefaultNumMipmaps(5);
|
|
|
|
|
|
|
|
|
@ -40,7 +42,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|
|
|
|
mMwRoot->pitch(Degree(-90));
|
|
|
|
|
mObjects.setMwRoot(mMwRoot);
|
|
|
|
|
mActors.setMwRoot(mMwRoot);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//used to obtain ingame information of ogre objects (which are faced or selected)
|
|
|
|
|
mRaySceneQuery = mRendering.getScene()->createRayQuery(Ray());
|
|
|
|
|
|
|
|
|
@ -49,7 +51,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|
|
|
|
Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
|
|
|
|
|
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
|
|
|
|
|
cameraPitchNode->attachObject(mRendering.getCamera());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//mSkyManager = 0;
|
|
|
|
|
mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera());
|
|
|
|
|
|
|
|
|
@ -62,6 +64,7 @@ RenderingManager::~RenderingManager ()
|
|
|
|
|
//TODO: destroy mSun?
|
|
|
|
|
delete mPlayer;
|
|
|
|
|
delete mSkyManager;
|
|
|
|
|
delete mDebugging;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWRender::SkyManager* RenderingManager::getSkyManager()
|
|
|
|
@ -88,11 +91,13 @@ OEngine::Render::Fader* RenderingManager::getFader()
|
|
|
|
|
void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){
|
|
|
|
|
mObjects.removeCell(store);
|
|
|
|
|
mActors.removeCell(store);
|
|
|
|
|
mDebugging->cellRemoved(store);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store)
|
|
|
|
|
{
|
|
|
|
|
mObjects.buildStaticGeometry (*store);
|
|
|
|
|
mDebugging->cellAdded(store);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderingManager::addObject (const MWWorld::Ptr& ptr){
|
|
|
|
@ -133,9 +138,9 @@ void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Ve
|
|
|
|
|
void RenderingManager::update (float duration){
|
|
|
|
|
|
|
|
|
|
mActors.update (duration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mSkyManager->update(duration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mRendering.update(duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,7 +171,7 @@ void RenderingManager::skySetDate (int day, int month)
|
|
|
|
|
|
|
|
|
|
int RenderingManager::skyGetMasserPhase() const
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mSkyManager->getMasserPhase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -182,8 +187,8 @@ void RenderingManager::skySetMoonColour (bool red){
|
|
|
|
|
|
|
|
|
|
bool RenderingManager::toggleRenderMode(int mode)
|
|
|
|
|
{
|
|
|
|
|
if (mode == MWWorld::World::Render_CollisionDebug)
|
|
|
|
|
return mDebugging.toggleRenderMode(mode);
|
|
|
|
|
if (mode != MWWorld::World::Render_Wireframe)
|
|
|
|
|
return mDebugging->toggleRenderMode(mode);
|
|
|
|
|
else // if (mode == MWWorld::World::Render_Wireframe)
|
|
|
|
|
{
|
|
|
|
|
if (mRendering.getCamera()->getPolygonMode() == PM_SOLID)
|
|
|
|
@ -208,13 +213,13 @@ void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
/// \todo make the viewing distance and fog start/end configurable
|
|
|
|
|
float low = 3000 / density;
|
|
|
|
|
float high = 6200 / density;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mRendering.getScene()->setFog (FOG_LINEAR, colour, 0, low, high);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mRendering.getCamera()->setFarClipDistance ( high );
|
|
|
|
|
mRendering.getViewport()->setBackgroundColour (colour);
|
|
|
|
|
}
|
|
|
|
@ -310,10 +315,10 @@ void RenderingManager::sunDisable()
|
|
|
|
|
|
|
|
|
|
void RenderingManager::setSunDirection(const Ogre::Vector3& direction)
|
|
|
|
|
{
|
|
|
|
|
// direction * -1 (because 'direction' is camera to sun vector and not sun to camera),
|
|
|
|
|
// direction * -1 (because 'direction' is camera to sun vector and not sun to camera),
|
|
|
|
|
// 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));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mSkyManager->setSunDirection(direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|