I have a problem with a terrain (using code from the tutorial on the wiki) on 1.9 static linked.
It runs fine in the IDE (VS.net 2010) in release mode but crashes when running from the executable ("application has stopped working").
This is the last thing the log file says. So, it doesn't really help in this case.
My whole application is in-line while I get this sorted out (before I break it up and place into my main app).09:47:16: Terrain created; size=513 minBatch=33 maxBatch=65 treeDepth=4 lodLevels=5 leafLods=2
09:47:26: Texture: dirt256.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) Internal format is PF_X8R8G8B8,256x256x1.
09:47:26: Texture: dirt04.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) Internal format is PF_X8R8G8B8,512x512x1.
09:47:26: Texture: adirt20.jpg: Loading 1 faces(PF_R8G8B8,512x512x1) Internal format is PF_X8R8G8B8,512x512x1.
This is the terrain generation section before the main loop is entered.
Code: Select all
// Terrain global options
TerrainGlobalOptions* mTerrainGlobals=new TerrainGlobalOptions();
mTerrainGlobals->setMaxPixelError(8);
mTerrainGlobals->setCompositeMapDistance(3000);
mTerrainGlobals->setLightMapDirection(light->getDerivedDirection());
mTerrainGlobals->setCompositeMapAmbient(mSceneMgr->getAmbientLight());
mTerrainGlobals->setCompositeMapDiffuse(light->getDiffuseColour());
// Terrain group
TerrainGroup* mTerrainGroup=new TerrainGroup(mSceneMgr,Ogre::Terrain::ALIGN_X_Z,513,1000.0f);
mTerrainGroup->setFilenameConvention(String("BasicTutorial3Terrain"),String("dat"));
mTerrainGroup->setOrigin(Vector3::ZERO);
// Configure default import settings for if we use imported image
Terrain::ImportData& defaultimp=mTerrainGroup->getDefaultImportSettings();
defaultimp.terrainSize=2049;
defaultimp.worldSize=1000.0f;
defaultimp.inputScale=100;
defaultimp.minBatchSize=33;
defaultimp.maxBatchSize=65;
// textures
defaultimp.layerList.resize(3);
defaultimp.layerList[0].worldSize=50;
defaultimp.layerList[0].textureNames.push_back("dirt256.jpg");
defaultimp.layerList[1].worldSize=100;
defaultimp.layerList[1].textureNames.push_back("dirt04.jpg");
defaultimp.layerList[2].worldSize=200;
defaultimp.layerList[2].textureNames.push_back("adirt20.jpg");
for(long x=0;x<=0;++x)
{
for(long y=0;y<=0;++y)
{
String filename=mTerrainGroup->generateFilename(x,y);
if(ResourceGroupManager::getSingleton().resourceExists(mTerrainGroup->getResourceGroup(),filename))
mTerrainGroup->defineTerrain(x,y);
else
{
Image img;
img.load("terrain.png",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
if(x%2!=0)
img.flipAroundY();
if(y%2!=0)
img.flipAroundX();
mTerrainGroup->defineTerrain(x,y,&img);
}
}
}
mTerrainGroup->loadAllTerrains(true);
TerrainGroup::TerrainIterator ti=mTerrainGroup->getTerrainIterator();
while(ti.hasMoreElements())
{
Terrain* terrain=ti.getNext()->instance;
TerrainLayerBlendMap* blendMap0=terrain->getLayerBlendMap(1);
TerrainLayerBlendMap* blendMap1=terrain->getLayerBlendMap(2);
Real minHeight0=70;
Real fadeDist0=40;
Real minHeight1=70;
Real fadeDist1=15;
float* pBlend1=blendMap1->getBlendPointer();
for(uint16 y=0;y<terrain->getLayerBlendMapSize();++y)
{
for(uint16 x=0;x<terrain->getLayerBlendMapSize();++x)
{
Real tx,ty;
blendMap0->convertImageToTerrainSpace(x,y,&tx,&ty);
Real height=terrain->getHeightAtTerrainPosition(tx,ty);
Real val=(height-minHeight0)/fadeDist0;
val=Math::Clamp(val,(Real)0,(Real)1);
val=(height-minHeight1)/fadeDist1;
val=Math::Clamp(val,(Real)0,(Real)1);
*pBlend1++=val;
}
}
blendMap0->dirty();
blendMap1->dirty();
blendMap0->update();
blendMap1->update();
}
mTerrainGroup->freeTemporaryResources();
[edit]
Some futher debugging reveals that the application crashes on mTerrainGroup->loadAllTerrains(true);
Also found that using the same assets as used in the tutorial (http://www.ogre3d.org/tikiwiki/tiki-ind ... =Tutorials) is causing a stack overflow. So, I am somewhat confused