I think I found a small bug in TerrainSceneManager. The bug is that it doesn't apply the world texture and the detail texture correctly (the code for setting the texture coordinates has an error). I made a small example to reproduce the bug, based on basic tutorial 3. Here is the code and the textures I used.
Code: Select all
#include "ExampleApplication.h"
class TutorialApplication : public ExampleApplication
{
protected:
public:
TutorialApplication()
{
}
~TutorialApplication()
{
}
protected:
void chooseSceneManager(void)
{
mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);
}
void createScene(void)
{
mSceneMgr->setWorldGeometry( "terrain.cfg" );
}
void createCamera(void)
{
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(0,100,0));
mCamera->lookAt(Vector3(250,100,0));
mCamera->setNearClipDistance(5);
}
};
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
// Create application object
TutorialApplication app;
try {
app.go();
} catch( Exception& e ) {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occured: %s\n",
e.getFullDescription().c_str());
#endif
}
return 0;
}
The world texture
The detail texture
Here is what it looks like when running the program
As you can see, the right and top side of the world texture is not displayed, and the detail texture doesn't display correctly at the right and top.
Here is how it looks with the fix
Everything is now as it should.
The fix:
In the file OgreTerrainRenderable.cpp, at line 211, change this
Code: Select all
*pTex0++ = ( float ) i / ( float ) msOptions->pageSize;
*pTex0++ = ( float ) ( float ) j / ( float ) msOptions->pageSize;
*pTex1++ = ( ( float ) i / ( float ) msOptions->tileSize ) * msOptions->detailTile;
*pTex1++ = ( ( float ) ( float ) j / ( float ) msOptions->tileSize ) * msOptions->detailTile;
Code: Select all
*pTex0++ = ( float ) i / ( float ) (msOptions->pageSize - 1);
*pTex0++ = ( float ) ( float ) j / ( float ) (msOptions->pageSize - 1);
*pTex1++ = ( ( float ) i / ( float ) (msOptions->tileSize - 1) ) * msOptions->detailTile;
*pTex1++ = ( ( float ) ( float ) j / ( float ) (msOptions->tileSize - 1) ) * msOptions->detailTile;