Revision: 2648
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2648&view=rev
Author: rorthomas
Date: 2012-05-24 14:30:25 +0000 (Thu, 24 May 2012)
Log Message:
-----------
terrain WIP: fixed crash
fixed autogears displayed inverted
Modified Paths:
--------------
trunk/source/main/gameplay/RoRFrameListener.cpp
trunk/source/main/gameplay/TerrainManager.cpp
trunk/source/main/gameplay/TerrainManager.h
trunk/source/main/physics/Beam.cpp
trunk/source/main/physics/collision/heightfinder.h
Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-24 14:15:56 UTC
(rev 2647)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-24 14:30:25 UTC
(rev 2648)
@@ -4121,7 +4121,7 @@
// we choose the heightfinder depending on whether we use the classical
// terrain or the new one
if (newTerrainMode)
- hfinder = new NTHeightFinder(mTerrainGroup, Vector3::ZERO);
+ hfinder = new NTHeightFinder(terrainManager, Vector3::ZERO);
else
hfinder = new TSMHeightFinder(geom, terrainmap, wheight);
Modified: trunk/source/main/gameplay/TerrainManager.cpp
===================================================================
--- trunk/source/main/gameplay/TerrainManager.cpp 2012-05-24 14:15:56 UTC
(rev 2647)
+++ trunk/source/main/gameplay/TerrainManager.cpp 2012-05-24 14:30:25 UTC
(rev 2648)
@@ -65,7 +65,6 @@
return true;
}
-
void TerrainManager::initTerrain()
{
// X, Y and Z scale
@@ -73,7 +72,7 @@
mapsizey = PARSEINT(terrainConfig.getSetting("MaxHeight"));
mapsizez = PARSEINT(terrainConfig.getSetting("PageWorldZ"));
pageSize = PARSEINT(terrainConfig.getSetting("PageSize"));
- terrainSize = pageSize;
+ terrainSize = mapsizex+1;
worldSize = std::max(mapsizex, mapsizez);
String terrainFileSuffix = "mapbin";
@@ -93,9 +92,6 @@
mTerrainGroup->setOrigin(mTerrainPos);
mTerrainGroup->setResourceGroup("cache");
- OGRE_NEW TerrainGlobalOptions();
- // Configure global
-
configureTerrainDefaults();
String filename = mTerrainGroup->generateFilename(0, 0);
@@ -116,7 +112,7 @@
{
Terrain *terrain = ti.getNext()->instance;
//ShadowManager::getSingleton().updatePSSM(terrain);
- //initBlendMaps(terrain);
+ initBlendMaps(terrain);
}
}
@@ -124,12 +120,14 @@
//mTerrainGroup->saveAllTerrains(false);
}
- //mTerrainGroup->freeTemporaryResources();
+ mTerrainGroup->freeTemporaryResources();
}
void TerrainManager::configureTerrainDefaults()
{
+ OGRE_NEW TerrainGlobalOptions();
+
Light *light = SkyManager::getSingleton().getMainLight();
TerrainGlobalOptions *terrainOptions =
TerrainGlobalOptions::getSingletonPtr();
// Configure global
@@ -272,6 +270,44 @@
}
}
+void TerrainManager::getTerrainImage(int x, int y, Image& img)
+{
+ // create new from image
+ String heightmapString = "Heightmap.image." + TOSTRING(x) + "." +
TOSTRING(y);
+ String heightmapFilename = terrainConfig.getSetting(heightmapString);
+ if (heightmapFilename.empty())
+ {
+ // try loading the old non-paged name
+ heightmapString = "Heightmap.image";
+ heightmapFilename = terrainConfig.getSetting(heightmapString);
+ }
+
+ if (heightmapFilename.find(".raw") != String::npos)
+ {
+ int rawSize =
StringConverter::parseInt(terrainConfig.getSetting("Heightmap.raw.size"));
+ int bpp =
StringConverter::parseInt(terrainConfig.getSetting("Heightmap.raw.bpp"));
+
+ // load raw data
+ DataStreamPtr stream =
ResourceGroupManager::getSingleton().openResource(heightmapFilename);
+ LOG(" loading RAW image: " + TOSTRING(stream->size()) + " / " +
TOSTRING(rawSize*rawSize*bpp));
+ PixelFormat pformat = PF_L8;
+ if (bpp == 2)
+ pformat = PF_L16;
+ img.loadRawData(stream, rawSize, rawSize, 1, pformat);
+ } else
+ {
+ img.load(heightmapFilename,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ }
+
+ if (!terrainConfig.getSetting("Heightmap.flip").empty() &&
StringConverter::parseBool(terrainConfig.getSetting("Heightmap.flip")))
+ img.flipAroundX();
+
+ //if (flipX)
+ // img.flipAroundY();
+ //if (flipY)
+ // img.flipAroundX();
+}
+
void TerrainManager::defineTerrain( int x, int y, bool flat )
{
if (flat)
@@ -288,42 +324,8 @@
}
else
{
- // create new from image
- String heightmapString = "Heightmap.image." + TOSTRING(x) + "."
+ TOSTRING(y);
- String heightmapFilename =
terrainConfig.getSetting(heightmapString);
- if (heightmapFilename.empty())
- {
- // try loading the old non-paged name
- heightmapString = "Heightmap.image";
- heightmapFilename =
terrainConfig.getSetting(heightmapString);
- }
Image img;
- if (heightmapFilename.find(".raw") != String::npos)
- {
- int rawSize =
StringConverter::parseInt(terrainConfig.getSetting("Heightmap.raw.size"));
- int bpp =
StringConverter::parseInt(terrainConfig.getSetting("Heightmap.raw.bpp"));
-
- // load raw data
- DataStreamPtr stream =
ResourceGroupManager::getSingleton().openResource(heightmapFilename);
- LOG(" loading RAW image: " + TOSTRING(stream->size()) +
" / " + TOSTRING(rawSize*rawSize*bpp));
- PixelFormat pformat = PF_L8;
- if (bpp == 2)
- pformat = PF_L16;
- img.loadRawData(stream, rawSize, rawSize, 1, pformat);
- } else
- {
- img.load(heightmapFilename,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- }
-
- if (!terrainConfig.getSetting("Heightmap.flip").empty() &&
StringConverter::parseBool(terrainConfig.getSetting("Heightmap.flip")))
- img.flipAroundX();
-
-
- //if (x % 2 != 0)
- // img.flipAroundY();
- //if (y % 2 != 0)
- // img.flipAroundX();
-
+ getTerrainImage(x, y, img);
mTerrainGroup->defineTerrain(x, y, &img);
mTerrainsImported = true;
}
Modified: trunk/source/main/gameplay/TerrainManager.h
===================================================================
--- trunk/source/main/gameplay/TerrainManager.h 2012-05-24 14:15:56 UTC (rev
2647)
+++ trunk/source/main/gameplay/TerrainManager.h 2012-05-24 14:30:25 UTC (rev
2648)
@@ -38,6 +38,8 @@
void loadTerrain(Ogre::String filename);
+ inline Ogre::TerrainGroup *getTerrainGroup() { return mTerrainGroup; };
+
protected:
bool disableCaching;
bool mTerrainsImported;
@@ -59,6 +61,7 @@
void configureTerrainDefaults();
void defineTerrain(int x, int y, bool flat=false);
void initBlendMaps( Ogre::Terrain* t );
+ void getTerrainImage(int x, int y, Ogre::Image& img);
};
#endif // TERRAINMANAGER_H__
Modified: trunk/source/main/physics/Beam.cpp
===================================================================
--- trunk/source/main/physics/Beam.cpp 2012-05-24 14:15:56 UTC (rev 2647)
+++ trunk/source/main/physics/Beam.cpp 2012-05-24 14:30:25 UTC (rev 2648)
@@ -6031,7 +6031,7 @@
if(hasEngine)
{
hasturbo = engine->hasturbo;
- autogearVisible = (engine->getAutoShift() ==
BeamEngine::MANUALMODE);
+ autogearVisible = (engine->getAutoShift() !=
BeamEngine::MANUALMODE);
}
dash->setEnabled(DD_ENGINE_TURBO, hasturbo);
Modified: trunk/source/main/physics/collision/heightfinder.h
===================================================================
--- trunk/source/main/physics/collision/heightfinder.h 2012-05-24 14:15:56 UTC
(rev 2647)
+++ trunk/source/main/physics/collision/heightfinder.h 2012-05-24 14:30:25 UTC
(rev 2648)
@@ -24,6 +24,8 @@
#include "OgreTerrainGroup.h"
+#include "TerrainManager.h"
+
/**
* This is the common interface for all Scene-Manager specific implementations
of the Height-Finder
*/
@@ -52,8 +54,9 @@
{
public:
- NTHeightFinder(Ogre::TerrainGroup *tg, Ogre::Vector3 tp) :
mTerrainGroup(tg), mTerrainPos(tp)
+ NTHeightFinder(TerrainManager *tm, Ogre::Vector3 tp) :
mTerrainGroup(0), mTerrainPos(tp)
{
+ mTerrainGroup = tm->getTerrainGroup();
}
~NTHeightFinder()
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