zoukankan      html  css  js  c++  java
  • OGRE学习笔记(一)通过例子了解场景管理器地形创建

    有人说没有开过车就造不出好车,没有有过游戏引擎就写不出好的引擎。

    所以最近开始学习OGRE,网上很多资料,但是又有点让人无从下手。最后决定还是从pro ogre 3d programing开始看,是中文翻译的版本。

    看到第五章,里面有个创建地形的例子,可能由于打字或者是版本的问题,电子书上面贴的代码有点问题,修改了一下才能运行。

    用ogre pplication Wizard生成代码修改void yourclass::createScene()

    createScene
    void yourclass::createScene(void)
    {
    // Set ambient light

    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));

    // Create a light

    Ogre::Light* l = mSceneMgr->createLight("MainLight");



    // Accept default settings: point light, white diffuse, just set position

    l->setPosition(20,80,50);



    Ogre::ColourValue fadeColour(0.93, 0.86, 0.76);

    mSceneMgr->setFog( Ogre::FOG_LINEAR, fadeColour, .001, 500, 1000);

    mWindow->getViewport(0)->setBackgroundColour(fadeColour);



    std::string terrain_cfg("terrain.cfg");

    mSceneMgr -> setWorldGeometry(terrain_cfg);



    // Infinite far plane?

    if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))

    {

    mCamera->setFarClipDistance(0);

    }

    // Define the required skyplane

    Ogre::Plane plane;

    // 5000 world units from the camera

    plane.d = 300;

    // Above the camera, facing down

    plane.normal = -Ogre::Vector3::UNIT_Y;


    mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky");


    // Set a nice viewpoint

    mCamera->setPosition(707,250,528);

    mCamera->lookAt(0, 0, 0);





    }

    还有一点需要注意:还需要修改void BaseApplication::chooseSceneManager(void)

    默认的场景管理器(mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC))似乎不支持从地形配置文件读取地形

    弹以出下错误

    代码修改成

    void BaseApplication::chooseSceneManager(void)
    void BaseApplication::chooseSceneManager(void)
    {
    // Get the SceneManager, in this case a generic one
    //mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
    mSceneMgr = mRoot->createSceneManager(Ogre::ST_EXTERIOR_CLOSE);
    //mSceneMgr = mRoot->createSceneManager("OctreeSceneManager");

    }

    才正确:




     

  • 相关阅读:
    [bbk3153] 第62集 Chapter 15Application Tuning(02)
    [bbk3152] 第61集 Chapter 15Application Tuning(01)
    [bbk1190]第2集 Chapter 01Oracle Architectural
    PL/SQL高级Creating Packages (01)
    Statspack00
    [bbk3201] 第64集 Chapter 16Using Materialized Views 00
    该如何选择国外VPS
    优化升级logging封装RotatingFileHandler
    smtp ssl模式邮件发送与附件添加
    smtp outlook邮件发送非授权码模式
  • 原文地址:https://www.cnblogs.com/wonderKK/p/2416593.html
Copyright © 2011-2022 走看看