Revision: 2774
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2774&view=rev
Author: rorthomas
Date: 2012-06-02 21:10:48 +0000 (Sat, 02 Jun 2012)
Log Message:
-----------
skymanager fixes for the new terrain
Modified Paths:
--------------
trunk/source/main/gameplay/RoRFrameListener.cpp
trunk/source/main/gfx/SkyManager.cpp
trunk/source/main/gfx/SkyManager.h
trunk/source/main/terrain/TerrainGeometryManager.cpp
trunk/source/main/terrain/TerrainGeometryManager.h
trunk/source/main/terrain/TerrainManager.h
Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-06-02 20:04:00 UTC
(rev 2773)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-06-02 21:10:48 UTC
(rev 2774)
@@ -3193,6 +3193,12 @@
{
gEnv->terrainManager->getWater()->framestep(dt);
}
+
+ // trigger updating of shadows etc
+ SkyManager *sky = gEnv->terrainManager->getSkyManager();
+ if(sky) sky->detectUpdate();
+
+ gEnv->terrainManager->update(dt);
}
//update visual - antishaking
@@ -3205,6 +3211,7 @@
//BeamFactory::getSingleton().updateAI(dt);
}
+
if (!updateEvents(dt))
{
LOG("exiting...");
Modified: trunk/source/main/gfx/SkyManager.cpp
===================================================================
--- trunk/source/main/gfx/SkyManager.cpp 2012-06-02 20:04:00 UTC (rev
2773)
+++ trunk/source/main/gfx/SkyManager.cpp 2012-06-02 21:10:48 UTC (rev
2774)
@@ -22,13 +22,15 @@
#include "SkyManager.h"
#include "Settings.h"
+#include "TerrainManager.h"
+#include "TerrainGeometryManager.h"
#include <Caelum.h>
using namespace Ogre;
//---------------------------------------------------------------------
-SkyManager::SkyManager() : mCaelumSystem(0)
+SkyManager::SkyManager() : mCaelumSystem(0), lc(0)
{
// Initialise CaelumSystem.
mCaelumSystem = new Caelum::CaelumSystem (gEnv->ogreRoot,
gEnv->sceneManager, Caelum::CaelumSystem::CAELUM_COMPONENTS_NONE);
@@ -63,6 +65,19 @@
mCaelumSystem->updateSubcomponents(dt);
}
+void SkyManager::detectUpdate()
+{
+ if (!mCaelumSystem || !gEnv->terrainManager) return;
+ Caelum::LongReal c = mCaelumSystem->getUniversalClock()->getJulianDay();
+
+ if(c - lc > 0.001f)
+ {
+ gEnv->terrainManager->getGeometryManager()->updateLightMap();
+ }
+
+ lc = c;
+}
+
void SkyManager::loadScript(String script)
{
// load the caelum config
Modified: trunk/source/main/gfx/SkyManager.h
===================================================================
--- trunk/source/main/gfx/SkyManager.h 2012-06-02 20:04:00 UTC (rev 2773)
+++ trunk/source/main/gfx/SkyManager.h 2012-06-02 21:10:48 UTC (rev 2774)
@@ -47,8 +47,10 @@
void forceUpdate(float dt);
void notifyCameraChanged(Ogre::Camera *cam);
+
+ void detectUpdate();
protected:
-
+ Caelum::LongReal lc;
Caelum::CaelumSystem *mCaelumSystem;
Caelum::CaelumSystem *getCaelumSystem() { return mCaelumSystem; };
};
Modified: trunk/source/main/terrain/TerrainGeometryManager.cpp
===================================================================
--- trunk/source/main/terrain/TerrainGeometryManager.cpp 2012-06-02
20:04:00 UTC (rev 2773)
+++ trunk/source/main/terrain/TerrainGeometryManager.cpp 2012-06-02
21:10:48 UTC (rev 2774)
@@ -121,7 +121,35 @@
mTerrainGroup->freeTemporaryResources();
}
+void TerrainGeometryManager::updateLightMap()
+{
+ TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
+ while(ti.hasMoreElements())
+ {
+ Terrain *terrain = ti.getNext()->instance;
+ //ShadowManager::getSingleton().updatePSSM(terrain);
+ if(!terrain->isDerivedDataUpdateInProgress())
+ {
+ terrain->dirtyLightmap();
+ terrain->updateDerivedData();
+ }
+ }
+}
+void TerrainGeometryManager::update(float dt)
+{
+ Light *light = gEnv->terrainManager->getMainLight();
+ TerrainGlobalOptions *terrainOptions =
TerrainGlobalOptions::getSingletonPtr();
+ if (light)
+ {
+
terrainOptions->setLightMapDirection(light->getDerivedDirection());
+
terrainOptions->setCompositeMapDiffuse(light->getDiffuseColour());
+ }
+
terrainOptions->setCompositeMapAmbient(gEnv->sceneManager->getAmbientLight());
+
+ mTerrainGroup->update();
+}
+
void TerrainGeometryManager::configureTerrainDefaults()
{
OGRE_NEW TerrainGlobalOptions();
Modified: trunk/source/main/terrain/TerrainGeometryManager.h
===================================================================
--- trunk/source/main/terrain/TerrainGeometryManager.h 2012-06-02 20:04:00 UTC
(rev 2773)
+++ trunk/source/main/terrain/TerrainGeometryManager.h 2012-06-02 21:10:48 UTC
(rev 2774)
@@ -60,6 +60,9 @@
}
Ogre::Vector3 getMaxTerrainSize();
+
+ void update(float dt);
+ void updateLightMap();
protected:
Ogre::ConfigFile terrainConfig;
Modified: trunk/source/main/terrain/TerrainManager.h
===================================================================
--- trunk/source/main/terrain/TerrainManager.h 2012-06-02 20:04:00 UTC (rev
2773)
+++ trunk/source/main/terrain/TerrainManager.h 2012-06-02 21:10:48 UTC (rev
2774)
@@ -54,6 +54,7 @@
Ogre::Light *getMainLight() { return main_light; };
Ogre::Vector3 getSpawnPos() { return start_position; };
bool getTrucksLoaded() { return trucksLoaded; };
+ TerrainGeometryManager *getGeometryManager() { return geometry_manager;
};
protected:
// members
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel