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");

    }

    才正确:




     

  • 相关阅读:
    解决android.os.NetworkOnMainThreadException
    android 模拟器对应键盘快捷键
    Android上解析Json格式数据
    命令行的由来
    Linux测网速
    cacti
    判断端口是否开放
    Linux中运行c程序,与系统打交道
    python 多线程
    Leetcode 编程训练(转载)
  • 原文地址:https://www.cnblogs.com/wonderKK/p/2416593.html
Copyright © 2011-2022 走看看