废话不多说,直接上代码和图片
#include "ExampleApplication.h"
class TutorialApplication : public ExampleApplication
{
protected:
public:
TutorialApplication()
{
}
~TutorialApplication()
{
}
protected:
void chooseSceneManager(void)
{
//将场景管理器设为地面的场景管理器
mSceneMgr = mRoot->createSceneManager(ST_EXTERIOR_CLOSE);
//初始化一个资源组
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
void createScene(void)
{
/*********************************************************************************************/
//普通天空
//加载地面属性
//mSceneMgr->setWorldGeometry( "terrain.cfg" );
//天空盒
//mSceneMgr->setSkyBox( true, "Examples/SpaceSkyBox" );
//天空穹
//mSceneMgr->setSkyDome( true, "Examples/CloudySky", 5, 8 );
//天空面
//Plane plane;
//plane.d = 1000;
//plane.normal = Vector3::NEGATIVE_UNIT_Y;
//mSceneMgr->setSkyPlane( true, plane, "Examples/SpaceSkyPlane", 1500, 75 );
//mSceneMgr->setSkyPlane( true, plane, "Examples/CloudySky", 1500, 40, true, 1.5f, 150, 150 );
/*********************************************************************************************/
//普通雾效
//设置视口的背景颜色
//ColourValue fadeColour(0.9, 0.9, 0.9);
//mWindow->getViewport(0)->setBackgroundColour(fadeColour);
//mSceneMgr->setFog(FOG_LINEAR, fadeColour, 0.0, 50, 500);
//加载地面属性
//mSceneMgr->setWorldGeometry( "terrain.cfg" );
/*********************************************************************************************/
//天空面雾效
/*ColourValue fadeColour(0.9, 0.9, 0.9);
mSceneMgr->setFog(FOG_LINEAR, fadeColour, 0.0, 0, 130);
mWindow->getViewport(0)->setBackgroundColour(fadeColour);
Plane plane;
plane.d = 100;
plane.normal = Vector3::NEGATIVE_UNIT_Y;
mSceneMgr->setWorldGeometry("terrain.cfg");
mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky", 500, 20, true, 0.5, 150, 150);*/
/*********************************************************************************************/
//黑暗中的雾效
ColourValue fadeColour(0.1, 0.1, 0.1);
mWindow->getViewport(0)->setBackgroundColour(fadeColour);
mSceneMgr->setFog(FOG_LINEAR, fadeColour, 0.0, 10, 150);
mSceneMgr->setWorldGeometry("terrain.cfg");
Plane plane;
plane.d = 10;
plane.normal = Vector3::NEGATIVE_UNIT_Y;
mSceneMgr->setSkyPlane(true, plane, "Examples/SpaceSkyPlane", 100, 45, true, 0.5, 150, 150);
}
};
#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;
}