This tutorial demonstrates how to render a heightmap-based terrain using the Terrain scene manager.
[From App_Terrain.cpp
]
class App_Terrain: public BaseDemo
{
public:
virtual void initEvent()
{
Log::notify(appletInfo());
{
Log::error("This test requres multi texturing.\n");
Time::sleep(2000);
exit(1);
}
ghostCameraManipulator()->setMovementSpeed(5);
ref<Terrain> terrain = new Terrain;
terrain->setUseGLSL( Has_GL_ARB_shading_language_100 ? true : false );
terrain->setWidth(100);
terrain->setDepth(100);
terrain->setHeight(5.0f);
if (Has_GL_ATI_texture_float || Has_GL_ARB_texture_float)
else
terrain->setOrigin(
vec3(0,0,0));
terrain->setHeightmapTexture("/images/ps_height_4k.jpg");
terrain->setTerrainTexture("/images/ps_texture_4k.jpg");
terrain->setDetailTexture("/images/noise.png");
terrain->setDetailRepetitionCount(8);
terrain->setFragmentShader("/glsl/terrain.fs");
terrain->setVertexShader("/glsl/terrain.vs");
terrain->init();
rendering()->
as<Rendering>()->sceneManagers()->push_back( terrain.get() );
if (!terrain->useGLSL())
{
rendering()->
as<Rendering>()->camera()->viewport()->setClearColor(white);
ref<Fog> fog = new Fog;
fog->setColor(white);
fog->setDensity(0.045f);
terrain->shaderNode()->setRenderState(
IN_Propagate, fog.get());
terrain->shaderNode()->setEnable(
EN_FOG,
true);
terrain->shaderNode()->updateHierarchy();
}
#if 0
showBoundingVolumes(1,0);
#endif
}
};