• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            場景查詢
            創建查詢的代價比較大,而執行不是。SceneQueryResualt只定義了兩種成員:movables與worldFragments.
            掩碼也需要自己定義,自己解釋。在一個軸對齊盒子中查詢燈光的例子如下:
            const unsigned int LIGHT_QUERY_MASK = 0x00000001; //掩碼定義
            Light* light1 = mSceneMgr->createLight("Light1");
            Light* light2 = mSceneMgr->createLight("Light2");
            light1->setPosition(12, 12, 12);
            light2->setPosition(5, 5, 5);
            light1->setQueryFlags(LIGHT_QUERY_MASK);
            light2->setQueryFlags(LIGHT_QUERY_MASK);
            AxisAlignedBoxSceneQuery* lightQuery =
            mSceneMgr->createAABBQuery(
            AxisAlignedBox(0, 0, 0, 10, 10, 10), LIGHT_QUERY_MASK);
            // sometime later in the application's code, find out what lights are in the box
            SceneQueryResult& results = lightQuery->execute(); //查詢
            // iterate through the list of items returned; there should only be one, and it
            // should be light2 created above. The list iterator is MovableObject type.
            SceneQueryResultMovableList::iterator it = results.movables.begin();
            for (; it != results.movables.end(); it++)
            {
            // act only on the lights, which should be all we have
            assert ((*it)->getQueryFlags() & LIGHT_QUERY_MASK) != 0);
            // do whatever it was we needed to do with the lights
            }
            // destroy the query when we are done with it
            mSceneMgr->destroyQuery(lightQuery);

            我們知道地形總是起伏不平的,當主角在上面行走時需要根據地形的高度調整,可以光線查詢來實現。
            原理比較簡單:向主角腳下執行光線查詢,與地形有一個交點,根據交點的高度調整主角位置。
            Terrain Clamping
            void Entity::clampToTerrain() {
            static Ogre::Ray updateRay;
            updateRay.setOrigin(m_controlledNode->getPosition() + Ogre::Vector3(0, 15, 0));
            updateRay.setDirection(Ogre::Vector3::NEGATIVE_UNIT_Y);
            m_raySceneQuery->setRay(updateRay);
            Ogre::RaySceneQueryResult& qryResult = m_raySceneQuery->execute();
            if (qryResult.size() == 0) {
            // then we are under the terrain and need to pop above it
            updateRay.setOrigin(m_controlledNode->getPosition());
            updateRay.setDirection(Ogre::Vector3::UNIT_Y);
            m_raySceneQuery->setRay(updateRay);
            }
            qryResult = m_raySceneQuery->execute();
            Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
            if (i != qryResult.end() && i->worldFragment)
            {
            Ogre::SceneQuery::WorldFragment* wf = i->worldFragment;
            m_controlledNode->setPosition(m_controlledNode->getPosition().x,
            i->worldFragment->singleIntersection.y,
            m_controlledNode->getPosition().z);
            }
            }
            void Entity::init()
            {
            // lots of other irrelevant entity init stuff goes here
            m_raySceneQuery = sm->createRayQuery(
            Ogre::Ray(m_controlledNode->getPosition(),
            Ogre::Vector3::NEGATIVE_UNIT_Y));
            // move this node is such a way that it is above the terrain
            clampToTerrain();
            }

            posted on 2007-03-11 17:24 清源游民 閱讀(1160) 評論(0)  編輯 收藏 引用 所屬分類: OGRE
            <2007年3月>
            25262728123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            留言簿(35)

            隨筆分類(78)

            隨筆檔案(74)

            文章檔案(5)

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            99久久免费国产特黄| 久久精品一区二区三区中文字幕| 一本一本久久a久久综合精品蜜桃| 久久婷婷五月综合色奶水99啪 | 久久综合九色综合网站| 免费观看成人久久网免费观看| 国内精品久久久久久久久| 久久综合色老色| 国产成人99久久亚洲综合精品| 性做久久久久久久久老女人| 色综合久久久久综合体桃花网| 国产精品成人99久久久久| 久久无码人妻一区二区三区| 久久久免费观成人影院| 久久综合综合久久97色| 久久成人国产精品免费软件| 国产精品丝袜久久久久久不卡| 男女久久久国产一区二区三区| 久久久久国产成人精品亚洲午夜| 99久久精品国内| 久久这里只有精品18| 久久天天躁狠狠躁夜夜躁2014| 久久综合精品国产一区二区三区| 久久精品人人做人人妻人人玩| 亚洲国产精品综合久久一线| 久久精品这里只有精99品| 国产精品成人久久久久久久| 久久精品国产99国产电影网 | 久久综合色老色| 久久人人爽人人爽人人片AV麻豆 | 久久精品夜夜夜夜夜久久| 精品综合久久久久久98| 久久天天躁狠狠躁夜夜avapp| 久久久国产99久久国产一| 久久亚洲国产精品五月天婷| 欧美伊人久久大香线蕉综合69| 国产精品99久久精品爆乳| 国产精品成人久久久久三级午夜电影 | 亚洲国产精品婷婷久久| 日韩欧美亚洲综合久久影院d3| 99久久成人18免费网站|